persistentstorage/sql/SRC/Server/SqlSrvMain.cpp
changeset 41 3256212fc81f
parent 17 55f2396f6d25
child 51 7d4490026038
equal deleted inserted replaced
35:0d6db0a14001 41:3256212fc81f
    23 #include "sqlite3.h"			//sqlite3_enable_shared_cache()
    23 #include "sqlite3.h"			//sqlite3_enable_shared_cache()
    24 #include "SqliteSymbian.h"		//sqlite3SymbianLibInit()
    24 #include "SqliteSymbian.h"		//sqlite3SymbianLibInit()
    25 #include "SqlCompact.h"
    25 #include "SqlCompact.h"
    26 #include "SqlCompactConn.h"
    26 #include "SqlCompactConn.h"
    27 #include "SqlSrvResourceProfiler.h"
    27 #include "SqlSrvResourceProfiler.h"
    28 #include "UTraceSql.h"
       
    29 #ifdef _DEBUG
    28 #ifdef _DEBUG
    30 #include <stdio.h>
    29 #include <stdio.h>
    31 #endif
    30 #endif
       
    31 #include "OstTraceDefinitions.h"
       
    32 #ifdef OST_TRACE_COMPILER_IN_USE
       
    33 #include "SqlSrvMainTraces.h"
       
    34 #endif
       
    35 #include "SqlTraceDef.h"
    32 
    36 
    33 #ifndef SQLSRV_STARTUP_TEST
    37 #ifndef SQLSRV_STARTUP_TEST
    34 static  
    38 static  
    35 #endif
    39 #endif
    36 CSqlServer* TheServer = NULL;//The single CSqlServer instance
    40 CSqlServer* TheServer = NULL;//The single CSqlServer instance
    64 //
    68 //
    65 //The function will panic with panic code 7 in _DEBUG mode if the key part of aLeft or
    69 //The function will panic with panic code 7 in _DEBUG mode if the key part of aLeft or
    66 //aRight argument is NULL.
    70 //aRight argument is NULL.
    67 static TInt Compare(const TSqlSecurityPair& aLeft, const TSqlSecurityPair& aRight)
    71 static TInt Compare(const TSqlSecurityPair& aLeft, const TSqlSecurityPair& aRight)
    68 	{
    72 	{
    69 	__SQLASSERT(aLeft.iKey != NULL && aRight.iKey != NULL, ESqlPanicInternalError);
    73 	__ASSERT_DEBUG(aLeft.iKey != NULL && aRight.iKey != NULL, __SQLPANIC2(ESqlPanicInternalError));
    70 	return ::CompareNoCase8(TPtrC8(aLeft.iKey), TPtrC8(aRight.iKey));
    74 	return ::CompareNoCase8(TPtrC8(aLeft.iKey), TPtrC8(aRight.iKey));
    71 	}
    75 	}
    72 	
    76 	
    73 /**
    77 /**
    74 Returns a reference to the sql server instance.
    78 Returns a reference to the sql server instance.
    79 
    83 
    80 @internalComponent
    84 @internalComponent
    81 */
    85 */
    82 CSqlServer& SqlServer(void)
    86 CSqlServer& SqlServer(void)
    83 	{
    87 	{
    84 	__SQLASSERT_ALWAYS(TheServer != NULL, ESqlPanicInvalidObj);		
    88 	__ASSERT_ALWAYS(TheServer != NULL, __SQLPANIC2(ESqlPanicInvalidObj));		
    85 	return *TheServer;
    89 	return *TheServer;
    86 	}
    90 	}
    87 	
    91 	
    88 /**
    92 /**
    89 Creates new CSqlServer instance.
    93 Creates new CSqlServer instance.
    93 
    97 
    94 @leave KErrNoMemory, an out of memory condition has occured;
    98 @leave KErrNoMemory, an out of memory condition has occured;
    95 */
    99 */
    96 CSqlServer* CSqlServer::NewLC()
   100 CSqlServer* CSqlServer::NewLC()
    97 	{
   101 	{
       
   102 	SQL_TRACE_INTERNALS(OstTrace0(TRACE_INTERNALS, CSQLSERVER_NEWLC_ENTRY, "Entry;0;CSqlServer::NewLC"));
    98 	CSqlServer* self = new (ELeave) CSqlServer;
   103 	CSqlServer* self = new (ELeave) CSqlServer;
    99 	CleanupStack::PushL(self);
   104 	CleanupStack::PushL(self);
   100 	self->ConstructL();
   105 	self->ConstructL();
       
   106 	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_NEWLC_EXIT, "Exit;0x%X;CSqlServer::NewLC", (TUint)self));
   101 	return self;
   107 	return self;
   102 	}
   108 	}
   103 	
   109 	
   104 /**
   110 /**
   105 Frees owned by CSqlServer memory and other resources.
   111 Frees owned by CSqlServer memory and other resources.
   106 */
   112 */
   107 CSqlServer::~CSqlServer()
   113 CSqlServer::~CSqlServer()
   108 	{
   114 	{
       
   115 	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_CSQLSERVER2_ENTRY, "Entry;0x%x;CSqlServer::~CSqlServer", (TUint)this));
   109 	delete iCompactor;
   116 	delete iCompactor;
   110 	delete iBackupClient;
   117 	delete iBackupClient;
   111 	iDriveSpaceCol.ResetAndDestroy();
   118 	iDriveSpaceCol.ResetAndDestroy();
   112 	sqlite3_soft_heap_limit(0);//Set to 0 the soft heap limit
   119 	sqlite3_soft_heap_limit(0);//Set to 0 the soft heap limit
   113 	iSecurityMap.Close();
   120 	iSecurityMap.Close();
   115 	iFlatBuf.Close();
   122 	iFlatBuf.Close();
   116 	User::Free(iBuf);
   123 	User::Free(iBuf);
   117 	delete iDbConfigFiles;
   124 	delete iDbConfigFiles;
   118 	sqlite3SymbianLibFinalize();
   125 	sqlite3SymbianLibFinalize();
   119 	TheServer = NULL;
   126 	TheServer = NULL;
   120 	SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KSqlSrvClose));
   127 	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_CSQLSERVER2_EXIT, "Exit;0x%x;CSqlServer::~CSqlServer", (TUint)this));
   121     SQLPROFILER_SERVER_STOP();
       
   122 	}
   128 	}
   123 
   129 
   124 /**
   130 /**
   125 @param aMinLen Requested minimal byte size of the flat buffer
   131 @param aMinLen Requested minimal byte size of the flat buffer
   126 
   132 
   127 @return A reference to the server's general purpose flat bufer. The buffer cannot keep a state between calls.
   133 @return A reference to the server's general purpose flat bufer. The buffer cannot keep a state between calls.
   128 */
   134 */
   129 RSqlBufFlat& CSqlServer::GetFlatBufL(TInt aMinLen)
   135 RSqlBufFlat& CSqlServer::GetFlatBufL(TInt aMinLen)
   130 	{
   136 	{
   131 	__SQLASSERT(aMinLen >= 0, ESqlPanicBadArgument);
   137 	__ASSERT_DEBUG(aMinLen >= 0, __SQLPANIC(ESqlPanicBadArgument));
   132 	__SQLLEAVE_IF_ERROR(iFlatBuf.ReAlloc(aMinLen));
   138 	__SQLLEAVE_IF_ERROR(iFlatBuf.ReAlloc(aMinLen));
   133 	SQLPROFILER_REPORT_ALLOC(iFlatBuf.MaxSize());
   139 	SQLPROFILER_REPORT_ALLOC(iFlatBuf.MaxSize());
   134 	return iFlatBuf;
   140 	return iFlatBuf;
   135 	}
   141 	}
   136 
   142 
   142 
   148 
   143 @return TDes8 reference to the server's general purpose bufer. The buffer cannot keep a state between calls.
   149 @return TDes8 reference to the server's general purpose bufer. The buffer cannot keep a state between calls.
   144 */
   150 */
   145 TDes8& CSqlServer::GetBuf8L(TInt aMinLen)
   151 TDes8& CSqlServer::GetBuf8L(TInt aMinLen)
   146 	{
   152 	{
   147 	__SQLASSERT(aMinLen >= 0, ESqlPanicBadArgument);
   153 	__ASSERT_DEBUG(aMinLen >= 0, __SQLPANIC(ESqlPanicBadArgument));
   148 #ifdef _DEBUG
   154 #ifdef _DEBUG
   149 TInt maxBufLen = iBufPtr8.MaxLength();
   155 	TInt maxBufLen = iBufPtr8.MaxLength();
   150 maxBufLen = maxBufLen;
   156 	maxBufLen = maxBufLen;
   151 #endif
   157 #endif
   152 	if(iBufPtr8.MaxLength() < aMinLen)
   158 	if(iBufPtr8.MaxLength() < aMinLen)
   153 		{
   159 		{
   154 		__SQLLEAVE_IF_ERROR(ReAllocBuf(aMinLen));
   160 		__SQLLEAVE_IF_ERROR(ReAllocBuf(aMinLen));
   155 		}
   161 		}
   165 
   171 
   166 @return TDes16 reference to the server's general purpose bufer. The buffer cannot keep a state between calls.
   172 @return TDes16 reference to the server's general purpose bufer. The buffer cannot keep a state between calls.
   167 */
   173 */
   168 TDes16& CSqlServer::GetBuf16L(TInt aMinLen)
   174 TDes16& CSqlServer::GetBuf16L(TInt aMinLen)
   169 	{
   175 	{
   170 	__SQLASSERT(aMinLen >= 0, ESqlPanicBadArgument);
   176 	__ASSERT_DEBUG(aMinLen >= 0, __SQLPANIC(ESqlPanicBadArgument));
   171 #ifdef _DEBUG
   177 #ifdef _DEBUG
   172 TInt maxBufLen = iBufPtr16.MaxLength();
   178 	TInt maxBufLen = iBufPtr16.MaxLength();
   173 maxBufLen = maxBufLen;
   179 	maxBufLen = maxBufLen;
   174 #endif
   180 #endif
   175 	if(iBufPtr16.MaxLength() < aMinLen)
   181 	if(iBufPtr16.MaxLength() < aMinLen)
   176 		{
   182 		{
   177 		__SQLLEAVE_IF_ERROR(ReAllocBuf(aMinLen * sizeof(TUint16)));
   183 		__SQLLEAVE_IF_ERROR(ReAllocBuf(aMinLen * sizeof(TUint16)));
   178 		}
   184 		}
   194 	const TInt KBufLimit = 8 * 1024;
   200 	const TInt KBufLimit = 8 * 1024;
   195 #endif
   201 #endif
   196 	if(iBufPtr8.MaxSize() > KBufLimit)
   202 	if(iBufPtr8.MaxSize() > KBufLimit)
   197 		{
   203 		{
   198 		(void)ReAllocBuf(KBufLimit);
   204 		(void)ReAllocBuf(KBufLimit);
   199 		__SQLASSERT(oldBuf == iBuf, ESqlPanicInternalError);
   205 		__ASSERT_DEBUG(oldBuf == iBuf, __SQLPANIC(ESqlPanicInternalError));
   200 		}
   206 		}
   201 	}
   207 	}
   202 
   208 
   203 /**
   209 /**
   204 Reallocates iBuf. iBuf content is not preserved.
   210 Reallocates iBuf. iBuf content is not preserved.
   209 @return KErrNoMemory, an out of memory condition has occurred;
   215 @return KErrNoMemory, an out of memory condition has occurred;
   210 		KErrNone, the operation has completed successfully;
   216 		KErrNone, the operation has completed successfully;
   211 */
   217 */
   212 TInt CSqlServer::ReAllocBuf(TInt aNewBufSize)
   218 TInt CSqlServer::ReAllocBuf(TInt aNewBufSize)
   213 	{
   219 	{
   214 	__SQLASSERT(aNewBufSize >= 0, ESqlPanicBadArgument);
   220 	__ASSERT_DEBUG(aNewBufSize >= 0, __SQLPANIC(ESqlPanicBadArgument));
   215 #ifdef _DEBUG	
   221 #ifdef _DEBUG	
   216 	const TInt KMinBufSize = 8;
   222 	const TInt KMinBufSize = 8;
   217 #else
   223 #else
   218 	const TInt KMinBufSize = 2 * 1024;
   224 	const TInt KMinBufSize = 2 * 1024;
   219 #endif
   225 #endif
   299 	//the SQL server startup code.
   305 	//the SQL server startup code.
   300 	StartL(KSqlSrvName);
   306 	StartL(KSqlSrvName);
   301 #endif	
   307 #endif	
   302     SQLPROFILER_SERVER_START();
   308     SQLPROFILER_SERVER_START();
   303 	//Configure the SQLite library
   309 	//Configure the SQLite library
   304 	__SQLLEAVE_IF_ERROR(sqlite3_config(SQLITE_CONFIG_LOOKASIDE, KSqliteLookAsideCellSize, KSqliteLookAsideCellCount));
   310 	TInt sqliteErr = sqlite3_config(SQLITE_CONFIG_LOOKASIDE, KSqliteLookAsideCellSize, KSqliteLookAsideCellCount);
       
   311     __SQLLEAVE_IF_ERROR(::Sql2OsErrCode(sqliteErr, KErrArgument));
   305 	//Open SQLITE library - this must be the first call after StartL() (os_symbian.cpp, "TheAllocator" initialization rellated).
   312 	//Open SQLITE library - this must be the first call after StartL() (os_symbian.cpp, "TheAllocator" initialization rellated).
   306 	__SQLLEAVE_IF_ERROR(sqlite3SymbianLibInit());
   313 	__SQLLEAVE_IF_ERROR(sqlite3SymbianLibInit());
   307 	//Create buffers
   314 	//Create buffers
   308 	__SQLLEAVE_IF_ERROR(iFlatBuf.SetCount(0));
   315 	__SQLLEAVE_IF_ERROR(iFlatBuf.SetCount(0));
   309 	//Get collation dll name
   316 	//Get collation dll name
   312 	TInt sysDrive = static_cast<TInt>(RFs::GetSystemDrive());
   319 	TInt sysDrive = static_cast<TInt>(RFs::GetSystemDrive());
   313 	//Get the server private data path.
   320 	//Get the server private data path.
   314 	RFs& fs = sqlite3SymbianFs();
   321 	RFs& fs = sqlite3SymbianFs();
   315 	TFileName serverPrivatePath;
   322 	TFileName serverPrivatePath;
   316 	__SQLLEAVE_IF_ERROR(fs.PrivatePath(serverPrivatePath));
   323 	__SQLLEAVE_IF_ERROR(fs.PrivatePath(serverPrivatePath));
       
   324 	DeleteTempFilesL(sysDrive, serverPrivatePath);
   317 	//Load config file parameter values (if config file exists) and initialize iFileData.
   325 	//Load config file parameter values (if config file exists) and initialize iFileData.
   318 	TParse parse;
   326 	TParse parse;
   319 	__SQLLEAVE_IF_ERROR(parse.Set(KSqlSrvDefaultConfigFile, &serverPrivatePath, NULL));
   327 	__SQLLEAVE_IF_ERROR(parse.Set(KSqlSrvDefaultConfigFile, &serverPrivatePath, NULL));
   320 	//Store the names of any existing database config files in memory
   328 	//Store the names of any existing database config files in memory
   321 	CacheDbConfigFileNamesL(fs, serverPrivatePath);
   329 	CacheDbConfigFileNamesL(fs, serverPrivatePath);
   324 		
   332 		
   325 	//Set the soft heap limit (iFileData.ConfigParams() returns now a reference to the config file params, including the soft heap limit, if set)
   333 	//Set the soft heap limit (iFileData.ConfigParams() returns now a reference to the config file params, including the soft heap limit, if set)
   326 	const TSqlSrvConfigParams& configParams = iFileData.ConfigParams();
   334 	const TSqlSrvConfigParams& configParams = iFileData.ConfigParams();
   327 	if(configParams.iSoftHeapLimitKb > 0)
   335 	if(configParams.iSoftHeapLimitKb > 0)
   328 		{
   336 		{
   329 		__SQLASSERT(configParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
   337 		__ASSERT_DEBUG(configParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
   330 		            configParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb, ESqlPanicInternalError);
   338 		            configParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb, __SQLPANIC(ESqlPanicInternalError));
   331 		sqlite3_soft_heap_limit(configParams.iSoftHeapLimitKb * 1024);
   339 		sqlite3_soft_heap_limit(configParams.iSoftHeapLimitKb * 1024);
   332 		}
   340 		}
   333 	//Enable shared cache
   341 	//Enable shared cache
   334 	(void)sqlite3SymbianLastOsError();//clear last OS error
   342 	(void)sqlite3SymbianLastOsError();//clear last OS error
   335 	TInt err = sqlite3_enable_shared_cache(static_cast <TInt> (EEnableSharedCache));
   343 	TInt err = sqlite3_enable_shared_cache(static_cast <TInt> (EEnableSharedCache));
   360     #endif //SQLSRV_STARTUP_TEST 	
   368     #endif //SQLSRV_STARTUP_TEST 	
   361 #endif //_DEBUG 	
   369 #endif //_DEBUG 	
   362 	}
   370 	}
   363 
   371 
   364 /**
   372 /**
       
   373 Delete any temp files left the "temp" subdirectory in server's private directory.
       
   374 
       
   375 The SQLite is configured to use shared page cache. When the shared page cache is enabled,
       
   376 those temp files created by SQLite are deleted only when the database gets closed. However,
       
   377 if during power down event the client application does not close the database, 
       
   378 the temp files will never get deleted.
       
   379 This is why the SQL server should deletes all temp files during its start-up.
       
   380 
       
   381 Note that all errors exept KErrNoMemory are ignored in the function body, becasuse
       
   382 the temp files deletion is not a critical operation to prevent the server start up.
       
   383 
       
   384 @param aDriveNumber A drive number.
       
   385 @param aServerPath A server's private path.
       
   386 
       
   387 */
       
   388 void CSqlServer::DeleteTempFilesL(TInt aDriveNumber, const TDesC& aServerPath)const
       
   389     {
       
   390     _LIT(KTempFileDir, "temp");
       
   391     _LIT(KWildCard, "*.*");
       
   392     TDriveUnit drive(aDriveNumber); 
       
   393     TDriveName driveName = drive.Name();
       
   394     TParse parse;
       
   395     (void)parse.Set(aServerPath, &driveName, 0);//this call can't fail
       
   396     (void)parse.AddDir(KTempFileDir);//this call can't fail
       
   397     TFileName tempfileDir(parse.FullName());
       
   398     (void)parse.Set(KWildCard, &tempfileDir, 0);//this call can't fail
       
   399 	RFs& fs = sqlite3SymbianFs();
       
   400 	CFileMan* fm = CFileMan::NewL(fs);
       
   401 	(void)fm->Delete(parse.FullName());
       
   402 	delete fm;
       
   403     }
       
   404 
       
   405 /**
   365 Retrieves in iCollationDllName current(default) collation dll name.
   406 Retrieves in iCollationDllName current(default) collation dll name.
   366 see TExtendedLocale
   407 see TExtendedLocale
   367 */
   408 */
   368 void CSqlServer::GetCollationDllNameL()
   409 void CSqlServer::GetCollationDllNameL()
   369 	{
   410 	{
   378 		{
   419 		{
   379 		//only get the file name + extension 
   420 		//only get the file name + extension 
   380 		fileName.Set(fname, NULL, NULL);
   421 		fileName.Set(fname, NULL, NULL);
   381 		iCollationDllName = fileName.NameAndExt();
   422 		iCollationDllName = fileName.NameAndExt();
   382 		}
   423 		}
       
   424 	SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSERVER_GETCOLLATIONDLLNAMEL, "0x%x;CSqlServer::GetCollationDllNameL;iCollationDllName=%S;err=%d", (TUint)this, __SQLPRNSTR(iCollationDllName), err));
   383 	}
   425 	}
   384 /**
   426 /**
   385 Finds and caches the name of each database configuration file 
   427 Finds and caches the name of each database configuration file 
   386 that exists in the server's private data cage on the Z: drive
   428 that exists in the server's private data cage on the Z: drive
   387 */
   429 */
   401 			iDbConfigFiles = CDbConfigFiles::NewL(*entryList);
   443 			iDbConfigFiles = CDbConfigFiles::NewL(*entryList);
   402 			}
   444 			}
   403 		}
   445 		}
   404 	else
   446 	else
   405 		{
   447 		{
   406 		__SQLLOG_ERR(_L("SQLLOG: CSqlServer::CacheDbConfigFileNamesL() - GetDir() failed with error code %d"), err);	
   448 		SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_CACHEDDBCONFIGFILENAMESL, "0x%X;CSqlServer::CacheDbConfigFileNamesL;GetDir() failed with error code %d", (TUint)this, err));	
   407 		}
   449 		}
   408 	CleanupStack::PopAndDestroy(); // entryList	
   450 	CleanupStack::PopAndDestroy(); // entryList	
   409 	}
   451 	}
   410 
   452 
   411 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   453 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   457 					 Note that the function may leave also with some other database specific or OS specific
   499 					 Note that the function may leave also with some other database specific or OS specific
   458 					 error codes.
   500 					 error codes.
   459 */
   501 */
   460 void CSqlServer::GetBackUpListL(TSecureId aUid, RArray<TParse>& aFileList)
   502 void CSqlServer::GetBackUpListL(TSecureId aUid, RArray<TParse>& aFileList)
   461 	{
   503 	{
       
   504 	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_ENTRY, "Entry;0x%x;CSqlServer::GetBackUpListL;aUid=0x%X", (TUint)this, (TUint)aUid.iId));
   462 	aFileList.Reset();
   505 	aFileList.Reset();
   463 	TFindFile findFile(iFileData.Fs());
   506 	TFindFile findFile(iFileData.Fs());
   464 	CDir* fileNameCol = NULL;
   507 	CDir* fileNameCol = NULL;
   465 	TUidName uidName = (static_cast <TUid> (aUid)).Name();
   508 	TUidName uidName = (static_cast <TUid> (aUid)).Name();
   466 	TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName);
   509 	TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName);
   470 	if(err == KErrNone)
   513 	if(err == KErrNone)
   471 		{
   514 		{
   472 		//The first set of files, which name is matching "[aUid]*" pattern, is ready.
   515 		//The first set of files, which name is matching "[aUid]*" pattern, is ready.
   473 		do
   516 		do
   474 			{
   517 			{
   475 			__SQLASSERT(fileNameCol != NULL, ESqlPanicInternalError);
   518 			__ASSERT_DEBUG(fileNameCol != NULL, __SQLPANIC(ESqlPanicInternalError));
   476 			CleanupStack::PushL(fileNameCol);
   519 			CleanupStack::PushL(fileNameCol);
   477 			const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
   520 			const TDesC& file = findFile.File();//"file" variable contains the drive and the path. the file name in "file" is invalid in this case.
   478 			//Check that the drive, where the database files are, is not ROM drive
   521 			//Check that the drive, where the database files are, is not ROM drive
   479 			TParse parse;
   522 			TParse parse;
   480 			(void)parse.Set(file, NULL, NULL);//this call can't file, the file name comes from findFile call.
   523 			(void)parse.Set(file, NULL, NULL);//this call can't file, the file name comes from findFile call.
   481 			TPtrC driveName = parse.Drive();
   524 			TPtrC driveName = parse.Drive();
   482 			__SQLASSERT(driveName.Length() > 0, ESqlPanicInternalError);
   525 			__ASSERT_DEBUG(driveName.Length() > 0, __SQLPANIC(ESqlPanicInternalError));
   483 			TInt driveNumber = -1;
   526 			TInt driveNumber = -1;
   484 			__SQLLEAVE_IF_ERROR(RFs::CharToDrive(driveName[0], driveNumber));
   527 			__SQLLEAVE_IF_ERROR(RFs::CharToDrive(driveName[0], driveNumber));
   485 			TDriveInfo driveInfo;
   528 			TDriveInfo driveInfo;
   486 			__SQLLEAVE_IF_ERROR(iFileData.Fs().Drive(driveInfo, static_cast <TDriveNumber> (driveNumber)));
   529 			__SQLLEAVE_IF_ERROR(iFileData.Fs().Drive(driveInfo, static_cast <TDriveNumber> (driveNumber)));
   487 			//If current drive is not ROM drive then process the files
   530 			//If current drive is not ROM drive then process the files
   493 					{
   536 					{
   494 					const ::TEntry& entry = (*fileNameCol)[i];
   537 					const ::TEntry& entry = (*fileNameCol)[i];
   495 					if(!entry.IsDir())
   538 					if(!entry.IsDir())
   496 						{
   539 						{
   497 						(void)parse.Set(entry.iName, &file, NULL);//"parse" variable now contains the full file path
   540 						(void)parse.Set(entry.iName, &file, NULL);//"parse" variable now contains the full file path
       
   541 						__SQLTRACE_INTERNALSVAR(TPtrC fname = parse.FullName());
       
   542 						SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL, "0x%x;CSqlServer::GetBackUpListL;fname=%S", (TUint)this, __SQLPRNSTR(fname)));
   498 						__SQLLEAVE_IF_ERROR(aFileList.Append(parse));
   543 						__SQLLEAVE_IF_ERROR(aFileList.Append(parse));
   499 						}
   544 						}
   500 					}
   545 					}
   501 				}
   546 				}
   502 			CleanupStack::PopAndDestroy(fileNameCol);
   547 			CleanupStack::PopAndDestroy(fileNameCol);
   503 			fileNameCol = NULL;
   548 			fileNameCol = NULL;
   504 			} while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files
   549 			} while((err = findFile.FindWild(fileNameCol)) == KErrNone);//Get the next set of files
   505 		}//end of "if(err == KErrNone)"
   550 		}//end of "if(err == KErrNone)"
   506 	__SQLASSERT(!fileNameCol, ESqlPanicInternalError);
   551 	__ASSERT_DEBUG(!fileNameCol, __SQLPANIC(ESqlPanicInternalError));
   507 	if(err != KErrNotFound && err != KErrNone)
   552 	if(err != KErrNotFound && err != KErrNone)
   508 		{
   553 		{
   509 		__SQLLEAVE(err);
   554 		__SQLLEAVE(err);
   510 		}
   555 		}
       
   556 	SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_EXIT, "Exit;0x%x;CSqlServer::GetBackUpListL;file count=%d;err=%d", (TUint)this, aFileList.Count(), err));
   511 	}
   557 	}
   512 
   558 
   513 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   559 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   514 ////////////////////////////////////////   SQL server startup   //////////////////////////////////////////////
   560 ////////////////////////////////////////   SQL server startup   //////////////////////////////////////////////
   515 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   561 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
   524 
   570 
   525 	// create and install the active scheduler we need
   571 	// create and install the active scheduler we need
   526 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
   572 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
   527 	CleanupStack::PushL(scheduler);
   573 	CleanupStack::PushL(scheduler);
   528 	CActiveScheduler::Install(scheduler);
   574 	CActiveScheduler::Install(scheduler);
   529 	SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EInternals), KSqlSrvStart));
       
   530 	TheServer = CSqlServer::NewLC();
   575 	TheServer = CSqlServer::NewLC();
   531 	RProcess::Rendezvous(KErrNone);
   576 	RProcess::Rendezvous(KErrNone);
   532 	CActiveScheduler::Start();
   577 	CActiveScheduler::Start();
   533 
   578 
   534 	CleanupStack::PopAndDestroy(2, scheduler);//CSqlServer, scheduler
   579 	CleanupStack::PopAndDestroy(2, scheduler);//CSqlServer, scheduler