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