persistentstorage/sql/SRC/Server/SqlSrvConfig.cpp
branchRCL_3
changeset 23 26645d81f48d
parent 0 08ec8eefde2f
child 24 cc28652e0254
equal deleted inserted replaced
21:28839de615b4 23:26645d81f48d
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 //
    14 //
    15 #include <f32file.h>
    15 #include <f32file.h>
    16 #include <f32file64.h>
    16 #include <f32file64.h>
    17 #include "SqlSrvConfig.h"
    17 #include "SqlSrvConfig.h"
    18 #include "SqlSrvUtil.h"
    18 #include "SqlSrvUtil.h"
       
    19 #include "OstTraceDefinitions.h"
       
    20 #ifdef OST_TRACE_COMPILER_IN_USE
       
    21 #include "SqlSrvConfigTraces.h"
       
    22 #endif
       
    23 #include "SqlTraceDef.h"
    19 
    24 
    20 /**
    25 /**
    21 Initializes TSqlSrvConfigParams data members with their default values.
    26 Initializes TSqlSrvConfigParams data members with their default values.
    22 */
    27 */
    23 TSqlSrvConfigParams::TSqlSrvConfigParams() :
    28 TSqlSrvConfigParams::TSqlSrvConfigParams() :
    44 @leave KErrEof No valid config string found in the configuration file;
    49 @leave KErrEof No valid config string found in the configuration file;
    45                Note that the function may also leave with some other system-wide error codes.
    50                Note that the function may also leave with some other system-wide error codes.
    46 */
    51 */
    47 void TSqlSrvConfig::InitL(RFs& aFs, const TDesC& aFileName)
    52 void TSqlSrvConfig::InitL(RFs& aFs, const TDesC& aFileName)
    48 	{
    53 	{
       
    54 	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLSRVCONFIGFILE_INITL_ENTRY, "Entry;0;TSqlSrvConfig::InitL;aFs.Handle()=0x%X;aFileName=%S", (TUint)aFs.Handle(), __SQLPRNSTR(aFileName)));
    49 	if(::FileExists(aFs, aFileName))
    55 	if(::FileExists(aFs, aFileName))
    50 		{
    56 		{
       
    57         SQL_TRACE_INTERNALS(OstTrace0(TRACE_INTERNALS, TSQLSRVCONFIGFILE_INITL1, "0;TSqlSrvConfig::InitL;Config file found"));
    51 		TBuf8<KSqlSrvMaxConfigStrLen> configFileStr;
    58 		TBuf8<KSqlSrvMaxConfigStrLen> configFileStr;
    52 		//Step 1: get the config string from the config file and store the string in configFileStr
    59 		//Step 1: get the config string from the config file and store the string in configFileStr
    53 		TSqlSrvConfig::GetConfigStringFromFileL(aFs, aFileName, configFileStr);
    60 		TSqlSrvConfig::GetConfigStringFromFileL(aFs, aFileName, configFileStr);
       
    61 		__SQLTRACE_INTERNALSVAR(TBuf<100> des16prnbuf);
       
    62         SQL_TRACE_INTERNALS(OstTraceExt1(TRACE_INTERNALS, TSQLSRVCONFIGFILE_INITL2, "0;TSqlSrvConfig::InitL;Config file string=%s", __SQLPRNSTR8(configFileStr, des16prnbuf)));
    54 		//Step 2: extract config file parameters from the string (configFileStr)  and store them in iConfigFileParams
    63 		//Step 2: extract config file parameters from the string (configFileStr)  and store them in iConfigFileParams
    55 		TSqlSrvConfig::ExtractConfigParamsFromStringL(configFileStr, iConfigFileParams);
    64 		TSqlSrvConfig::ExtractConfigParamsFromStringL(configFileStr, iConfigFileParams);
    56 		}
    65 		}
    57 	//If the soft heap limit is not set from the file or the file does not exist - then set the soft heap limit with the default value
    66 	//If the soft heap limit is not set from the file or the file does not exist - then set the soft heap limit with the default value
    58 	if(iConfigFileParams.iSoftHeapLimitKb == TSqlSrvConfigParams::KConfigPrmValueNotSet)
    67 	if(iConfigFileParams.iSoftHeapLimitKb == TSqlSrvConfigParams::KConfigPrmValueNotSet)
    62 	//If the free page threshold is not set from the file or the file does not exist - then set the free page threshold with the default value
    71 	//If the free page threshold is not set from the file or the file does not exist - then set the free page threshold with the default value
    63 	if(iConfigFileParams.iFreePageThresholdKb == TSqlSrvConfigParams::KConfigPrmValueNotSet)
    72 	if(iConfigFileParams.iFreePageThresholdKb == TSqlSrvConfigParams::KConfigPrmValueNotSet)
    64 		{
    73 		{
    65 		iConfigFileParams.iFreePageThresholdKb = KSqlCompactFreePageThresholdKb;
    74 		iConfigFileParams.iFreePageThresholdKb = KSqlCompactFreePageThresholdKb;
    66 		}
    75 		}
       
    76 
       
    77 #ifdef _SQL_RDEBUG_PRINT
       
    78     SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, TSQLSRVCONFIGFILE_INITL_EXIT1, "Exit;0;TSqlSrvConfig::InitL;iCacheSize=%d;iPageSize=%d;iDbEncoding=%d;iSoftHeapLimit=%d", iConfigFileParams.iCacheSize, iConfigFileParams.iPageSize, iConfigFileParams.iDbEncoding, iConfigFileParams.iSoftHeapLimitKb));
       
    79 #else	
       
    80     SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, TSQLSRVCONFIGFILE_INITL_EXIT2, "Exit;0;TSqlSrvConfig::InitL;iCacheSize=%d;iPageSize=%d;iDbEncoding=%{TSqlSrvConfig_TDbEncoding};iSoftHeapLimit=%d", iConfigFileParams.iCacheSize, iConfigFileParams.iPageSize, iConfigFileParams.iDbEncoding, iConfigFileParams.iSoftHeapLimitKb));
       
    81 #endif    
       
    82     SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLSRVCONFIGFILE_INITL_EXIT3, "Exit;0;TSqlSrvConfig::InitL;iCompactionMode=%d;iFreePageThresholdKb=%d", iConfigFileParams.iCompactionMode, iConfigFileParams.iFreePageThresholdKb));
    67 	}
    83 	}
    68 
    84 
    69 /**
    85 /**
    70 Parses the config string parameter (aConfigStr), extracts configuration parameters values and 
    86 Parses the config string parameter (aConfigStr), extracts configuration parameters values and 
    71 and initialises with them aConfigParams data members.
    87 and initialises with them aConfigParams data members.
    80 @leave KErrArgument if the config is not good or the config string contains "soft heap limit" parameter/value pair.
    96 @leave KErrArgument if the config is not good or the config string contains "soft heap limit" parameter/value pair.
    81 @leave KErrArgument if the config is not good or the config string contains "free page threshold" parameter/value pair.
    97 @leave KErrArgument if the config is not good or the config string contains "free page threshold" parameter/value pair.
    82 */
    98 */
    83 void TSqlSrvConfig::GetConfigParamsL(const TDesC8& aConfigStr, TSqlSrvConfigParams& aConfigParams) const
    99 void TSqlSrvConfig::GetConfigParamsL(const TDesC8& aConfigStr, TSqlSrvConfigParams& aConfigParams) const
    84 	{
   100 	{
       
   101 	__SQLTRACE_INTERNALSVAR(TBuf<100> des16prnbuf);
       
   102     SQL_TRACE_INTERNALS(OstTraceExt1(TRACE_INTERNALS, TSQLSRVCONFIGFILE_GETCONFIGPARAMSL_ENTRY, "Entry;0;TSqlSrvConfig::GetConfigParamsL;aConfigStr=%s", __SQLPRNSTR8(aConfigStr, des16prnbuf)));
    85 	TSqlSrvConfigParams tmpConfigParams;
   103 	TSqlSrvConfigParams tmpConfigParams;
    86 	//Step 1: extract configuration parameters from aConfigStr, store them in tmpConfigParams.
   104 	//Step 1: extract configuration parameters from aConfigStr, store them in tmpConfigParams.
    87 	TSqlSrvConfig::ExtractConfigParamsFromStringL(aConfigStr, tmpConfigParams);
   105 	TSqlSrvConfig::ExtractConfigParamsFromStringL(aConfigStr, tmpConfigParams);
    88 	if(tmpConfigParams.iSoftHeapLimitKb != TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   106 	if(tmpConfigParams.iSoftHeapLimitKb != TSqlSrvConfigParams::KConfigPrmValueNotSet || 
    89 	   tmpConfigParams.iFreePageThresholdKb != TSqlSrvConfigParams::KConfigPrmValueNotSet)
   107 	   tmpConfigParams.iFreePageThresholdKb != TSqlSrvConfigParams::KConfigPrmValueNotSet)
   109 	//Step 4: set the soft heap limit.
   127 	//Step 4: set the soft heap limit.
   110 	aConfigParams.iSoftHeapLimitKb = iConfigFileParams.iSoftHeapLimitKb;
   128 	aConfigParams.iSoftHeapLimitKb = iConfigFileParams.iSoftHeapLimitKb;
   111 	//Step 5: set the free page threshold.
   129 	//Step 5: set the free page threshold.
   112 	aConfigParams.iFreePageThresholdKb = iConfigFileParams.iFreePageThresholdKb;
   130 	aConfigParams.iFreePageThresholdKb = iConfigFileParams.iFreePageThresholdKb;
   113 	//Step 6: assert the parameter values.
   131 	//Step 6: assert the parameter values.
   114 	__SQLASSERT(aConfigParams.iPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iPageSize >= 0, ESqlPanicInternalError);
   132 	__ASSERT_DEBUG(aConfigParams.iPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iPageSize >= 0, __SQLPANIC(ESqlPanicInternalError));
   115 	__SQLASSERT(aConfigParams.iCacheSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iCacheSize >= 0, ESqlPanicInternalError);
   133 	__ASSERT_DEBUG(aConfigParams.iCacheSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iCacheSize >= 0, __SQLPANIC(ESqlPanicInternalError));
   116 	__SQLASSERT(aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncNotSet || 
   134 	__ASSERT_DEBUG(aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncNotSet || 
   117 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf8 || 
   135 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf8 || 
   118 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf16, ESqlPanicInternalError);
   136 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf16, __SQLPANIC(ESqlPanicInternalError));
   119 	__SQLASSERT(aConfigParams.iSoftHeapLimitKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   137 	__ASSERT_DEBUG(aConfigParams.iSoftHeapLimitKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   120 	            (aConfigParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
   138 	            (aConfigParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
   121 	             aConfigParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb), ESqlPanicInternalError);
   139 	             aConfigParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb), __SQLPANIC(ESqlPanicInternalError));
   122 	__SQLASSERT(aConfigParams.iCompactionMode == ESqlCompactionNotSet || aConfigParams.iCompactionMode == ESqlCompactionManual || 
   140 	__ASSERT_DEBUG(aConfigParams.iCompactionMode == ESqlCompactionNotSet || aConfigParams.iCompactionMode == ESqlCompactionManual || 
   123 				aConfigParams.iCompactionMode == ESqlCompactionBackground || aConfigParams.iCompactionMode == ESqlCompactionAuto, ESqlPanicInternalError);
   141 				aConfigParams.iCompactionMode == ESqlCompactionBackground || aConfigParams.iCompactionMode == ESqlCompactionAuto, __SQLPANIC(ESqlPanicInternalError));
   124 	__SQLASSERT(aConfigParams.iFreePageThresholdKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   142 	__ASSERT_DEBUG(aConfigParams.iFreePageThresholdKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   125 				aConfigParams.iFreePageThresholdKb >= 0, ESqlPanicInternalError);
   143 				aConfigParams.iFreePageThresholdKb >= 0, __SQLPANIC(ESqlPanicInternalError));
       
   144 #ifdef _SQL_RDEBUG_PRINT
       
   145     SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, TSQLSRVCONFIGFILE_GETCONFIGPARAMSL_EXIT1, "Exit;0;TSqlSrvConfig::GetConfigParamsL;cacheSize=%d;pageSize=%d;dbEncoding=%d;softHeapLimit=%d", aConfigParams.iCacheSize, aConfigParams.iPageSize, aConfigParams.iDbEncoding, aConfigParams.iSoftHeapLimitKb));
       
   146 #else   
       
   147     SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, TSQLSRVCONFIGFILE_GETCONFIGPARAMSL_EXIT2, "Exit;0;TSqlSrvConfig::GetConfigParamsL;cacheSize=%d;pageSize=%d;dbEncoding=%{TSqlSrvConfig_TDbEncoding};softHeapLimit=%d", aConfigParams.iCacheSize, aConfigParams.iPageSize, aConfigParams.iDbEncoding, aConfigParams.iSoftHeapLimitKb));
       
   148 #endif    
       
   149     SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, TSQLSRVCONFIGFILE_GETCONFIGPARAMSL_EXIT3, "Exit;0;TSqlSrvConfig::GetConfigParamsL;compactionMode=%d;freePageThresholdKb=%d", aConfigParams.iCompactionMode, aConfigParams.iFreePageThresholdKb));
   126 	}
   150 	}
   127 
   151 
   128 //The function opeans the aFileName config file and reads the config string, storring it in aConfigStr argument.
   152 //The function opeans the aFileName config file and reads the config string, storring it in aConfigStr argument.
   129 //Preconditions:
   153 //Preconditions:
   130 // - The config file does exist;
   154 // - The config file does exist;
   131 // - It is a file, containing 16-bit strings;
   155 // - It is a file, containing 16-bit strings;
   132 // - aConfigStr max size is at least KSqlSrvMaxConfigStrLen bytes;
   156 // - aConfigStr max size is at least KSqlSrvMaxConfigStrLen bytes;
   133 //The function may leave if some of the file I/O operations (open file, read file) fails.
   157 //The function may leave if some of the file I/O operations (open file, read file) fails.
   134 void TSqlSrvConfig::GetConfigStringFromFileL(RFs& aFs, const TDesC& aFileName, TDes8& aConfigStr)
   158 void TSqlSrvConfig::GetConfigStringFromFileL(RFs& aFs, const TDesC& aFileName, TDes8& aConfigStr)
   135 	{
   159 	{
   136 	__SQLASSERT(aConfigStr.MaxLength() >= KSqlSrvMaxConfigStrLen, ESqlPanicBadArgument);
   160 	__ASSERT_DEBUG(aConfigStr.MaxLength() >= KSqlSrvMaxConfigStrLen, __SQLPANIC2(ESqlPanicBadArgument));
   137 	RFile64 cfgFile;
   161 	RFile64 cfgFile;
   138 	CleanupClosePushL(cfgFile);
   162 	CleanupClosePushL(cfgFile);
   139 	__SQLLEAVE_IF_ERROR(cfgFile.Open(aFs, aFileName, EFileRead));
   163 	__SQLLEAVE_IF_ERROR2(cfgFile.Open(aFs, aFileName, EFileRead));
   140 	TFileText cfgFileReader;
   164 	TFileText cfgFileReader;
   141 	cfgFileReader.Set(cfgFile);
   165 	cfgFileReader.Set(cfgFile);
   142 	TBuf<KSqlSrvMaxConfigStrLen> buf;
   166 	TBuf<KSqlSrvMaxConfigStrLen> buf;
   143 	TBool cfgLineFound = EFalse;
   167 	TBool cfgLineFound = EFalse;
   144 	TInt err = KErrNone;
   168 	TInt err = KErrNone;
   154 		break;
   178 		break;
   155 		}
   179 		}
   156 	CleanupStack::PopAndDestroy(&cfgFile);
   180 	CleanupStack::PopAndDestroy(&cfgFile);
   157 	if(err != KErrEof)
   181 	if(err != KErrEof)
   158 		{//The "read configuration file" operation has failed with "err" (if err != KErrNone)
   182 		{//The "read configuration file" operation has failed with "err" (if err != KErrNone)
   159 		__SQLLEAVE_IF_ERROR(err);	
   183 		__SQLLEAVE_IF_ERROR2(err);	
   160 		}
   184 		}
   161 	if(!cfgLineFound)
   185 	if(!cfgLineFound)
   162 		{//End of config file reached - no valid configuration line found.
   186 		{//End of config file reached - no valid configuration line found.
   163 		__SQLLEAVE(KErrEof);	
   187 		__SQLLEAVE2(KErrEof);	
   164 		}
   188 		}
   165 	__SQLASSERT(err == KErrNone || err == KErrEof, ESqlPanicInternalError);
   189 	__ASSERT_DEBUG(err == KErrNone || err == KErrEof, __SQLPANIC2(ESqlPanicInternalError));
   166 	aConfigStr.Copy(buf);
   190 	aConfigStr.Copy(buf);
   167 	}
   191 	}
   168 
   192 
   169 //Parses the config string parameter (aConfigStr) and stores the extracted configuration parameter values in the aConfigParams argument.
   193 //Parses the config string parameter (aConfigStr) and stores the extracted configuration parameter values in the aConfigParams argument.
   170 //The config string format is: "PARAM1=VALUE1;PARAM2=VALUE2;..."
   194 //The config string format is: "PARAM1=VALUE1;PARAM2=VALUE2;..."
   182 			{
   206 			{
   183 			TSqlSrvConfig::ExtractParamValueL(prmName, prmValue, aConfigParams);
   207 			TSqlSrvConfig::ExtractParamValueL(prmName, prmValue, aConfigParams);
   184 			}
   208 			}
   185 		}
   209 		}
   186 	//Assert the extracted parameter values.
   210 	//Assert the extracted parameter values.
   187 	__SQLASSERT(aConfigParams.iPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iPageSize >= 0, ESqlPanicInternalError);
   211 	__ASSERT_DEBUG(aConfigParams.iPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iPageSize >= 0, __SQLPANIC2(ESqlPanicInternalError));
   188 	__SQLASSERT(aConfigParams.iCacheSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iCacheSize >= 0, ESqlPanicInternalError);
   212 	__ASSERT_DEBUG(aConfigParams.iCacheSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iCacheSize >= 0, __SQLPANIC2(ESqlPanicInternalError));
   189 	__SQLASSERT(aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncNotSet || 
   213 	__ASSERT_DEBUG(aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncNotSet || 
   190 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf8 || 
   214 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf8 || 
   191 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf16, ESqlPanicInternalError);
   215 				aConfigParams.iDbEncoding == TSqlSrvConfigParams::EEncUtf16, __SQLPANIC2(ESqlPanicInternalError));
   192 	__SQLASSERT(aConfigParams.iSoftHeapLimitKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   216 	__ASSERT_DEBUG(aConfigParams.iSoftHeapLimitKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   193 	            (aConfigParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
   217 	            (aConfigParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
   194 	             aConfigParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb), ESqlPanicInternalError);
   218 	             aConfigParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb), __SQLPANIC2(ESqlPanicInternalError));
   195 	__SQLASSERT(aConfigParams.iCompactionMode == ESqlCompactionNotSet || aConfigParams.iCompactionMode == ESqlCompactionManual || 
   219 	__ASSERT_DEBUG(aConfigParams.iCompactionMode == ESqlCompactionNotSet || aConfigParams.iCompactionMode == ESqlCompactionManual || 
   196 				aConfigParams.iCompactionMode == ESqlCompactionBackground || aConfigParams.iCompactionMode == ESqlCompactionAuto, ESqlPanicInternalError);
   220 				aConfigParams.iCompactionMode == ESqlCompactionBackground || aConfigParams.iCompactionMode == ESqlCompactionAuto, __SQLPANIC2(ESqlPanicInternalError));
   197 	__SQLASSERT(aConfigParams.iFreePageThresholdKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   221 	__ASSERT_DEBUG(aConfigParams.iFreePageThresholdKb == TSqlSrvConfigParams::KConfigPrmValueNotSet || 
   198 			    aConfigParams.iFreePageThresholdKb >= 0, ESqlPanicInternalError);
   222 			    aConfigParams.iFreePageThresholdKb >= 0, __SQLPANIC2(ESqlPanicInternalError));
   199 	}
   223 	}
   200 
   224 
   201 //The function searches aConfigStr arguments for "PARAM=VALUE;" pair. If such pair is found, then 
   225 //The function searches aConfigStr arguments for "PARAM=VALUE;" pair. If such pair is found, then 
   202 //aParamName is set to point to the parameter name, aParamValue is set to point to the parameter value,
   226 //aParamName is set to point to the parameter name, aParamValue is set to point to the parameter value,
   203 //aConfigStr is set to point to the rest of the config string (skipping the just found "param=value;" pair).
   227 //aConfigStr is set to point to the rest of the config string (skipping the just found "param=value;" pair).
   235 		}
   259 		}
   236 	//Find the parameter name and parameter value
   260 	//Find the parameter name and parameter value
   237 	pos = prmText.Locate(KAssignment);
   261 	pos = prmText.Locate(KAssignment);
   238 	if(pos < 0 || pos >= (prmText.Length() - 1))
   262 	if(pos < 0 || pos >= (prmText.Length() - 1))
   239 		{
   263 		{
   240 		__SQLLEAVE(KErrArgument);
   264 		__SQLLEAVE2(KErrArgument);
   241 		}
   265 		}
   242 	//we've got now prmText pointing to a " PARAM = VALUE " string.
   266 	//we've got now prmText pointing to a " PARAM = VALUE " string.
   243 	aParamName.Set(TSqlSrvConfig::TrimAndConstructPtr(prmText.Ptr(), pos));
   267 	aParamName.Set(TSqlSrvConfig::TrimAndConstructPtr(prmText.Ptr(), pos));
   244 	aParamValue.Set(TSqlSrvConfig::TrimAndConstructPtr(prmText.Ptr() + pos + 1, prmText.Length() - (pos + 1)));
   268 	aParamValue.Set(TSqlSrvConfig::TrimAndConstructPtr(prmText.Ptr() + pos + 1, prmText.Length() - (pos + 1)));
   245 	return ETrue;
   269 	return ETrue;
   287 	TLex8 lex(aParamValue);
   311 	TLex8 lex(aParamValue);
   288 	TInt cacheSize = TSqlSrvConfigParams::KConfigPrmValueNotSet;
   312 	TInt cacheSize = TSqlSrvConfigParams::KConfigPrmValueNotSet;
   289 	TInt err = lex.Val(cacheSize);
   313 	TInt err = lex.Val(cacheSize);
   290 	if(err != KErrNone || cacheSize < 0) 	//The correct check is for "<=0", but it has to be backward 
   314 	if(err != KErrNone || cacheSize < 0) 	//The correct check is for "<=0", but it has to be backward 
   291 		{									//compatible with the previous implementation
   315 		{									//compatible with the previous implementation
   292 		__SQLLEAVE(KErrArgument);
   316 		__SQLLEAVE2(KErrArgument);
   293 		}
   317 		}
   294 	return cacheSize;
   318 	return cacheSize;
   295 	}
   319 	}
   296 
   320 
   297 //The function converts aParamValue to a numerical value (the page size in bytes) and returns it.
   321 //The function converts aParamValue to a numerical value (the page size in bytes) and returns it.
   301 	TLex8 lex(aParamValue);
   325 	TLex8 lex(aParamValue);
   302 	TInt pageSize = TSqlSrvConfigParams::KConfigPrmValueNotSet;
   326 	TInt pageSize = TSqlSrvConfigParams::KConfigPrmValueNotSet;
   303 	TInt err = lex.Val(pageSize);
   327 	TInt err = lex.Val(pageSize);
   304 	if(err != KErrNone || pageSize < 0) 	//The correct check is for "<0", "power of 2", "between 512 and 32768",
   328 	if(err != KErrNone || pageSize < 0) 	//The correct check is for "<0", "power of 2", "between 512 and 32768",
   305 		{									//but it has to be backward compatible with the previous implementation
   329 		{									//but it has to be backward compatible with the previous implementation
   306 		__SQLLEAVE(KErrArgument);
   330 		__SQLLEAVE2(KErrArgument);
   307 		}
   331 		}
   308 	return pageSize;
   332 	return pageSize;
   309 	}
   333 	}
   310 
   334 
   311 //The function converts aParamValue to a numerical value (the database encoding) and returns it.
   335 //The function converts aParamValue to a numerical value (the database encoding) and returns it.
   334 	TInt softHeapLimitKb = TSqlSrvConfigParams::KConfigPrmValueNotSet;
   358 	TInt softHeapLimitKb = TSqlSrvConfigParams::KConfigPrmValueNotSet;
   335 	TInt err = lex.Val(softHeapLimitKb);
   359 	TInt err = lex.Val(softHeapLimitKb);
   336 	if(err != KErrNone || softHeapLimitKb < 0 || 
   360 	if(err != KErrNone || softHeapLimitKb < 0 || 
   337 	   (softHeapLimitKb < TSqlSrvConfigParams::KMinSoftHeapLimitKb || softHeapLimitKb > TSqlSrvConfigParams::KMaxSoftHeapLimitKb))
   361 	   (softHeapLimitKb < TSqlSrvConfigParams::KMinSoftHeapLimitKb || softHeapLimitKb > TSqlSrvConfigParams::KMaxSoftHeapLimitKb))
   338 		{					
   362 		{					
   339 		__SQLLEAVE(KErrArgument);
   363 		__SQLLEAVE2(KErrArgument);
   340 		}
   364 		}
   341 	return softHeapLimitKb;
   365 	return softHeapLimitKb;
   342 	}
   366 	}
   343 	
   367 	
   344 //The function converts aParamValue to a numerical value (the database compaction mode) and returns it.
   368 //The function converts aParamValue to a numerical value (the database compaction mode) and returns it.
   370 	TLex8 lex(aParamValue);
   394 	TLex8 lex(aParamValue);
   371 	TInt freePageThreshold = 0;
   395 	TInt freePageThreshold = 0;
   372 	TInt err = lex.Val(freePageThreshold);
   396 	TInt err = lex.Val(freePageThreshold);
   373 	if(err != KErrNone || freePageThreshold < 0)
   397 	if(err != KErrNone || freePageThreshold < 0)
   374 		{					
   398 		{					
   375 		__SQLLEAVE(KErrArgument);
   399 		__SQLLEAVE2(KErrArgument);
   376 		}
   400 		}
   377 	return freePageThreshold;
   401 	return freePageThreshold;
   378 	}
   402 	}
   379 	
   403 	
   380 
   404 
   381 //The function searches aStr for leading and trailing whitespace 
   405 //The function searches aStr for leading and trailing whitespace 
   382 //characters, then creates and returns TPtrC object which points to the 
   406 //characters, then creates and returns TPtrC object which points to the 
   383 //aStr content without leading and trailing whitespace characters.
   407 //aStr content without leading and trailing whitespace characters.
   384 TPtrC8 TSqlSrvConfig::TrimAndConstructPtr(const TUint8* aStr, TInt aLength)
   408 TPtrC8 TSqlSrvConfig::TrimAndConstructPtr(const TUint8* aStr, TInt aLength)
   385 	{
   409 	{
   386 	__SQLASSERT(aStr != NULL, ESqlPanicBadArgument);
   410 	__ASSERT_DEBUG(aStr != NULL, __SQLPANIC2(ESqlPanicBadArgument));
   387 	__SQLASSERT(aLength >= 0, ESqlPanicBadArgument);
   411 	__ASSERT_DEBUG(aLength >= 0, __SQLPANIC2(ESqlPanicBadArgument));
   388 	//Trim left
   412 	//Trim left
   389 	for(;aLength>0;--aLength,++aStr)
   413 	for(;aLength>0;--aLength,++aStr)
   390 		{
   414 		{
   391 		if(!TChar(*aStr).IsSpace())
   415 		if(!TChar(*aStr).IsSpace())
   392 			{
   416 			{