Update contrib.
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "SqlSrvMain.h" //CSqlServer
18 #include "SqlSrvStartup.h" //SqlSrvVersion()
19 #include "SqlSrvSession.h" //CSqlSrvSession
20 #include "SqlSrvDbSysSettings.h"//TSqlDbSysSettings
21 #include "SqlSrvStatementUtil.h"
22 #include "SqlSrvStatement.h"
23 #include "sqlite3.h" //sqlite3_enable_shared_cache()
24 #include "SqliteSymbian.h" //sqlite3SymbianLibInit()
25 #include "SqlCompact.h"
26 #include "SqlCompactConn.h"
27 #include "SqlSrvResourceProfiler.h"
31 #include "OstTraceDefinitions.h"
32 #ifdef OST_TRACE_COMPILER_IN_USE
33 #include "SqlSrvMainTraces.h"
35 #include "SqlTraceDef.h"
37 #ifndef SQLSRV_STARTUP_TEST
40 CSqlServer* TheServer = NULL;//The single CSqlServer instance
43 #define __SQLDEBUG_EXPR(expr) expr
45 #define __SQLDEBUG_EXPR(expr)
48 _LIT(KMatchAllDbFiles, "*");
49 _LIT(KDefaultICollationDllName, "");
51 //Constants for enabling/disabling the shared cache
52 enum TSharedCacheState
54 EDisableSharedCache = 0,
55 EEnableSharedCache = 1
59 //The "lookaside" optimisation is disabled if SYSLIBS_TEST macro is defined.
60 //According to the SQLite authors recommendations, the OOM testing should be performed without this optimisation.
61 const TInt KSqliteLookAsideCellSize = 0;
62 const TInt KSqliteLookAsideCellCount = 0;
64 //SQLite, "fixed heap cell size" constants
65 //SQLite will preallocate KSqliteLookAsideCellSize * KSqliteLookAsideCellCount bytes from the heap and
66 //use the allocated block for all allocation requests with size <= KSqliteLookAsideCellSize.
67 //The malloc()/free() request time is constant, if the cell is retrieved/returned from/to the "fixed cell size" block.
68 const TInt KSqliteLookAsideCellSize = 128;
69 const TInt KSqliteLookAsideCellCount = 512;
72 //Local function, used for comparing TSqlSecurityPair objects.
73 //The keys are expected to be UTF8 encoded, zero-terminated.
75 //The function will panic with panic code 7 in _DEBUG mode if the key part of aLeft or
76 //aRight argument is NULL.
77 static TInt Compare(const TSqlSecurityPair& aLeft, const TSqlSecurityPair& aRight)
79 __ASSERT_DEBUG(aLeft.iKey != NULL && aRight.iKey != NULL, __SQLPANIC2(ESqlPanicInternalError));
80 return ::CompareNoCase8(TPtrC8(aLeft.iKey), TPtrC8(aRight.iKey));
84 Returns a reference to the sql server instance.
86 @return A reference to the sql server instance.
88 @panic SqlDb 2 If the sql server instance is NULL.
92 CSqlServer& SqlServer(void)
94 __ASSERT_ALWAYS(TheServer != NULL, __SQLPANIC2(ESqlPanicInvalidObj));
99 Creates new CSqlServer instance.
100 The created instance will be pushed in the cleanup stack.
102 @return A pointer to the created CSqlServer instance.
104 @leave KErrNoMemory, an out of memory condition has occured;
106 CSqlServer* CSqlServer::NewLC()
108 SQL_TRACE_INTERNALS(OstTrace0(TRACE_INTERNALS, CSQLSERVER_NEWLC_ENTRY, "Entry;0;CSqlServer::NewLC"));
109 CSqlServer* self = new (ELeave) CSqlServer;
110 CleanupStack::PushL(self);
112 SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_NEWLC_EXIT, "Exit;0x%X;CSqlServer::NewLC", (TUint)self));
117 Frees owned by CSqlServer memory and other resources.
119 CSqlServer::~CSqlServer()
121 SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_CSQLSERVER2_ENTRY, "Entry;0x%x;CSqlServer::~CSqlServer", (TUint)this));
123 delete iBurEventMonitor;
124 iDriveSpaceCol.ResetAndDestroy();
125 sqlite3_soft_heap_limit(0);//Set to 0 the soft heap limit
126 iSecurityMap.Close();
127 (void)sqlite3_enable_shared_cache(static_cast <TInt> (EDisableSharedCache));
130 delete iDbConfigFiles;
131 sqlite3SymbianLibFinalize();
133 SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_CSQLSERVER2_EXIT, "Exit;0x%x;CSqlServer::~CSqlServer", (TUint)this));
137 @param aMinLen Requested minimal byte size of the flat buffer
139 @return A reference to the server's general purpose flat bufer. The buffer cannot keep a state between calls.
141 RSqlBufFlat& CSqlServer::GetFlatBufL(TInt aMinLen)
143 __ASSERT_DEBUG(aMinLen >= 0, __SQLPANIC(ESqlPanicBadArgument));
144 __SQLLEAVE_IF_ERROR(iFlatBuf.ReAlloc(aMinLen));
145 SQLPROFILER_REPORT_ALLOC(iFlatBuf.MaxSize());
150 Returns a 8-bit descriptor's reference to the server's general purpose buffer.
151 Note that the function may reallocate the buffer if the buffer length is smaller than the requested minimal length.
153 @param aMinLen Requested minimal 8-bit character length of the buffer
155 @return TDes8 reference to the server's general purpose bufer. The buffer cannot keep a state between calls.
157 TDes8& CSqlServer::GetBuf8L(TInt aMinLen)
159 __ASSERT_DEBUG(aMinLen >= 0, __SQLPANIC(ESqlPanicBadArgument));
161 TInt maxBufLen = iBufPtr8.MaxLength();
162 maxBufLen = maxBufLen;
164 if(iBufPtr8.MaxLength() < aMinLen)
166 __SQLLEAVE_IF_ERROR(ReAllocBuf(aMinLen));
168 SQLPROFILER_REPORT_ALLOC(iBufPtr8.MaxLength());
173 Returns a 16-bit descriptor's reference to the server's general purpose buffer.
174 Note that the function may reallocate the buffer if the buffer length is smaller than the requested minimal length.
176 @param aMinLen Requested minimal 16-bit character length of the buffer
178 @return TDes16 reference to the server's general purpose bufer. The buffer cannot keep a state between calls.
180 TDes16& CSqlServer::GetBuf16L(TInt aMinLen)
182 __ASSERT_DEBUG(aMinLen >= 0, __SQLPANIC(ESqlPanicBadArgument));
184 TInt maxBufLen = iBufPtr16.MaxLength();
185 maxBufLen = maxBufLen;
187 if(iBufPtr16.MaxLength() < aMinLen)
189 __SQLLEAVE_IF_ERROR(ReAllocBuf(aMinLen * sizeof(TUint16)));
191 SQLPROFILER_REPORT_ALLOC(iBufPtr16.MaxLength());
196 If iFlatBuf or iBuf allocated memory is more than KBufLimit bytes,
197 then that buffer will be reallocated down to KBufLimit size.
199 void CSqlServer::MinimizeBuffers()
201 iFlatBuf.ResetAndMinimize();
203 const TInt KBufLimit = 64;
204 const TUint8* oldBuf = iBuf;
206 const TInt KBufLimit = 8 * 1024;
208 if(iBufPtr8.MaxSize() > KBufLimit)
210 (void)ReAllocBuf(KBufLimit);
211 __ASSERT_DEBUG(oldBuf == iBuf, __SQLPANIC(ESqlPanicInternalError));
216 Reallocates iBuf. iBuf content is not preserved.
217 Sets iBufPtr8 and iBufPtr16 to point to iBuf.
219 @param aNewBufSize The new buffer size in bytes
221 @return KErrNoMemory, an out of memory condition has occurred;
222 KErrNone, the operation has completed successfully;
224 TInt CSqlServer::ReAllocBuf(TInt aNewBufSize)
226 __ASSERT_DEBUG(aNewBufSize >= 0, __SQLPANIC(ESqlPanicBadArgument));
228 const TInt KMinBufSize = 8;
230 const TInt KMinBufSize = 2 * 1024;
232 const TInt KNewBufSize = Max(aNewBufSize, KMinBufSize);
233 TUint8* newBuf = static_cast <TUint8*> (User::ReAlloc(iBuf, KNewBufSize));
237 iBufPtr8.Set(iBuf, 0, KNewBufSize);
238 iBufPtr16.Set(reinterpret_cast <TUint16*> (iBuf), 0, (TUint)KNewBufSize / sizeof(TUint16));
242 {//The reallocation has failed, iBuf - not changed
250 Creates new CSqlSrvSession instance.
251 If SQLSRV_STARTUP_TEST macro is defined, then the function returns NULL.
252 The "real" implementation of the function is not used in this case because the used unit test will require
253 a lot of cpp files to be included into the test build (t_sqlstartup).
255 @return A pointer to the created CSqlSrvSession instance.
257 @leave KErrNoMemory, an out of memory condition has occured;
258 KErrNotSupported, the client side library version differs from the server version.
262 CSession2* CSqlServer::NewSessionL(const TVersion& aVersion, const RMessage2&) const
264 #ifdef SQLSRV_STARTUP_TEST
265 aVersion.Name();//to prevent the compiler warning ("unused parameter").
268 if(!User::QueryVersionSupported(::SqlSrvVersion(), aVersion))
270 User::Leave(KErrNotSupported);
272 CSqlSrvSession* sess = CSqlSrvSession::NewL();
274 #endif //SQLSRV_STARTUP_TEST
278 CSqlServer's active object priority.
282 const TInt KSqlServerPriority = CActive::EPriorityStandard;
285 Initializes CSqlServer data members with default values.
287 CSqlServer::CSqlServer() :
288 CServer2(KSqlServerPriority, ESharableSessions),
289 iSecurityMap(TSqlSecurityLinearOrder(&Compare), TSqlSecurityDestructor()),
296 Initializes CSqlServer instance:
298 - opens sqlite library;
299 - initializes the file session instance;
300 - creates server's private directory on the system drive;
301 - enables sqlite shared cache;
303 @leave KErrNoMemory, an out of memory condition has occured;
304 Note that the function may also leave with some other database specific
305 errors categorised as ESqlDbError.
307 void CSqlServer::ConstructL()
309 #ifndef SQLSRV_STARTUP_TEST
310 //Start the server only in "normal" builds, not in the case where t_sqlstartup unit test tests directly
311 //the SQL server startup code.
314 SQLPROFILER_SERVER_START();
315 //Configure the SQLite library
316 TInt sqliteErr = sqlite3_config(SQLITE_CONFIG_LOOKASIDE, KSqliteLookAsideCellSize, KSqliteLookAsideCellCount);
317 __SQLLEAVE_IF_ERROR(::Sql2OsErrCode(sqliteErr, KErrArgument));
318 //Open SQLITE library - this must be the first call after StartL() (os_symbian.cpp, "TheAllocator" initialization rellated).
319 __SQLLEAVE_IF_ERROR(sqlite3SymbianLibInit());
321 __SQLLEAVE_IF_ERROR(iFlatBuf.SetCount(0));
322 //Get collation dll name
323 GetCollationDllNameL();
324 //Get the system drive.
325 TInt sysDrive = static_cast<TInt>(RFs::GetSystemDrive());
326 //Get the server private data path.
327 RFs& fs = sqlite3SymbianFs();
328 TFileName serverPrivatePath;
329 __SQLLEAVE_IF_ERROR(fs.PrivatePath(serverPrivatePath));
330 DeleteTempFilesL(sysDrive, serverPrivatePath);
331 //Load config file parameter values (if config file exists) and initialize iFileData.
333 __SQLLEAVE_IF_ERROR(parse.Set(KSqlSrvDefaultConfigFile, &serverPrivatePath, NULL));
334 //Store the names of any existing database config files in memory
335 CacheDbConfigFileNamesL(fs, serverPrivatePath);
336 //Initialise the file data object
337 iFileData.InitL(fs, TDriveUnit(sysDrive).Name(), serverPrivatePath, parse.FullName(), iDbConfigFiles);
339 //Set the soft heap limit (iFileData.ConfigParams() returns now a reference to the config file params, including the soft heap limit, if set)
340 const TSqlSrvConfigParams& configParams = iFileData.ConfigParams();
341 if(configParams.iSoftHeapLimitKb > 0)
343 __ASSERT_DEBUG(configParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb &&
344 configParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb, __SQLPANIC(ESqlPanicInternalError));
345 sqlite3_soft_heap_limit(configParams.iSoftHeapLimitKb * 1024);
347 //Enable shared cache
348 (void)sqlite3SymbianLastOsError();//clear last OS error
349 TInt err = sqlite3_enable_shared_cache(static_cast <TInt> (EEnableSharedCache));
350 __SQLLEAVE_IF_ERROR(::Sql2OsErrCode(err, sqlite3SymbianLastOsError()));
351 //Create an empty "drive space" collection
352 iDriveSpaceCol.Create(fs);
353 // Create the BUR instance
354 iBurEventMonitor = CSqlBurEventMonitor::NewL(*this);
356 iCompactor = CSqlCompactor::NewL(&SqlCreateCompactConnL, KSqlCompactStepIntervalMs);
358 //The following statements exist to prevent the failure of the OOM testing in debug mode.
359 //The standard C library allocates some memory at the startup and stores a pointer to the allocated memory
360 //in the TLS. During normal API OOM testing the SQL server is not restarted, it never goes down.
361 //Then the TLS and the allocated memory are not released. In which case the OOM testing will fail
362 //(because the standard C library performs a lazy initialization and the allocation and TLS usage will be made
363 //at the point of first use of some C function. This is out of the control of the test code).
364 //In order to avoid that, during the SQL server startup here, before the OOM test goes and checks what
365 //is the allocated memory at the beginning, a fake sprintf() call is made in order to force the mentioned above
366 //allocation in the standard C library.
367 //All explanations above are true, except one case when the SQl server startup code is tested directly.
368 #ifndef SQLSRV_STARTUP_TEST
369 const TInt KAnyNumber = 0xAA55;
371 sprintf(tmp, "%04X", KAnyNumber);
372 const TInt KGreatSize = 1024;
373 __SQLLEAVE_IF_ERROR(ReAllocBuf(KGreatSize));
374 #endif //SQLSRV_STARTUP_TEST
379 Delete any temp files left the "temp" subdirectory in server's private directory.
381 The SQLite is configured to use shared page cache. When the shared page cache is enabled,
382 those temp files created by SQLite are deleted only when the database gets closed. However,
383 if during power down event the client application does not close the database,
384 the temp files will never get deleted.
385 This is why the SQL server should deletes all temp files during its start-up.
387 Note that all errors exept KErrNoMemory are ignored in the function body, becasuse
388 the temp files deletion is not a critical operation to prevent the server start up.
390 @param aDriveNumber A drive number.
391 @param aServerPath A server's private path.
394 void CSqlServer::DeleteTempFilesL(TInt aDriveNumber, const TDesC& aServerPath)const
396 _LIT(KTempFileDir, "temp");
397 _LIT(KWildCard, "*.*");
398 TDriveUnit drive(aDriveNumber);
399 TDriveName driveName = drive.Name();
401 (void)parse.Set(aServerPath, &driveName, 0);//this call can't fail
402 (void)parse.AddDir(KTempFileDir);//this call can't fail
403 TFileName tempfileDir(parse.FullName());
404 (void)parse.Set(KWildCard, &tempfileDir, 0);//this call can't fail
405 RFs& fs = sqlite3SymbianFs();
406 CFileMan* fm = CFileMan::NewL(fs);
407 (void)fm->Delete(parse.FullName());
412 Retrieves in iCollationDllName current(default) collation dll name.
415 void CSqlServer::GetCollationDllNameL()
417 TExtendedLocale extdlocale;
418 extdlocale.LoadSystemSettings();
421 TInt err = extdlocale.GetLocaleDllName(ELocaleCollateSetting, fname);
424 iCollationDllName = KDefaultICollationDllName;
428 //only get the file name + extension
429 fileName.Set(fname, NULL, NULL);
430 iCollationDllName = fileName.NameAndExt();
432 SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSERVER_GETCOLLATIONDLLNAMEL, "0x%x;CSqlServer::GetCollationDllNameL;iCollationDllName=%S;err=%d", (TUint)this, __SQLPRNSTR(iCollationDllName), err));
435 Finds and caches the name of each database configuration file
436 that exists in the server's private data cage on the Z: drive
438 void CSqlServer::CacheDbConfigFileNamesL(RFs& aFs, const TDesC& aServerPrivatePath)
440 //Create an in-memory array holding the names of the database config files, if any exist
441 TParse parseDbConfig;
442 __SQLLEAVE_IF_ERROR(parseDbConfig.Set(KSqlSrvDbConfigFileFormat, &aServerPrivatePath, NULL));
443 TFileName configFilePath(parseDbConfig.FullName()); // get 'drive:\private path\cfg*' search string
444 CDir* entryList = 0; // memory will be allocated for this in GetDir()
445 TInt err = aFs.GetDir(configFilePath, KEntryAttNormal, ESortByName, entryList);
448 __ASSERT_DEBUG(entryList != NULL, __SQLPANIC(ESqlPanicInternalError));
449 CleanupStack::PushL(entryList);
450 if(entryList->Count() > 0)
452 iDbConfigFiles = CDbConfigFiles::NewL(*entryList);
454 CleanupStack::PopAndDestroy(entryList);
458 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_CACHEDDBCONFIGFILENAMESL, "0x%X;CSqlServer::CacheDbConfigFileNamesL;GetDir() failed with error code %d", (TUint)this, err));
459 __ASSERT_DEBUG(!entryList, __SQLPANIC(ESqlPanicInternalError));
463 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
464 //////////////////////////////////////// MSqlPolicyInspector implementation ///////////////////////////////
465 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
468 Implements MSqlPolicyInspector::Check() method.
470 @see MSqlPolicyInspector
471 @see MSqlPolicyInspector::Check()
473 TBool CSqlServer::Check(const TSecurityPolicy& aPolicy) const
475 #ifdef SQLSRV_STARTUP_TEST
476 aPolicy.Package();//to prevent compiler warning
479 return aPolicy.CheckPolicy(CServer2::Message());
483 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
484 //////////////////////////////////////// MSqlSrvBurInterface implementation //////////////////////////////
485 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
488 Implements MSqlSrvBurInterface::Fs().
490 @return A reference to the file session instance.
492 RFs& CSqlServer::Fs()
494 return iFileData.Fs();
498 Implements MSqlSrvBurInterface::GetBackupListL().
499 Retrieves in aFileNameList parameter a list of secure database names (full database names, including path)
500 which security UID matches aUid parameter.
501 No databases will be included into the list, if the drive is read-only.
503 @param aUid Database security UID.
504 @param aDrive The drive where the database search will be performed, in the SQL server private data cage.
505 @param aFileNameList An output parameter.
506 Each array entry represents the full name of a database in SQL server private data cage
507 on the specified drive (aDrive), which uid matches the aUid parameter.
509 @leave KErrNoMemory, an out of memory condition has occured;
510 Note that the function may leave also with some other database specific or OS specific
513 void CSqlServer::GetBackUpListL(TSecureId aUid, TDriveNumber aDrive, RArray<HBufC*>& aFileNameList)
515 SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_ENTRY, "Entry;0x%x;CSqlServer::GetBackUpListL;aDrive=%d;aUid=0x%X", (TUint)this, (TInt)aDrive, (TUint)aUid.iId));
516 __ASSERT_DEBUG(aFileNameList.Count() == 0, __SQLPANIC(ESqlPanicBadArgument));
517 RFs& fs = iFileData.Fs();
518 //No files in the list if aDrive is a read-only drive
519 TDriveInfo driveInfo;
520 __SQLLEAVE_IF_ERROR(fs.Drive(driveInfo, aDrive));
521 if(driveInfo.iDriveAtt & KDriveAttRom)
525 //Compose the search path
526 TDriveUnit driveUnit(aDrive);
527 TDriveName driveName = driveUnit.Name();
529 path.Copy(driveName);
530 path.Append(iFileData.PrivatePath());
531 //Include the aUid and the "*" mask
532 TUidName uidName = (static_cast <TUid> (aUid)).Name();
533 TBuf<KMaxUidName + sizeof(KMatchAllDbFiles)> fileNameMask(uidName);
534 fileNameMask.Append(KMatchAllDbFiles);
536 __SQLLEAVE_IF_ERROR(parse.Set(path, &fileNameMask, NULL));
538 TPtrC fullPath(parse.FullName());
539 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_FULLPATH, "Exit;0x%x;CSqlServer::GetBackUpListL;fullPath=%S", (TUint)this, __SQLPRNSTR(fullPath)));
540 CDir* fileNameCol = NULL;
541 TInt err = fs.GetDir(fullPath, KEntryAttNormal, ESortNone, fileNameCol);
542 if(err == KErrNotFound)
544 __ASSERT_DEBUG(!fileNameCol, __SQLPANIC(ESqlPanicInternalError));
545 SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_EXIT1, "Exit;0x%x;CSqlServer::GetBackUpListL;no files found", (TUint)this));
548 __SQLLEAVE_IF_ERROR(err);
549 __ASSERT_DEBUG(fileNameCol != NULL, __SQLPANIC(ESqlPanicInternalError));
550 CleanupStack::PushL(fileNameCol);
551 TInt fileCount = fileNameCol->Count();
552 __SQLLEAVE_IF_ERROR(aFileNameList.Reserve(fileCount));
553 //Append the full database file paths to the file names list.
554 for(TInt i=0;i<fileCount;++i)
556 const ::TEntry& entry = (*fileNameCol)[i];
557 __ASSERT_DEBUG(!entry.IsDir(), __SQLPANIC(ESqlPanicInternalError));//RFs::GetDir() search attributes exclude directories (see the GetDir() call above).
558 __SQLLEAVE_IF_ERROR(parse.Set(path, &entry.iName, NULL));
559 TPtrC fname(parse.FullName());
560 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL, "0x%x;CSqlServer::GetBackUpListL;fname=%S", (TUint)this, __SQLPRNSTR(fname)));
561 HBufC* fnameBuf = fname.AllocL();
562 __SQLDEBUG_EXPR(err = )aFileNameList.Append(fnameBuf);
563 __ASSERT_DEBUG(err == KErrNone, __SQLPANIC(ESqlPanicInternalError));
565 CleanupStack::PopAndDestroy(fileNameCol);
566 SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSERVER_GETBACKUPLISTL_EXIT2, "Exit;0x%x;CSqlServer::GetBackUpListL;file count=%d", (TUint)this, fileCount));
569 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
570 //////////////////////////////////////// SQL server startup //////////////////////////////////////////////
571 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
573 #ifndef SQLSRV_STARTUP_TEST
576 static void RunServerL()
578 // naming the server thread after the server helps to debug panics
579 User::LeaveIfError(User::RenameThread(KSqlSrvName));
581 // create and install the active scheduler we need
582 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
583 CleanupStack::PushL(scheduler);
584 CActiveScheduler::Install(scheduler);
585 TheServer = CSqlServer::NewLC();
586 RProcess::Rendezvous(KErrNone);
587 CActiveScheduler::Start();
589 CleanupStack::PopAndDestroy(2, scheduler);//CSqlServer, scheduler
592 // SQL server process entry point
597 CTrapCleanup* cleanup = CTrapCleanup::New();
598 TInt err = KErrNoMemory;
601 TRAP(err, ::RunServerL());
610 #endif //SQLSRV_STARTUP_TEST