persistentstorage/sql/SRC/Server/SqlSrvBlob.cpp
branchRCL_3
changeset 45 cc28652e0254
parent 44 26645d81f48d
--- a/persistentstorage/sql/SRC/Server/SqlSrvBlob.cpp	Tue Aug 31 16:57:14 2010 +0300
+++ b/persistentstorage/sql/SRC/Server/SqlSrvBlob.cpp	Wed Sep 01 12:39:58 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -14,19 +14,12 @@
 //
 
 #include "sqlite3.h"
-#include "SqlAssert.h"
+#include "SqlPanic.h"
 #include "SqlSrvBlob.h"
 #include "SqliteSymbian.h"
 #include "SqlSrvUtil.h"
 #include "SqlSrvStrings.h"
 #include "SqlDb.h"
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "SqlSrvBlobTraces.h"
-#endif
-#include "SqlTraceDef.h"
-
-#define UNUSED_VAR(var) var = var
 
 /**
 Creates a new HBlobBuf instance.
@@ -52,19 +45,14 @@
 */
 HBlobBuf* HBlobBuf::NewL(sqlite3* aDb, const TDesC8& aDbName, const TDesC8& aTableName, const TDesC8& aColumnName, TInt64 aRowId, TMode aMode)
 	{
-	__SQLTRACE_BLOBVAR(TBuf<100> des16prnbuf);
-	SQL_TRACE_BLOB(OstTraceExt4(TRACE_INTERNALS, HBLOBBUF_NEWL_ENTRY1, "Entry;0;HBlobBuf::NewL;sqlite3*=0x%X;aDbName=%s;aRowId=%lld;aMode=%d", (TUint)aDb, __SQLPRNSTR8(aDbName, des16prnbuf), aRowId, (TInt)aMode));
-	SQL_TRACE_BLOB(OstTraceExt1(TRACE_INTERNALS, HBLOBBUF_NEWL_ENTRY2, "Entry;0;HBlobBuf::NewL;aTableName=%s", __SQLPRNSTR8(aTableName, des16prnbuf)));
-	SQL_TRACE_BLOB(OstTraceExt1(TRACE_INTERNALS, HBLOBBUF_NEWL_ENTRY3, "Entry;0;HBlobBuf::NewL;aColumnName=%s", __SQLPRNSTR8(aColumnName, des16prnbuf)));
-	__ASSERT_DEBUG(aDb != NULL, __SQLPANIC2(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aRowId > 0, __SQLPANIC2(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aMode == HBlobBuf::EReadOnly || aMode == HBlobBuf::EReadWrite, __SQLPANIC2(ESqlPanicBadArgument));
+	__SQLASSERT(aDb != NULL, ESqlPanicBadArgument);
+	__SQLASSERT(aRowId > 0, ESqlPanicBadArgument);
+	__SQLASSERT(aMode == HBlobBuf::EReadOnly || aMode == HBlobBuf::EReadWrite, ESqlPanicBadArgument);
 	
 	HBlobBuf* self = new (ELeave) HBlobBuf;
 	CleanupStack::PushL(self);
 	self->ConstructL(aDb, aDbName, aTableName, aColumnName, aRowId, aMode);
 	CleanupStack::Pop(self);
-	SQL_TRACE_BLOB(OstTraceExt2(TRACE_INTERNALS, HBLOBBUF_NEWL_EXIT, "Exit;0x%X;HBlobBuf::NewL;sqlite3_blob*=0x%X", (TUint)self, (TUint)self->iBlobHandle));
 	return self;
 	}
 
@@ -101,16 +89,16 @@
 */
 void HBlobBuf::ConstructL(sqlite3* aDb, const TDesC8& aDbName, const TDesC8& aTableName, const TDesC8& aColumnName, TInt64 aRowId, TMode aMode)
 	{
-	__ASSERT_DEBUG(aDb != NULL, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aRowId > 0, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aMode == HBlobBuf::EReadOnly || aMode == HBlobBuf::EReadWrite, __SQLPANIC(ESqlPanicBadArgument));
+	__SQLASSERT(aDb != NULL, ESqlPanicBadArgument);
+	__SQLASSERT(aRowId > 0, ESqlPanicBadArgument);
+	__SQLASSERT(aMode == HBlobBuf::EReadOnly || aMode == HBlobBuf::EReadWrite, ESqlPanicBadArgument);
 	
 	(void)sqlite3SymbianLastOsError();//clear last OS error
 			
 	TInt err = sqlite3_blob_open(aDb, (const char*)aDbName.Ptr(), (const char*)aTableName.Ptr(), (const char*)aColumnName.Ptr(), 
 								 aRowId, aMode & HBlobBuf::EReadWrite, &iBlobHandle);
 	__SQLLEAVE_IF_ERROR(::Sql2OsErrCode(err, sqlite3SymbianLastOsError()));
-	__ASSERT_DEBUG(iBlobHandle != NULL, __SQLPANIC(ESqlPanicInternalError));
+	__SQLASSERT(iBlobHandle != NULL, ESqlPanicInternalError);
 	iBlobSize = sqlite3_blob_bytes(iBlobHandle);
 	iWrPos = iRdPos = 0;
 	}
@@ -120,11 +108,8 @@
 */
 void HBlobBuf::DoRelease()
 	{
-	SQL_TRACE_BLOB(OstTraceExt2(TRACE_INTERNALS, HBLOBBUF_DORELEASE_ENTRY, "Entry;0x%X;HBlobBuf::DoRelease;sqlite3_blob*=0x%X", (TUint)this, (TUint)iBlobHandle));
-	TRAPD(err, DoSynchL());
-	SQL_TRACE_BLOB(OstTraceExt2(TRACE_INTERNALS, HBLOBBUF_DORELEASE_EXIT, "Exit;0x%X;HBlobBuf::DoRelease;err=%d", (TUint)this, err));
-    UNUSED_VAR(err);
-    }
+	TRAP_IGNORE(DoSynchL());
+	}
 	
 /**
 Closes the blob handle.
@@ -135,7 +120,6 @@
 	if(iBlobHandle)
 		{
 		TInt err = sqlite3_blob_close(iBlobHandle);
-		SQL_TRACE_BLOB(OstTraceExt2(TRACE_INTERNALS, HBLOBBUF_DOSYNCHL, "0x%X;HBlobBuf::DoSynchL;err=%d", (TUint)this, err));
 		iBlobHandle = NULL; // the close is unconditional, even if an error occurs
 		__SQLLEAVE_IF_ERROR(::Sql2OsErrCode(err, sqlite3SymbianLastOsError()));
 		}	
@@ -161,11 +145,9 @@
 */
 TInt HBlobBuf::DoReadL(TAny* aPtr, TInt aMaxLength)
 	{
-	__ASSERT_DEBUG(aPtr != NULL, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aMaxLength >= 0, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(iBlobHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));
-	
-	SQL_TRACE_BLOB(OstTraceExt5(TRACE_INTERNALS, HBLOBBUF_DOREADL, "0x%X;HBlobBuf::DoReadL;aMaxLength=%d;iBlobSize=%d;iWrPos=%d;iRdPos=%d", (TUint)this, aMaxLength, iBlobSize, iWrPos, iRdPos));
+	__SQLASSERT(aPtr != NULL, ESqlPanicBadArgument);
+	__SQLASSERT(aMaxLength >= 0, ESqlPanicBadArgument);
+	__SQLASSERT(iBlobHandle != NULL, ESqlPanicInvalidObj);
 	
 	if(aMaxLength <= 0)
 		{
@@ -206,11 +188,9 @@
 */
 void HBlobBuf::DoWriteL(const TAny* aPtr, TInt aLength)
 	{
-	__ASSERT_DEBUG(aPtr != NULL, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(aLength >= 0, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(iBlobHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));
-	
-	SQL_TRACE_BLOB(OstTraceExt5(TRACE_INTERNALS, HBLOBBUF_DOWRITEL, "0x%X;HBlobBuf::DoWriteL;aLength=%d;iBlobSize=%d;iWrPos=%d;iRdPos=%d", (TUint)this, aLength, iBlobSize, iWrPos, iRdPos));
+	__SQLASSERT(aPtr != NULL, ESqlPanicBadArgument);
+	__SQLASSERT(aLength >= 0, ESqlPanicBadArgument);
+	__SQLASSERT(iBlobHandle != NULL, ESqlPanicInvalidObj);
 	
 	if(aLength <= 0)
 		{
@@ -247,10 +227,9 @@
 */
 TStreamPos HBlobBuf::DoSeekL(MStreamBuf::TMark aMark, TStreamLocation aLocation, TInt aOffset)
 	{
-	SQL_TRACE_BLOB(OstTraceExt5(TRACE_INTERNALS, HBLOBBUF_DOSEEKL, "0x%X;HBlobBuf::DoSeekL;aMark=%d;aLocation=%d;aOffset=%d;iBlobSize=%d", (TUint)this, (TInt)aMark, (TInt)aLocation, aOffset, iBlobSize));
-	__ASSERT_ALWAYS(!(aMark & ~(ERead | EWrite)), __SQLPANIC(ESqlPanicStreamMarkInvalid));
-	__ASSERT_DEBUG(aOffset >= 0, __SQLPANIC(ESqlPanicBadArgument));
-	__ASSERT_DEBUG(iBlobHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));
+	__SQLASSERT_ALWAYS(!(aMark & ~(ERead | EWrite)), ESqlPanicStreamMarkInvalid);
+	__SQLASSERT(aOffset >= 0, ESqlPanicBadArgument);
+	__SQLASSERT(iBlobHandle != NULL, ESqlPanicInvalidObj);
 	
 	TInt newPos = 0;
 	switch(aLocation)
@@ -265,7 +244,7 @@
 		newPos = iBlobSize + aOffset;
 		break;
 	default:
-		__ASSERT_DEBUG(0, __SQLPANIC(ESqlPanicStreamLocationInvalid));
+		__SQLASSERT(0, ESqlPanicStreamLocationInvalid);
 		newPos = -1;
 		break;
 		}