persistentstorage/sql/SRC/Server/SqlSrvDatabase.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
--- a/persistentstorage/sql/SRC/Server/SqlSrvDatabase.cpp	Tue Aug 31 16:57:14 2010 +0300
+++ b/persistentstorage/sql/SRC/Server/SqlSrvDatabase.cpp	Wed Sep 01 12:39:58 2010 +0100
@@ -22,11 +22,6 @@
 #include "SqlSrvUtil.h"			//Global server functions
 #include "SqlCompact.h"
 #include "SqlSrvResourceProfiler.h"
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "SqlSrvDatabaseTraces.h"
-#endif
-#include "SqlTraceDef.h"
 
 //
 // The following macro disables the creation/loading of the settings table.
@@ -91,7 +86,7 @@
 //aRight argument is NULL.
 static TInt Compare(const TSqlAttachDbPair& aLeft, const TSqlAttachDbPair& aRight)
 	{
-	__ASSERT_DEBUG(aLeft.iKey != NULL && aRight.iKey != NULL, __SQLPANIC2(ESqlPanicInternalError));
+	__SQLASSERT(aLeft.iKey != NULL && aRight.iKey != NULL, ESqlPanicInternalError);
 	return ::CompareNoCase8(TPtrC8(aLeft.iKey), TPtrC8(aRight.iKey));
 	}
 
@@ -106,7 +101,7 @@
 //aRight argument is NULL.
 static TInt Compare2(const TSqlCompactDbPair& aLeft, const TSqlCompactDbPair& aRight)
 	{
-	__ASSERT_DEBUG(aLeft.iKey != NULL && aRight.iKey != NULL, __SQLPANIC2(ESqlPanicInternalError));
+	__SQLASSERT(aLeft.iKey != NULL && aRight.iKey != NULL, ESqlPanicInternalError);
 	return ::CompareNoCase(*aLeft.iKey, *aRight.iKey);
 	}
 
@@ -120,13 +115,13 @@
 		TBuf8<KMaxFileName + 1> fileNameZ;
 		if(!::UTF16ZToUTF8Z(aFileData.FileNameZ(), fileNameZ))
 			{
-			__SQLLEAVE2(KErrGeneral);	
+			__SQLLEAVE(KErrGeneral);	
 			}
-		__SQLLEAVE_IF_ERROR2(::CreateDbHandle8(fileNameZ, aDbHandle));
+		__SQLLEAVE_IF_ERROR(::CreateDbHandle8(fileNameZ, aDbHandle));
 		}
 	else
 		{
-		__SQLLEAVE_IF_ERROR2(::CreateDbHandle16(aFileData.FileNameZ(), aDbHandle));
+		__SQLLEAVE_IF_ERROR(::CreateDbHandle16(aFileData.FileNameZ(), aDbHandle));
 		}
 	}
 	
@@ -158,7 +153,7 @@
 //The function is used to read the security policy of the main database.
 static CSqlSecurityPolicy* LoadDbSecurityPolicyLC(sqlite3* aDbHandle)
 	{
-	__ASSERT_DEBUG(aDbHandle != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aDbHandle != NULL, ESqlPanicBadArgument);
 	//Create new database security policy object and initialize it with a default security policy
 	TSecurityPolicy defaultPolicy(TSecurityPolicy::EAlwaysFail);
 	CSqlSecurityPolicy* dbPolicy = CSqlSecurityPolicy::NewLC(defaultPolicy);
@@ -173,7 +168,7 @@
 //The function panics in _DEBUG mode if aSrc is NULL.
 static TUint8* CreateStrCopyLC(const TUint8* aSrc)
 	{
-	__ASSERT_DEBUG(aSrc != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aSrc != NULL, ESqlPanicBadArgument);
 	TInt len = User::StringLength(aSrc) + 1;
 	TUint8* copy = new (ELeave) TUint8[len];
 	Mem::Copy(copy, aSrc, len);
@@ -185,7 +180,7 @@
 //during the stack cleanup.
 static void EnableAuthorizer(void* aAuthorizerDisabled)
 	{
-	__ASSERT_DEBUG(aAuthorizerDisabled != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aAuthorizerDisabled != NULL, ESqlPanicBadArgument);
 	TBool* authorizerDisabled = static_cast <TBool*> (aAuthorizerDisabled);
 	*authorizerDisabled = EFalse;
 	}
@@ -214,7 +209,7 @@
 //CSqlSrvDatabase's ConstructL() method(s) leave (when creating a new database file).
 static void DbFileCleanup(void* aDbFileCleanup)
 	{
-	__ASSERT_DEBUG(aDbFileCleanup != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aDbFileCleanup != NULL, ESqlPanicBadArgument);
 	TDbFileCleanup* dbFileCleanup = static_cast <TDbFileCleanup*> (aDbFileCleanup);
 	dbFileCleanup->Cleanup();
 	}
@@ -228,26 +223,23 @@
 //During the call the authorizer will be disabled.
 static TInt ExecPragma(sqlite3* aDbHandle, TBool& aAuthorizerDisabled, const TDesC& aPragma, TInt aValue, const TDesC& aDbName = KMainDb16)
 	{
-    __SQLTRACE_INTERNALSEXPR(TPtrC pragmaprnptr(aPragma.Left(aPragma.Length() - 1)));
-	SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, EXECPRAGMA_ENTRY, "Entry;0;ExecPragma;sqlite3*=0x%X;aPragma=%S;aValue=%d;aDbName=%S", (TUint)aDbHandle, __SQLPRNSTR(pragmaprnptr), aValue, __SQLPRNSTR(aDbName)));
-	__ASSERT_DEBUG(aDbHandle != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aDbHandle != NULL, ESqlPanicBadArgument);
 	TBuf<KMaxFileName + 64> pragmaSql;//(KMaxFileName + 64) characters buffer length is enough for the longest possible PRAGMA statement
 	pragmaSql.Format(aPragma, &aDbName, aValue);
 	TBool authorizerDisabledState = aAuthorizerDisabled;
 	aAuthorizerDisabled	= ETrue;
 	TInt err = DbExecStmt16(aDbHandle, pragmaSql);
 	aAuthorizerDisabled = authorizerDisabledState;
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, EXECPRAGMA_EXIT, "Exit;0;ExecPragma;sqlite3*=0x%X;err=%d", (TUint)aDbHandle, err));
 	return err;
 	}
 
 //The journal size limit is set to be at lest 16 pages and no less than 64 Kb.
 static void SetJournalSizeLimitL(sqlite3* aDbHandle, TBool& aAuthorizerDisabled, TInt aPageSize, const TDesC& aDbName = KMainDb16)
 	{
-	__ASSERT_DEBUG(aDbHandle != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aDbHandle != NULL, ESqlPanicBadArgument);
 	if(aPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet)
 		{
-		__SQLLEAVE_IF_ERROR2(DbPageSize(aDbHandle, aDbName, aPageSize));
+		__SQLLEAVE_IF_ERROR(DbPageSize(aDbHandle, aDbName, aPageSize));
 		}
 	const TInt KPageMultiplier = 16;
 	const TInt KDefaultJournalSizeLimit = 64 * 1024;
@@ -255,7 +247,7 @@
 	const TInt KJournalSizeLimit = Min((aPageSize * KPageMultiplier), KMaxJournalSizeLimit);
 	if(KJournalSizeLimit > KDefaultJournalSizeLimit)
 		{
-		__SQLLEAVE_IF_ERROR2(::ExecPragma(aDbHandle, aAuthorizerDisabled, KJournalSizeLimitPragma, KJournalSizeLimit));
+		__SQLLEAVE_IF_ERROR(::ExecPragma(aDbHandle, aAuthorizerDisabled, KJournalSizeLimitPragma, KJournalSizeLimit));
 		}
 	}
 
@@ -301,16 +293,15 @@
 */
 CSqlSrvDatabase* CSqlSrvDatabase::CreateSecureL(const TSqlSrvFileData& aFileData, CSqlSecurityPolicy* aSecurityPolicy)
 	{
-	SQL_TRACE_INTERNALS(OstTrace0(TRACE_INTERNALS, CSQLSRVDATABASE_CREATESECUREL_ENTRY, "Entry;0;CSqlSrvDatabase::CreateSecureL"));
-	__ASSERT_DEBUG(aFileData.IsSecureFileNameFmt(), __SQLPANIC2(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aSecurityPolicy != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aFileData.IsSecureFileNameFmt(), ESqlPanicBadArgument);
+	__SQLASSERT(aSecurityPolicy != NULL, ESqlPanicBadArgument);
 	if(!::SqlServer().SecurityInspector().Check(aSecurityPolicy->DbPolicy(RSqlSecurityPolicy::ESchemaPolicy)))
 		{
 		//The caller has no "SCHEMA" policy. Then the client is not given a permission to create the database.
 		//Delete aSecurityPolicy since no database object is going to be created and the security policy object 
 		//won't be put in the security policies map.
 		delete aSecurityPolicy;
-		__SQLLEAVE2(KErrPermissionDenied);
+		__SQLLEAVE(KErrPermissionDenied);
 		}
 	//What does happen with aSecurityPolicy instance?
 	// If the database is created successfully, then a lookup will be made in the security policies map.
@@ -333,7 +324,6 @@
 	CleanupStack::PushL(self);
 	self->ConstructCreateSecureL(aFileData, aSecurityPolicy);
 	CleanupStack::Pop(self);
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_CREATESECUREL_EXIT, "Exit;0x%X;CSqlSrvDatabase::CreateSecureL;sqlite3*=0x%X", (TUint)self, (TUint)self->iDbHandle));
 	return self;
 	}
 
@@ -364,13 +354,11 @@
 */
 CSqlSrvDatabase* CSqlSrvDatabase::CreateL(const TSqlSrvFileData& aFileData)
 	{
-	SQL_TRACE_INTERNALS(OstTrace0(TRACE_INTERNALS, CSQLSRVDATABASE_CREATEL_ENTRY, "Entry;0;CSqlSrvDatabase::CreateL"));
-	__ASSERT_DEBUG(!aFileData.IsSecureFileNameFmt(), __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(!aFileData.IsSecureFileNameFmt(), ESqlPanicBadArgument);
 	CSqlSrvDatabase* self = new (ELeave) CSqlSrvDatabase();
 	CleanupStack::PushL(self);
 	self->ConstructCreateL(aFileData);
 	CleanupStack::Pop(self);
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_CREATEL_EXIT, "Exit;0x%X;CSqlSrvDatabase::CreateL;sqlite3*=0x%X", (TUint)self, (TUint)self->iDbHandle));
 	return self;
 	}
 
@@ -405,12 +393,10 @@
 */
 CSqlSrvDatabase* CSqlSrvDatabase::OpenL(const TSqlSrvFileData& aFileData)
 	{
-	SQL_TRACE_INTERNALS(OstTrace0(TRACE_INTERNALS, CSQLSRVDATABASE_OPENL_ENTRY, "Entry;0;CSqlSrvDatabase::OpenL"));
 	CSqlSrvDatabase* self = new (ELeave) CSqlSrvDatabase();
 	CleanupStack::PushL(self);
 	aFileData.IsSecureFileNameFmt() ? self->ConstructOpenSecureL(aFileData) : self->ConstructOpenL(aFileData);
 	CleanupStack::Pop(self);
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_OPENL_EXIT, "Exit;0x%X;CSqlSrvDatabase::OpenL;sqlite3*=0x%X", (TUint)self, (TUint)self->iDbHandle));
 	return self;
 	}
 
@@ -419,12 +405,12 @@
 */
 CSqlSrvDatabase::~CSqlSrvDatabase()
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_CSQLSRVDATABASE2_ENTRY, "Entry;0x%X;CSqlSrvDatabase::~CSqlSrvDatabase;sqlite3*=0x%X", (TUint)this, (TUint)iDbHandle));
+    SQLPROFILER_DB_CLOSE((TUint)iDbHandle);
 	TSqlCompactDbMapIterator compactDbIt(iCompactDbMap);
 	TSqlCompactDbPair compactDbPair;
 	while(compactDbIt.Next(compactDbPair))
 		{
-	   __ASSERT_DEBUG(compactDbPair.iData, __SQLPANIC2(ESqlPanicInvalidObj));
+        __SQLASSERT(compactDbPair.iData, ESqlPanicInvalidObj);
 		::SqlServer().Compactor().ReleaseEntry(*compactDbPair.iData);
 		}
 	iCompactDbMap.Close();
@@ -467,12 +453,11 @@
     TSqlAttachDbPair attachDbPair;
     while(it.Next(attachDbPair))
         {
-        __ASSERT_DEBUG(attachDbPair.iData, __SQLPANIC2(ESqlPanicInvalidObj));
-       ::SqlServer().SecurityMap().Remove(attachDbPair.iData);
+        __SQLASSERT(attachDbPair.iData, ESqlPanicInvalidObj);
+        ::SqlServer().SecurityMap().Remove(attachDbPair.iData);
         }
 	iAttachDbMap.Close();
 	::CloseDbHandle(iDbHandle);
-	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSRVDATABASE_CSQLSRVDATABASE2_EXIT, "Exit;0x%X;CSqlSrvDatabase::~CSqlSrvDatabase", (TUint)this));
 	}
 
 /**
@@ -510,8 +495,6 @@
 */
 void CSqlSrvDatabase::CreateNewDbFileL(const TSqlSrvFileData& aFileData)
 	{
-	__SQLTRACE_INTERNALSVAR(TPtrC fname = aFileData.FileName());
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_CREATENEWDBFILEL, "0x%x;CSqlSrvDatabase::CreateNewDbFileL;fname=%S", (TUint)this, __SQLPRNSTR(fname)));
 	if(::FileExists(aFileData.Fs(), aFileData.FileName()))
 		{
 		__SQLLEAVE(KErrAlreadyExists);	
@@ -547,8 +530,6 @@
 */
 void CSqlSrvDatabase::OpenExistingDbFileL(const TSqlSrvFileData& aFileData)
 	{
-	__SQLTRACE_INTERNALSVAR(TPtrC fname = aFileData.FileName());
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_OPENEXISTINGDBFILEL, "0x%x;CSqlSrvDatabase::OpenExistingDbFileL;fname=%S", (TUint)this, __SQLPRNSTR(fname)));
 	if(!aFileData.ContainHandles())
 		{//This check is valid only if the database is outside application's private data cage
 		if(!::FileExists(aFileData.Fs(), aFileData.FileName()))
@@ -673,7 +654,6 @@
 */
 void CSqlSrvDatabase::AttachDbL(const TSqlSrvFileData& aFileData, const TDesC& aDbName)
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_ATTACHDBL_ENTRY, "Entry;0x%X;CSqlSrvDatabase::AttachDbL;aDbName=%S", (TUint)this, __SQLPRNSTR(aDbName)));
 	if(!aFileData.ContainHandles())
 		{//This check is valid only if the database is outside application's private data cage
 		if(!::FileExists(aFileData.Fs(), aFileData.FileName()))
@@ -716,7 +696,6 @@
 			__SQLLEAVE(err);
 			}
 		}
-	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSRVDATABASE_ATTACHDBL_EXIT, "Exit;0x%X;CSqlSrvDatabase::AttachDbL", (TUint)this));
 	}
 
 /**
@@ -800,7 +779,6 @@
 */
 void CSqlSrvDatabase::DetachDbL(const TDesC& aDbName)
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_DETACHDBL_ENTRY, "Entry;0x%X;CSqlSrvDatabase::DetachDbL;aDbName=%S", (TUint)this, __SQLPRNSTR(aDbName)));
 	TInt err = FinalizeAttachedDb(aDbName);
 	if(err == KErrNone)
 		{
@@ -810,7 +788,6 @@
 		{
 		__SQLLEAVE(err);
 		}
-	SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSRVDATABASE_DETACHDBL_EXIT, "Exit;0x%X;CSqlSrvDatabase::DetachDbL", (TUint)this));
 	}
 
 /**
@@ -829,7 +806,7 @@
 	CleanupStack::PushL(TCleanupItem(&EnableAuthorizer, &iAuthorizerDisabled));
 	TInt pageCount = 0;
 	__SQLLEAVE_IF_ERROR(::DbPageCount(iDbHandle, aDbName, pageCount));
-	__ASSERT_DEBUG(pageCount >= 0, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(pageCount >= 0, ESqlPanicInternalError);
 	CleanupStack::PopAndDestroy();
 	return (TInt64)pageCount * PageSizeL(aDbName);
 	}
@@ -851,7 +828,7 @@
 	TInt freePageCount = 0;
 	__SQLLEAVE_IF_ERROR(::DbFreePageCount(iDbHandle, aDbName, freePageCount));
 	CleanupStack::PopAndDestroy();
-	__ASSERT_DEBUG(freePageCount >= 0, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(freePageCount >= 0, ESqlPanicInternalError);
 	return (TInt64)freePageCount * PageSizeL(aDbName);
 	}
 
@@ -915,8 +892,7 @@
 */
 TInt CSqlSrvDatabase::CompactL(TInt aSize, const TDesC& aDbName)
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSRVDATABASE_COMPACTL_ENTRY, "Entry;0x%X;CSqlSrvDatabase::CompactL;aSize=%d;aDbName=%S", (TUint)this, aSize, __SQLPRNSTR(aDbName)));
-	__ASSERT_DEBUG(aSize > 0 || aSize == RSqlDatabase::EMaxCompaction, __SQLPANIC(ESqlPanicBadArgument));
+	__SQLASSERT(aSize > 0 || aSize == RSqlDatabase::EMaxCompaction, ESqlPanicBadArgument);
 	TInt pageSize = PageSizeL(aDbName);//PageSizeL() will disable/enable the authorizer
 	TInt pageCount = KMaxTInt;
 	if(aSize > 0)
@@ -930,7 +906,6 @@
 		__SQLLEAVE_IF_ERROR(::DbCompact(iDbHandle, aDbName, pageCount, pageCount));
 		CleanupStack::PopAndDestroy();
 		}
-	SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSRVDATABASE_COMPACTL_EXIT, "Exit;0x%X;CSqlSrvDatabase::CompactL;pageCount=%d;pageSize=%d", (TUint)this, pageCount, pageSize));
 	return pageCount * pageSize;
 	}
 
@@ -968,7 +943,7 @@
 void CSqlSrvDatabase::AttachCleanup(void* aCleanup)
 	{
 	TAttachCleanup* cleanup = reinterpret_cast <TAttachCleanup*> (aCleanup);
-	__ASSERT_DEBUG(cleanup != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(cleanup != NULL, ESqlPanicBadArgument);
 	(void)cleanup->iSelf.FinalizeAttachedDb(cleanup->iDbName);
 	}
 
@@ -1103,17 +1078,17 @@
 		{
 		//No, it is not in the map. Read the security policies from the security policies tables and 
 		//insert a new item in the map.
-		__ASSERT_DEBUG(aMapKey != NULL, __SQLPANIC(ESqlPanicInternalError));
+		__SQLASSERT(aMapKey != NULL, ESqlPanicInternalError);
 		aMapKey = ::CreateStrCopyLC(aMapKey);
 		CSqlSecurityPolicy* securityPolicy = aAttachedDb ? ::LoadAttachedDbSecurityPolicyLC(aFileData) :
 		                                                   ::LoadDbSecurityPolicyLC(iDbHandle);
-	    __ASSERT_DEBUG(!::SqlServer().SecurityMap().Entry(aMapKey), __SQLPANIC2(ESqlPanicObjExists));
+        __SQLASSERT(!::SqlServer().SecurityMap().Entry(aMapKey), ESqlPanicObjExists);
 		__SQLLEAVE_IF_ERROR(::SqlServer().SecurityMap().Insert(aMapKey, securityPolicy));
 		CleanupStack::Pop(2);//iSecurityMap owns aMapKey and securityPolicy objects
 		aSecurityPolicy = securityPolicy;
 		}
-	__ASSERT_DEBUG(aMapKey != NULL, __SQLPANIC(ESqlPanicInternalError));
-	__ASSERT_DEBUG(aSecurityPolicy != NULL, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(aMapKey != NULL, ESqlPanicInternalError);
+	__SQLASSERT(aSecurityPolicy != NULL, ESqlPanicInternalError);
 	}
 
 /**
@@ -1142,7 +1117,6 @@
 */
 void CSqlSrvDatabase::RemoveFromMapsL(const TDesC& aDbName)
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_REMOVEFROMMAPSL, "0x%X;CSqlSrvDatabase::RemoveFromMapsL;aDbName=%S", (TUint)this, __SQLPRNSTR(aDbName)));
 	TPtr8 ptr(iFileNameBuf, sizeof(iFileNameBuf));
 	if(!::UTF16ToUTF8Z(aDbName, ptr))
 		{
@@ -1173,7 +1147,6 @@
 */
 void CSqlSrvDatabase::InsertInAttachDbMapL(const TDesC& aDbFileName, const TDesC& aDbName)
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSRVDATABASE_INSERTINATTACHDBMAPL, "0x%X;CSqlSrvDatabase::InsertInAttachDbMapL;aDbFileName=%S;aDbName=%S", (TUint)this, __SQLPRNSTR(aDbFileName), __SQLPRNSTR(aDbName)));
 	//Convert aDbName to UTF8, zero-terminated name
 	TPtr8 ptr(iFileNameBuf, sizeof(iFileNameBuf));
 	if(!::UTF16ToUTF8Z(aDbName, ptr))
@@ -1183,7 +1156,7 @@
 	const TUint8* mapKey = ::CreateStrCopyLC(iFileNameBuf);
 	const TUint8* mapData = SecurityMapKeyL(aDbFileName);
 	mapData = ::CreateStrCopyLC(mapData);
-	__ASSERT_DEBUG(!iAttachDbMap.Entry(mapKey), __SQLPANIC(ESqlPanicObjExists));
+    __SQLASSERT(!iAttachDbMap.Entry(mapKey), ESqlPanicObjExists);
 	__SQLLEAVE_IF_ERROR(iAttachDbMap.Insert(mapKey, mapData));
 	CleanupStack::Pop(2);//iAttachDbMap owns mapKey amd mapData.
 	}
@@ -1205,7 +1178,7 @@
 */
 void CSqlSrvDatabase::ProcessSettingsL(const TSqlSrvFileData& aFileData, const TDesC& aDbName)
 	{
-	__ASSERT_DEBUG(!aFileData.IsReadOnly(), __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(!aFileData.IsReadOnly(), ESqlPanicInternalError);
 #if !defined(__SQL_DISABLE_SYMBIAN_SETTINGS_TABLE__)
 	//Make the journal file persistent - done by SQLite automatically because the locking mode is EXCLUSIVE
 	//__SQLLEAVE_IF_ERROR(::ExecPragma(iDbHandle, iAuthorizerDisabled, KPersistentJournalPragma, KPersist, aDbName));
@@ -1218,7 +1191,7 @@
 	TSqlCompactionMode compactionMode = currVacuumMode == ESqliteVacuumOff ? ESqlCompactionManual : ESqlCompactionNotSet;
 	TSqlDbSysSettings dbSettings(iDbHandle);
 	dbSettings.LoadSettingsL(aDbName, storedCollationDllName, storedDbConfigFileVer, compactionMode);
-	__ASSERT_DEBUG(currVacuumMode == ESqliteVacuumOff ? compactionMode == ESqlCompactionManual : 1, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(currVacuumMode == ESqliteVacuumOff ? compactionMode == ESqlCompactionManual : 1, ESqlPanicInternalError);
 	if(aFileData.ContainHandles() && aFileData.IsCreated())
 		{
 		compactionMode = aFileData.ConfigParams().iCompactionMode;
@@ -1262,7 +1235,6 @@
 	//Check whether reindexing is necessary
 	if(::SqlServer().CollationDllName().CompareF(aStoredCollationDllName) != 0)
 		{
-		SQL_TRACE_INTERNALS(OstTraceExt3(TRACE_INTERNALS, CSQLSRVDATABASE_APPLYCONFIGUPDATES2L, "0x%X;CSqlSrvDatabase::ApplyConfigUpdatesL;Reindex db;aStoredCollationDllName=%S;aDbName=%S", (TUint)this, __SQLPRNSTR(aStoredCollationDllName), __SQLPRNSTR(aDbName)));
 		dbSettings.ReindexDatabaseL(aDbName, ::SqlServer().CollationDllName());
 		}
 
@@ -1273,7 +1245,7 @@
 	TRAPD(err, dbSettings.ConfigureDatabaseL(aStoredDbConfigFileVersion, aFileData, aDbName));
 	if(KErrNone != err)
 		{
-		SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_APPLYCONFIGUPDATESL, "0x%X;CSqlSrvDatabase::ApplyConfigUpdatesL;ConfigureDatabaseL() failed with error code %d", (TUint)this, err));	
+		__SQLLOG_ERR(_L("SQLLOG: CSqlSrvDatabase::ApplyConfigUpdatesL() - ConfigureDatabaseL() failed with error code %d"), err);	
 		}
 	}
 
@@ -1290,17 +1262,17 @@
 */
 void CSqlSrvDatabase::SetConfigL(const TSqlSrvConfigParams& aConfigParams, TBool aSetPageSize, const TDesC& aLogicalDbName)
 	{
-	__ASSERT_DEBUG(aConfigParams.iPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iPageSize >= 0, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aConfigParams.iCacheSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iCacheSize >= 0, __SQLPANIC(ESqlPanicBadArgument));
+	__SQLASSERT(aConfigParams.iPageSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iPageSize >= 0, ESqlPanicBadArgument);
+	__SQLASSERT(aConfigParams.iCacheSize == TSqlSrvConfigParams::KConfigPrmValueNotSet || aConfigParams.iCacheSize >= 0, ESqlPanicBadArgument);
 	if(aSetPageSize && aConfigParams.iPageSize != TSqlSrvConfigParams::KConfigPrmValueNotSet)
 		{
 		__SQLLEAVE_IF_ERROR(::ExecPragma(iDbHandle, iAuthorizerDisabled, KPageSizePragma, aConfigParams.iPageSize));
 		}
 	
 	const TDesC& logicalDbName = aLogicalDbName.Length() > 0 ? aLogicalDbName : KMainDb16;
-	
+
 	::SetJournalSizeLimitL(iDbHandle, iAuthorizerDisabled, aConfigParams.iPageSize, logicalDbName);
-
+	
 	//Setting the cache size.
 	//Step 1: Check if aConfigParams.iCacheSize value is set. If it is set, then use it.
 	if(aConfigParams.iCacheSize != TSqlSrvConfigParams::KConfigPrmValueNotSet)
@@ -1312,8 +1284,8 @@
 	//Step 2: aConfigParams.iCacheSize value is not set. Then check if aConfigParams.iSoftHeapLimitKb value is set.
 		if(aConfigParams.iSoftHeapLimitKb != TSqlSrvConfigParams::KConfigPrmValueNotSet)
 			{
-			__ASSERT_DEBUG(aConfigParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb && 
-			            aConfigParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb, __SQLPANIC(ESqlPanicInternalError));
+			__SQLASSERT(aConfigParams.iSoftHeapLimitKb >= TSqlSrvConfigParams::KMinSoftHeapLimitKb && 
+			            aConfigParams.iSoftHeapLimitKb <= TSqlSrvConfigParams::KMaxSoftHeapLimitKb, ESqlPanicInternalError);
 	//Step 3: aConfigParams.iSoftHeapLimitKb value is set. Then use it to calculate the cache size. But we need the page size first.
     //        aLogicalDbName is used instead of logicalDbName because PageSizeL() if called with non-zero length name, 
 	//        "thinks" it is the main database name. KMainDb16 will be interpreted as an attached database name. 
@@ -1354,10 +1326,10 @@
 void CSqlSrvDatabase::InitCompactionL(TSqlCompactionMode aCompactionMode, TInt aFreePageThresholdKb, 
 									  const TDesC& aDbFileName, TSqliteVacuumMode aCurrentVacuumMode, const TDesC& aDbName)
 	{
-	__ASSERT_DEBUG(aCompactionMode == ESqlCompactionManual || aCompactionMode == ESqlCompactionBackground || aCompactionMode == ESqlCompactionAuto, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aCurrentVacuumMode == ESqliteVacuumOff || aCurrentVacuumMode == ESqliteVacuumAuto || 
-			    aCurrentVacuumMode == ESqliteVacuumIncremental, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aFreePageThresholdKb >= 0, __SQLPANIC(ESqlPanicBadArgument));
+	__SQLASSERT(aCompactionMode == ESqlCompactionManual || aCompactionMode == ESqlCompactionBackground || aCompactionMode == ESqlCompactionAuto, ESqlPanicBadArgument);
+	__SQLASSERT(aCurrentVacuumMode == ESqliteVacuumOff || aCurrentVacuumMode == ESqliteVacuumAuto || 
+			    aCurrentVacuumMode == ESqliteVacuumIncremental, ESqlPanicBadArgument);
+	__SQLASSERT(aFreePageThresholdKb >= 0, ESqlPanicBadArgument);
 	TSqliteVacuumMode newSqliteVacuumMode = aCompactionMode == ESqlCompactionAuto ? ESqliteVacuumAuto : ESqliteVacuumIncremental;
 	if(aCurrentVacuumMode == ESqliteVacuumOff)
 		{
@@ -1390,7 +1362,6 @@
 */
 void CSqlSrvDatabase::NewCompactEntryL(TInt aFreePageThresholdKb, const TDesC& aDbFileName, const TDesC& aDbName)
 	{
-	SQL_TRACE_INTERNALS(OstTraceExt4(TRACE_INTERNALS, CSQLSRVDATABASE_NEWCOMPACTENTRYL_ENTRY, "Entry;0x%X;CSqlSrvDatabase::NewCompactEntryL;aFreePageThresholdKb=%d;aDbFileName=%S;aDbName=%S", (TUint)this, aFreePageThresholdKb, __SQLPRNSTR(aDbFileName), __SQLPRNSTR(aDbName)));	
 	TSqlCompactSettings settings;
 	settings.iFreePageThresholdKb = aFreePageThresholdKb;
 	::SqlServer().Compactor().AddEntryL(aDbFileName, settings);
@@ -1399,7 +1370,7 @@
 	HBufC* data = aDbFileName.Alloc();
 	if(key && data)
 		{
-	    __ASSERT_DEBUG(!iCompactDbMap.Entry(key), __SQLPANIC(ESqlPanicObjExists));
+	    __SQLASSERT(!iCompactDbMap.Entry(key), ESqlPanicObjExists);
 		err = iCompactDbMap.Insert(key, data);//returns the index of the new entry
 		}
 	if(err < 0) //If either "key" or "data" or both is NULL, then "err" is KErrNoMemory and the next "if" will be executed.
@@ -1408,7 +1379,6 @@
 		delete key;
 		::SqlServer().Compactor().ReleaseEntry(aDbFileName);
 		}
-	SQL_TRACE_INTERNALS(OstTraceExt2(TRACE_INTERNALS, CSQLSRVDATABASE_NEWCOMPACTENTRYL_EXIT, "Exit;0x%X;CSqlSrvDatabase::NewCompactEntryL;err=%d", (TUint)this, err));	
 	__SQLLEAVE_IF_ERROR(err);
 	}
 
@@ -1430,7 +1400,6 @@
 			{
 			::SqlServer().Compactor().ReleaseEntry(*compactDbPair.iData);
 			iCompactDbMap.Remove(compactDbPair.iKey);
-			SQL_TRACE_INTERNALS(OstTrace1(TRACE_INTERNALS, CSQLSRVDATABASE_RELEASECOMPACTENTRY, "0x%X;CSqlSrvDatabase::ReleaseCompactEntry", (TUint)this));	
 			break;
 			}
 		}
@@ -1450,7 +1419,7 @@
 void CSqlSrvDatabase::CompactCleanup(void* aCleanup)
 	{
 	CSqlSrvDatabase* self = reinterpret_cast <CSqlSrvDatabase*> (aCleanup);
-	__ASSERT_DEBUG(self != NULL, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(self != NULL, ESqlPanicBadArgument);
     self->ReleaseCompactEntry(KMainDb16);
 	}
 
@@ -1478,7 +1447,7 @@
 	TInt pageSize = 0;
 	__SQLLEAVE_IF_ERROR(::DbPageSize(iDbHandle, aDbName, pageSize));
 	CleanupStack::PopAndDestroy();
-	__ASSERT_DEBUG(pageSize > 0, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(pageSize > 0, ESqlPanicInternalError);
 	if(aDbName == KNullDesC)
 		{
 		iPageSize = pageSize;	
@@ -1506,13 +1475,13 @@
 */
 void CSqlSrvDatabase::ConstructCreateSecureL(const TSqlSrvFileData& aFileData, CSqlSecurityPolicy* aSecurityPolicy)
 	{
-	__ASSERT_DEBUG(aSecurityPolicy != NULL, __SQLPANIC(ESqlPanicBadArgument));
+	__SQLASSERT(aSecurityPolicy != NULL, ESqlPanicBadArgument);
 	//Insert a new item in the security policies map.
 	CleanupStack::PushL(aSecurityPolicy);
 	const TUint8* mapKey = SecurityMapKeyL(aFileData.FileName());
 	mapKey = ::CreateStrCopyLC(mapKey);
-	__ASSERT_DEBUG(!::SqlServer().SecurityMap().Entry(mapKey), __SQLPANIC(ESqlPanicObjExists));
- 	__SQLLEAVE_IF_ERROR(::SqlServer().SecurityMap().Insert(mapKey, aSecurityPolicy));
+    __SQLASSERT(!::SqlServer().SecurityMap().Entry(mapKey), ESqlPanicObjExists);
+	__SQLLEAVE_IF_ERROR(::SqlServer().SecurityMap().Insert(mapKey, aSecurityPolicy));
 	CleanupStack::Pop(2);//iSecurityMap owns mapKey and aSecurityPolicy.
 	iSecureDbName = mapKey;
 	iSecurityPolicy = aSecurityPolicy;
@@ -1549,8 +1518,8 @@
 //If the method fails and the error is not KErrAlreadyExists, the database file will be closed and deleted.
 void CSqlSrvDatabase::DoCommonConstructCreateL(const TSqlSrvFileData& aFileData, TBool aSecureDb)
 	{
-	__ASSERT_DEBUG(!iDbHandle, __SQLPANIC(ESqlPanicInternalError));
-	__ASSERT_DEBUG(aSecureDb ? iSecurityPolicy != NULL : ETrue, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(!iDbHandle, ESqlPanicInternalError);
+	__SQLASSERT(aSecureDb ? iSecurityPolicy != NULL : ETrue, ESqlPanicInternalError);
 	CreateNewDbFileL(aFileData);
 	TDbFileCleanup dbFileCleanup(aFileData, iDbHandle);
 	CleanupStack::PushL(TCleanupItem(&DbFileCleanup, &dbFileCleanup));