sl@0
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef __SQLSRVCONFIG_H__
|
sl@0
|
17 |
#define __SQLSRVCONFIG_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <f32file.h>
|
sl@0
|
21 |
#include "SqlAssert.h"
|
sl@0
|
22 |
#include "SqlUtil.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
//Forward declarations
|
sl@0
|
25 |
class RFs;
|
sl@0
|
26 |
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
TSqlSrvConfigParams structure represents a set of configurable SQLITE parameters.
|
sl@0
|
29 |
These are:
|
sl@0
|
30 |
@code
|
sl@0
|
31 |
- iCacheSize - page cache size in pages;
|
sl@0
|
32 |
- iPageSize - page size in bytes;
|
sl@0
|
33 |
- iDbEncoding - database encoding - 16-bit or 8-bit;
|
sl@0
|
34 |
- iSoftHeapLimitKb - soft heap limit in Kb;
|
sl@0
|
35 |
- iCompactMode - manual, background, automatic;
|
sl@0
|
36 |
- iFreePageThresholdKb - free page threshold (in Kb) is used by the background compaction framework;
|
sl@0
|
37 |
@endcode
|
sl@0
|
38 |
|
sl@0
|
39 |
There is only one way a valid TSqlSrvConfigParams object to be created - using TSqlSrvConfig::GetConfigParamsL().
|
sl@0
|
40 |
GetConfigParamsL() uses an algorithm, described in TSqlSrvConfig class' comments, to decide which parameter value,
|
sl@0
|
41 |
shall be used: build time, config file or the client defined one.
|
sl@0
|
42 |
|
sl@0
|
43 |
@see TSqlSrvConfig
|
sl@0
|
44 |
@see TSqlSrvConfig::GetConfigParamsL()
|
sl@0
|
45 |
@internalComponent
|
sl@0
|
46 |
*/
|
sl@0
|
47 |
NONSHARABLE_STRUCT(TSqlSrvConfigParams)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
enum {KConfigPrmValueNotSet = -1};//iCacheSize, iPageSize, iSoftHeapLimitKb are initialized by default with KConfigPrmValueNotSet
|
sl@0
|
50 |
enum TDbEncoding {EEncNotSet, EEncUtf8, EEncUtf16};//Database encoding: the default value for iDbEncoding is EEncNotSet
|
sl@0
|
51 |
enum
|
sl@0
|
52 |
{
|
sl@0
|
53 |
#ifdef __WINSCW__
|
sl@0
|
54 |
KDefaultSoftHeapLimitKb = 1024,
|
sl@0
|
55 |
#else
|
sl@0
|
56 |
KDefaultSoftHeapLimitKb = 8192,
|
sl@0
|
57 |
#endif
|
sl@0
|
58 |
#ifdef SYSLIBS_TEST
|
sl@0
|
59 |
KMinSoftHeapLimitKb = 8,
|
sl@0
|
60 |
#else
|
sl@0
|
61 |
KMinSoftHeapLimitKb = 512,
|
sl@0
|
62 |
#endif
|
sl@0
|
63 |
KMaxSoftHeapLimitKb = KMaxTInt / 1024
|
sl@0
|
64 |
};
|
sl@0
|
65 |
|
sl@0
|
66 |
TSqlSrvConfigParams();
|
sl@0
|
67 |
|
sl@0
|
68 |
TInt iCacheSize;
|
sl@0
|
69 |
TInt iPageSize;
|
sl@0
|
70 |
TDbEncoding iDbEncoding;
|
sl@0
|
71 |
TInt iSoftHeapLimitKb;
|
sl@0
|
72 |
TSqlCompactionMode iCompactionMode;
|
sl@0
|
73 |
TInt iFreePageThresholdKb;
|
sl@0
|
74 |
};
|
sl@0
|
75 |
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
TSqlSrvConfig class is used for:
|
sl@0
|
78 |
@code
|
sl@0
|
79 |
- keeping the SQL server configuration file parameter values;
|
sl@0
|
80 |
- producing a TSqlSrvConfigParams object with correct SQLITE parameter values when requested (TSqlSrvConfig::GetConfigParamsL());
|
sl@0
|
81 |
@endcode
|
sl@0
|
82 |
|
sl@0
|
83 |
If SQL server config file exists at the moment of the SQL server startup, the SQL server will keep
|
sl@0
|
84 |
a copy of the config file parameter values in a TSqlSrvConfig object.
|
sl@0
|
85 |
|
sl@0
|
86 |
The SQL server will use the following rules, which config parameter should be used:
|
sl@0
|
87 |
@code
|
sl@0
|
88 |
----------------------------------------------------------------------------------------------
|
sl@0
|
89 |
Server config file parameter | Client config string parameter | What parameter is used
|
sl@0
|
90 |
----------------------------------------------------------------------------------------------
|
sl@0
|
91 |
.No..........................|.No.............................|.Build-time config parameter
|
sl@0
|
92 |
.No..........................|.Yes............................|.Client config string parameter
|
sl@0
|
93 |
.Yes.........................|.No.............................|.Server config file parameter
|
sl@0
|
94 |
.Yes.........................|.Yes............................|.Client config string parameter
|
sl@0
|
95 |
----------------------------------------------------------------------------------------------
|
sl@0
|
96 |
@endcode
|
sl@0
|
97 |
|
sl@0
|
98 |
TSqlSrvConfig::InitL() should be used once for loading the config parameter values from the SQL server comfiguration file.
|
sl@0
|
99 |
|
sl@0
|
100 |
TSqlSrvConfig::GetConfigParamsL() can be used for retrieving correctly initialized TSqlSrvConfigParams object.
|
sl@0
|
101 |
The rules described in the table above will be used for producing correct set of config parameter values in
|
sl@0
|
102 |
the created TSqlSrvConfigParams object.
|
sl@0
|
103 |
|
sl@0
|
104 |
There are exceptions from the rules and these are:
|
sl@0
|
105 |
- the "soft heap limit" parameter, which cannot be set using a configuration string,
|
sl@0
|
106 |
it is a config file only parameter;
|
sl@0
|
107 |
- the "free page threshold" parameter, which cannot be set using a configuration string,
|
sl@0
|
108 |
it is a config file only parameter;
|
sl@0
|
109 |
|
sl@0
|
110 |
The configuration string format is: "PARAM1=VALUE1;PARAM2=VALUE2;...."
|
sl@0
|
111 |
|
sl@0
|
112 |
@see TSqlSrvConfigParams
|
sl@0
|
113 |
@internalComponent
|
sl@0
|
114 |
*/
|
sl@0
|
115 |
NONSHARABLE_CLASS(TSqlSrvConfig)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
public:
|
sl@0
|
118 |
void InitL(RFs& aFs, const TDesC& aFileName);
|
sl@0
|
119 |
void GetConfigParamsL(const TDesC8& aConfigStr, TSqlSrvConfigParams& aConfigParams) const;
|
sl@0
|
120 |
|
sl@0
|
121 |
private:
|
sl@0
|
122 |
static void GetConfigStringFromFileL(RFs& aFs, const TDesC& aFileName, TDes8& aConfigStr);
|
sl@0
|
123 |
static void ExtractConfigParamsFromStringL(const TDesC8& aConfigStr, TSqlSrvConfigParams& aConfigParams);
|
sl@0
|
124 |
static TBool ExtractParamValuePairL(TPtrC8& aConfigStr, TPtrC8& aParamName, TPtrC8& aParamValue);
|
sl@0
|
125 |
static void ExtractParamValueL(const TDesC8& aParamName, const TDesC8& aParamValue, TSqlSrvConfigParams& aConfigParams);
|
sl@0
|
126 |
static TInt GetCacheSizeL(const TDesC8& aParamValue);
|
sl@0
|
127 |
static TInt GetPageSizeL(const TDesC8& aParamValue);
|
sl@0
|
128 |
static TSqlSrvConfigParams::TDbEncoding GetEncoding(const TDesC8& aParamValue);
|
sl@0
|
129 |
static TInt GetSoftHeapLimitL(const TDesC8& aParamValue);
|
sl@0
|
130 |
static TSqlCompactionMode GetCompactionModeL(const TDesC8& aParamValue);
|
sl@0
|
131 |
static TPtrC8 TrimAndConstructPtr(const TUint8* aStr, TInt aLength);
|
sl@0
|
132 |
static TInt GetFreePageThresholdL(const TDesC8& aParamValue);
|
sl@0
|
133 |
|
sl@0
|
134 |
private:
|
sl@0
|
135 |
TSqlSrvConfigParams iConfigFileParams;
|
sl@0
|
136 |
|
sl@0
|
137 |
};
|
sl@0
|
138 |
|
sl@0
|
139 |
/**
|
sl@0
|
140 |
CDbConfigFiles class is used to store the name of each database configuration
|
sl@0
|
141 |
file that exists on the device. Database configuration files are currently
|
sl@0
|
142 |
supported only for shared, secure databases and the name of a configuration
|
sl@0
|
143 |
file is the name of the database itself prefixed with the string ‘cfg’ and
|
sl@0
|
144 |
suffixed with the extension ‘.N’, where N is the version of the configuration
|
sl@0
|
145 |
file. For example, for the database [12345678]a.db a valid configuration
|
sl@0
|
146 |
filename is cfg[12345678]a.db.01. All database configuration files must
|
sl@0
|
147 |
be located in the SQL Server’s private data cage on the Z: drive -
|
sl@0
|
148 |
namely, Z:\private\10281E17\.
|
sl@0
|
149 |
|
sl@0
|
150 |
@internalComponent
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
NONSHARABLE_CLASS(CDbConfigFiles) : public CBase
|
sl@0
|
153 |
{
|
sl@0
|
154 |
public:
|
sl@0
|
155 |
static CDbConfigFiles* NewL(const CDir& aDirEntries);
|
sl@0
|
156 |
~CDbConfigFiles();
|
sl@0
|
157 |
HBufC* FindConfigFile(const TDesC& aDbFilename) const;
|
sl@0
|
158 |
|
sl@0
|
159 |
private:
|
sl@0
|
160 |
CDbConfigFiles();
|
sl@0
|
161 |
void ConstructL(const CDir& aDirEntries);
|
sl@0
|
162 |
void StoreFileNamesL(const CDir& aDirEntries);
|
sl@0
|
163 |
|
sl@0
|
164 |
private:
|
sl@0
|
165 |
RPointerArray<HBufC> iConfigFileNames;
|
sl@0
|
166 |
};
|
sl@0
|
167 |
|
sl@0
|
168 |
#endif//__SQLSRVCONFIG_H__
|