Revision: 201017 RCL_3 PDK_3.0.i
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 18:25:57 +0300
branchRCL_3
changeset 16 6b6fd149daa2
parent 13 211563e4b919
child 20 04ec7606545c
Revision: 201017 Kit: 201017
persistentstorage/centralrepository/cenrepsrv/install.cpp
persistentstorage/sql/GROUP/BLD.INF
persistentstorage/sql/GROUP/sqltests.bat
persistentstorage/sql/GROUP/sqltests.iby
persistentstorage/sql/GROUP/t_sqlsecurity6.mmp
persistentstorage/sql/OsLayer/os_symbian.cpp
persistentstorage/sql/SRC/Common/SqlAssert.h
persistentstorage/sql/SRC/Common/SqlSrvStartup.h
persistentstorage/sql/SRC/Common/SqlUtil.cpp
persistentstorage/sql/SRC/Server/SqlSrvAuthorizer.cpp
persistentstorage/sql/SRC/Server/SqlSrvSession.cpp
persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp
persistentstorage/sql/SRC/Server/SqlSrvUtil.cpp
persistentstorage/sql/TEST/t_sqlapi.cpp
persistentstorage/sql/TEST/t_sqlapi2.cpp
persistentstorage/sql/TEST/t_sqlattach.cpp
persistentstorage/sql/TEST/t_sqlbadclient.cpp
persistentstorage/sql/TEST/t_sqlblob.cpp
persistentstorage/sql/TEST/t_sqlbur.cpp
persistentstorage/sql/TEST/t_sqlcompact2.cpp
persistentstorage/sql/TEST/t_sqlconfigfile.cpp
persistentstorage/sql/TEST/t_sqldbconfigfile.cpp
persistentstorage/sql/TEST/t_sqldefect.cpp
persistentstorage/sql/TEST/t_sqlenvcreate.cpp
persistentstorage/sql/TEST/t_sqlenvdestroy.cpp
persistentstorage/sql/TEST/t_sqlfilebuf64.cpp
persistentstorage/sql/TEST/t_sqlfserr.cpp
persistentstorage/sql/TEST/t_sqlload.cpp
persistentstorage/sql/TEST/t_sqloom5.cpp
persistentstorage/sql/TEST/t_sqlsecurity6.cpp
persistentstorage/sql/TEST/t_sqlstartup.cpp
--- a/persistentstorage/centralrepository/cenrepsrv/install.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/centralrepository/cenrepsrv/install.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-2010 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"
@@ -434,11 +434,7 @@
 void CCentRepSWIWatcher::ReadAndInternalizeInstallDirL(const TDesC& aInstallDirFilePath)
 	{
 	RFile file;
-	TInt e=file.Open(TServerResources::iFs,aInstallDirFilePath, EFileRead|EFileShareReadersOnly);
-	if(e == KErrNotFound || e == KErrPathNotFound)
-		{
-		User::Leave(KErrNotFound);
-		}
+	User::LeaveIfError(file.Open(TServerResources::iFs,aInstallDirFilePath, EFileRead|EFileShareReadersOnly));
 	CleanupClosePushL(file);
 
 	CDirectFileStore* store = CDirectFileStore::FromLC (file);
--- a/persistentstorage/sql/GROUP/BLD.INF	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/GROUP/BLD.INF	Tue Apr 27 18:25:57 2010 +0300
@@ -76,6 +76,7 @@
 t_sqlsecurity3.mmp
 t_sqlsecurity4.mmp
 t_sqlsecurity5.mmp
+t_sqlsecurity6.mmp
 t_sqlattach.mmp
 #ifndef WINS //hardware only
 t_sqlattach2.mmp manual
--- a/persistentstorage/sql/GROUP/sqltests.bat	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/GROUP/sqltests.bat	Tue Apr 27 18:25:57 2010 +0300
@@ -36,6 +36,7 @@
 T_SQLSECURITY3.EXE
 T_SQLSECURITY4.EXE
 T_SQLSECURITY5.EXE
+T_SQLSECURITY6.EXE
 T_SQLATTACH.EXE
 T_SQLPERFORMANCE.EXE
 T_SQLPERFORMANCE2.EXE
--- a/persistentstorage/sql/GROUP/sqltests.iby	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/GROUP/sqltests.iby	Tue Apr 27 18:25:57 2010 +0300
@@ -80,6 +80,7 @@
 file=ABI_DIR\BUILD_DIR\T_SQLSECURITY3.EXE	\TEST\T_SQLSECURITY3.EXE
 file=ABI_DIR\BUILD_DIR\T_SQLSECURITY4.EXE	\TEST\T_SQLSECURITY4.EXE
 file=ABI_DIR\BUILD_DIR\T_SQLSECURITY5.EXE	\TEST\T_SQLSECURITY5.EXE
+file=ABI_DIR\BUILD_DIR\T_SQLSECURITY6.EXE	\TEST\T_SQLSECURITY6.EXE
 file=ABI_DIR\BUILD_DIR\T_SQLATTACH.EXE		\TEST\T_SQLATTACH.EXE
 file=ABI_DIR\BUILD_DIR\T_SQLATTACH2.EXE		\TEST\T_SQLATTACH2.EXE
 file=ABI_DIR\BUILD_DIR\T_SQLPERFORMANCE.EXE	\TEST\T_SQLPERFORMANCE.EXE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/persistentstorage/sql/GROUP/t_sqlsecurity6.mmp	Tue Apr 27 18:25:57 2010 +0300
@@ -0,0 +1,35 @@
+// Copyright (c) 2010 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+TARGET			t_sqlsecurity6.exe
+TARGETTYPE		EXE
+CAPABILITY		WriteUserData ReadUserData
+
+USERINCLUDE 	.
+OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+
+SOURCEPATH		../TEST
+SOURCE			t_sqlsecurity6.cpp
+
+LIBRARY			euser.lib 
+LIBRARY			efsrv.lib
+LIBRARY			sqldb.lib 
+LIBRARY			bafl.lib 
+LIBRARY 		estor.lib 
+
+UID				0 0x00009876
+VENDORID		0x70000001
+
+SMPSAFE
\ No newline at end of file
--- a/persistentstorage/sql/OsLayer/os_symbian.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/OsLayer/os_symbian.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -84,6 +84,10 @@
 	EPanicFastCounterFreq		=21
 	};
 
+//Bit-mask constant. If xOpen()'s "aFlag" parameter contains one of these bits set, then the the file top be
+//opened or created is a journal file.
+const TUint KJournalFileTypeBitMask = SQLITE_OPEN_MAIN_JOURNAL | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_MASTER_JOURNAL; 
+
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1218,8 +1222,9 @@
 		{
 		wchar_t* dest = reinterpret_cast <wchar_t*> (const_cast <TUint16*> (aFileNameDestBuf.Ptr()));
 		TInt len = mbstowcs(dest, aFileName, aFileNameDestBuf.MaxLength());
+		__ASSERT_DEBUG(len >= 0, User::Panic(KPanicCategory, EPanicInternalError));
 		//If len == aFileNameDestBuf.MaxLength(), then the output buffer is too small.
-		if(len > 0 && len < aFileNameDestBuf.MaxLength())
+		if(len < aFileNameDestBuf.MaxLength())
 			{
 			aFileNameDestBuf.SetLength(len);
 			return ETrue;
@@ -1246,8 +1251,9 @@
 	char* dest = reinterpret_cast <char*> (const_cast <TUint8*> (aFileNameDestBuf.Ptr()));
 	const wchar_t* src = reinterpret_cast <const wchar_t*> (aFileName.Ptr());
 	TInt len = wcstombs(dest, src, aFileNameDestBuf.MaxLength());
+	__ASSERT_DEBUG(len >= 0, User::Panic(KPanicCategory, EPanicInternalError));
 	//If len == aFileNameDestBuf.MaxLength(), then the output buffer is too small.
-	if(len > 0 && len < aFileNameDestBuf.MaxLength())
+	if(len < aFileNameDestBuf.MaxLength())
 		{
 		aFileNameDestBuf.SetLength(len);
 		return ETrue;
@@ -2005,38 +2011,35 @@
 		{
 		deviceCharacteristics |= SQLITE_IOCAP_ATOMIC;	
 		}
-	if(aVolumeInfo.iBlockSize >= SQLITE_DEFAULT_SECTOR_SIZE && (aVolumeInfo.iBlockSize & (aVolumeInfo.iBlockSize - 1)) == 0)	
+	switch(aVolumeInfo.iBlockSize)
 		{
-		switch(aVolumeInfo.iBlockSize)
-			{
-			case 512:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC512;
-				break;
-			case 1024:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC1K;
-				break;
-			case 2048:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC2K;
-				break;
-			case 4096:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC4K;
-				break;
-			case 8192:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC8K;
-				break;
-			case 16384:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC16K;
-				break;
-			case 32768:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC32K;
-				break;
-			case 65536:
-				deviceCharacteristics |= SQLITE_IOCAP_ATOMIC64K;
-				break;
-			default:
-				//Do nothing. deviceCharacteristics was initialized with 0 at the beginning of the function body.
-				break;
-			}
+		case 512:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC512;
+			break;
+		case 1024:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC1K;
+			break;
+		case 2048:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC2K;
+			break;
+		case 4096:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC4K;
+			break;
+		case 8192:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC8K;
+			break;
+		case 16384:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC16K;
+			break;
+		case 32768:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC32K;
+			break;
+		case 65536:
+			deviceCharacteristics |= SQLITE_IOCAP_ATOMIC64K;
+			break;
+		default:
+			//Do nothing. deviceCharacteristics was initialized with 0 at the beginning of the function body.
+			break;
 		}
 	return deviceCharacteristics;
 	}
@@ -2287,8 +2290,7 @@
 				__FS_CALL(EFsOpFileOpen, 0);
 				err = dbFile.iFileBuf.Open(osLayerData.iFs, fname, fmode);
 				
-				if(err == KErrNone && ((aFlags & SQLITE_OPEN_MAIN_JOURNAL) || (aFlags & SQLITE_OPEN_TEMP_JOURNAL) || 
-                        (aFlags & SQLITE_OPEN_SUBJOURNAL) || (aFlags & SQLITE_OPEN_MASTER_JOURNAL)))
+				if(err == KErrNone && (aFlags & KJournalFileTypeBitMask))
 				    {
                     err = TVfs::DoFileSizeCorruptionCheck(dbFile, fname, fmode);
 				    }
@@ -2338,8 +2340,7 @@
 		(void)dbFile.iFileBuf.SetReadAheadSize(dbFile.iSectorSize, recReadBufSize);
 		}
 #ifdef _SQLPROFILER
-	dbFile.iIsJournal = (aFlags & SQLITE_OPEN_MAIN_JOURNAL) || (aFlags & SQLITE_OPEN_TEMP_JOURNAL) || 
-						(aFlags & SQLITE_OPEN_SUBJOURNAL) || (aFlags & SQLITE_OPEN_MASTER_JOURNAL);
+	dbFile.iIsJournal = aFlags & KJournalFileTypeBitMask; 
 #endif
 	return err == KErrNone ? SQLITE_OK : (err == KErrNoMemory ? SQLITE_IOERR_NOMEM : SQLITE_CANTOPEN);
 	}
--- a/persistentstorage/sql/SRC/Common/SqlAssert.h	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Common/SqlAssert.h	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 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"
@@ -46,7 +46,7 @@
 	static TInt Assert(const TText* aFile, TInt aLine, TInt aPanicCode);
 	static void Leave(const TText* aFile, TInt aLine, TInt aError);
 	static TInt LeaveIfError(const TText* aFile, TInt aLine, TInt aError);
-	static void* LeaveIfNull(const TText* aFile, TInt aLine, void* aPtr);
+	static const void* LeaveIfNull(const TText* aFile, TInt aLine, const void* aPtr);
 	static TInt PanicClientL(const TText* aFile, TInt aLine, const RMessage2& aMessage, TInt aPanicCode);
 	static void ErrorPrint(const TDesC& aMsg, TInt aErr);
 	static void ErrorPrint(const TDesC& aMsg, const TDesC& aStr);
--- a/persistentstorage/sql/SRC/Common/SqlSrvStartup.h	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Common/SqlSrvStartup.h	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 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"
@@ -31,11 +31,6 @@
 
 const TUid KSqlSrvUid3 = {0x10281E17};//The same UID is in SqlSrv.mmp file
 
-//Stack, Min & Max server heap size
-const TInt KSqlSrvStackSize =   0x10000;	// 64K
-const TInt KSqlSrvMinHeapSize = 0x1000;		//  4K
-const TInt KSqlSrvMaxHeapSize = 0x400000;	//  4M
-
 /**
 @return SQL server version.
 
--- a/persistentstorage/sql/SRC/Common/SqlUtil.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Common/SqlUtil.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 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"
@@ -274,7 +274,7 @@
 
 @internalComponent
 */	
-void* Util::LeaveIfNull(const TText* aFile, TInt aLine, void* aPtr)
+const void* Util::LeaveIfNull(const TText* aFile, TInt aLine, const void* aPtr)
 	{
 	if(!aPtr)
 		{
--- a/persistentstorage/sql/SRC/Server/SqlSrvAuthorizer.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Server/SqlSrvAuthorizer.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 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"
@@ -279,8 +279,6 @@
 		case SQLITE_DETACH://                Database Name   NULL
 		case SQLITE_REINDEX://				 Index Name      NULL
 		case SQLITE_ANALYZE://				 Table Name      NULL
-		case SQLITE_CREATE_VTABLE:
-		case SQLITE_DROP_VTABLE:
 		case SQLITE_FUNCTION:
 			break;
 		case SQLITE_PRAGMA://                Pragma Name     1st arg or NULL 
@@ -295,7 +293,10 @@
 //      case SQLITE_DROP_TEMP_INDEX://       Index Name      Table Name      
 //      case SQLITE_DROP_TEMP_TABLE://       Table Name      NULL            
 //      case SQLITE_DROP_TEMP_TRIGGER://     Trigger Name    Table Name      
-//      case SQLITE_DROP_TEMP_VIEW://        View Name       NULL            
+//      case SQLITE_DROP_TEMP_VIEW://        View Name       NULL
+//"CREATE VIRTUAL TABLE" and "DROP VIRTUAL TABLE" sql statements are not supported
+//		case SQLITE_CREATE_VTABLE:
+//		case SQLITE_DROP_VTABLE:
 		default:
 			__SQLASSERT(EFalse, ESqlPanicInternalError);
 			break;
@@ -410,10 +411,6 @@
 		case SQLITE_REINDEX://				Index Name      NULL
 		case SQLITE_ANALYZE://				Table Name      NULL
 			break;
-		case SQLITE_CREATE_VTABLE:
-		case SQLITE_DROP_VTABLE:
-			__SQLASSERT(EFalse, ESqlPanicInternalError);
-			res = SQLITE_DENY;	
 		//No policy check
 		case SQLITE_FUNCTION:
 			break;
@@ -427,6 +424,9 @@
 //      case SQLITE_DROP_TEMP_TABLE://       Table Name      NULL            
 //      case SQLITE_DROP_TEMP_TRIGGER://     Trigger Name    Table Name      
 //      case SQLITE_DROP_TEMP_VIEW://        View Name       NULL            
+//"CREATE VIRTUAL TABLE" and "DROP VIRTUAL TABLE" sql statements are not supported
+//		case SQLITE_CREATE_VTABLE:
+//		case SQLITE_DROP_VTABLE:
 		default:
 			__SQLASSERT(EFalse, ESqlPanicInternalError);
 			break;
--- a/persistentstorage/sql/SRC/Server/SqlSrvSession.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Server/SqlSrvSession.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1200,16 +1200,16 @@
 @return The blob stream handle
 
 @leave KErrNoMemory, 		 An out of memory condition has occurred;
-	   KErrArgument, 		 The IPC data buffer length is invalid, or the ROWID is invalid,
-	   				 		 or UTF-16 to UTF-8 string conversion failed;	
+	   KErrArgument, 		 The ROWID is invalid or UTF-16 to UTF-8 string conversion failed;	
 	   KErrBadDescriptor 	 The transferred data is bigger than the specified length;
 	   KErrBadName,	 		 The table name, column name or database name has an invalid length;
        KErrPermissionDenied, The client does not have the required security capabilites for this operation; 						 
        						 Note that the function may also leave with some other system wide errors or 
                      		 database specific errors categorised as ESqlDbError.
 
-@panic SqlDb 2 Client panic. The database object is not yet created (iDatabase is NULL)
-@panic SqlDb 3 Client panic. Failed to create a blob stream handle
+@panic SqlDb 2 Client panic. The database object is not yet created (iDatabase is NULL).
+@panic SqlDb 3 Client panic. Failed to create a blob stream handle.
+@panic SqlDb 4 Client panic. IPC buffer length is 0.
 
 Usage of the IPC call arguments:
 Arg 0: [in]	    The length of the IPC data buffer
@@ -1220,13 +1220,11 @@
 	{	
 	__SQLPANIC_CLIENT(iDatabase != NULL, aMessage, ESqlPanicInvalidObj);
 	
+	TInt ipcPrmLen = aMessage.Int0();
+	__SQLPANIC_CLIENT(ipcPrmLen > 0, aMessage, ESqlPanicBadArgument);
+	
 	iIpcStreams.AllocL();
 	
-	TInt ipcPrmLen = aMessage.Int0();
-	if(ipcPrmLen < 1)
-		{
-		__SQLLEAVE(KErrArgument);
-		}
 	TDes8& ipcPrmDes = ReadString8ZL(aMessage, 1, ipcPrmLen);
 	RDesReadStream strm(ipcPrmDes);
 	
--- a/persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -423,15 +423,21 @@
 // - aHasTail is true (possibly more than one SQL statement, separated with ";");
 // - aStmtHandle is NULL;
 //
-static TInt ProcessPrepareError(TInt aSqliteError, TBool aHasTail, sqlite3_stmt* aStmtHandle)
+static TInt ProcessPrepareError(TInt aSqliteError, TBool aHasTail, sqlite3_stmt*& aStmtHandle)
 	{
 	if(aSqliteError != SQLITE_OK)
 		{
 		return ::Sql2OsErrCode(aSqliteError, sqlite3SymbianLastOsError());
 		}
 	else if(aHasTail || !aStmtHandle)
-		{//More than one SQL statement or the SQL string is "" or ";;;" or ";   ;; ;". 
-		 //Report it as an error, because there is no statement handle.
+		{//Case 1:
+		 // More than one SQL statement or the SQL string is "" or ";;;" or ";   ;; ;". 
+		 // Report it as an error, because there is no statement handle.
+		 //Case 2:
+		 // Non-null aHasTail. In this case the SQL string contains more than one SQL statement.
+		 // The statement handle is not null. The statement has to be finialized before reporting the error.
+		(void)FinalizeStmtHandle(aStmtHandle);
+		aStmtHandle = NULL;
 		return KErrArgument;
 		}
 	return KErrNone;
--- a/persistentstorage/sql/SRC/Server/SqlSrvUtil.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/SRC/Server/SqlSrvUtil.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 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"
@@ -147,10 +147,6 @@
 	{
 	__SQLASSERT(aIn.Length() <= KMaxFileName, ESqlPanicBadArgument);
 	__SQLASSERT(aOut.MaxLength() >= KMaxFileName, ESqlPanicBadArgument);
-	if(aIn.Length() > KMaxFileName || aOut.MaxLength() < KMaxFileName)
-		{
-		return EFalse;	
-		}
 	TBuf16<KMaxFileName + 1> des;
 	des.Copy(aIn);
 	des.Append(TChar(0));
--- a/persistentstorage/sql/TEST/t_sqlapi.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlapi.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -780,6 +780,7 @@
 _LIT8(KStmt19, "INSERT INTO BBB(Fld1, Fld2, Fld3, Fld4, Fld5, Fld6)\
 	                                       VALUES(:V1, :V2, :V3, :V4, :V5, :V6)");
 _LIT8(KStmt20, "SELECT * FROM BBB");
+_LIT8(KStmt21, "SELECT fld1, fld2 FROM AAA;SELECT fld1, fld2 FROM AAA");
 
 /**
 @SYMTestCaseID			SYSLIB-SQL-CT-1606
@@ -812,6 +813,10 @@
 	ExecSqlStmt(db, stmt, KErrNone);
 	stmt.Close();
 
+	//String containg more than one SQL statement.
+	stmt = PrepareSqlStmt<DES, BUF>(db, KStmt21, KErrArgument); 
+	stmt.Close();
+	
 	//SQL statement without parameters. Insert a record into the table.
 	stmt = PrepareSqlStmt<DES, BUF>(db, KStmt13, KErrNone);
 	ExecSqlStmt(db, stmt, KErrNone);
--- a/persistentstorage/sql/TEST/t_sqlapi2.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlapi2.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1697,6 +1697,74 @@
 		}
 	}
 
+/**
+@SYMTestCaseID			PDS-SQL-CT-4198
+@SYMTestCaseDesc		Expired SQL statements test.
+						The test creates a database and opens 2 connections to that database.
+						Connection 2 prepares couple of SELECT and INSERT statements (8-bit and 16-bit).
+						Then connection 1 renames the table used in the already prepared statements.
+						Connection 2 attempts to execute the prepared statements. The execution should fail
+						because the statements are expired, the database schema has changed after they 
+						were prepared.
+@SYMTestActions			Expired SQL statements test.
+@SYMTestExpectedResults Test must not fail
+@SYMTestPriority		High
+@SYMDEF					DEF145236
+*/
+void ExpiredStmtTest()
+	{
+	(void)RSqlDatabase::Delete(KTestDbName1);
+	//Create a database and create db connection 1.
+	TInt err = TheDb.Create(KTestDbName1);
+	TEST2(err, KErrNone);
+	err = TheDb.Exec(_L("CREATE TABLE A(C1 INTEGER)"));
+	TEST(err >= 0);
+	err = TheDb.Exec(_L("INSERT INTO A(C1) VALUES(1)"));
+	TEST2(err, 1);
+	
+	//Create db connection 2 to the same database, as db connection 1.
+	RSqlDatabase db2;
+	err = db2.Open(KTestDbName1);
+	TEST2(err, KErrNone);
+	
+	//Db connection 2. Prepare SELECT and INSERT, 8-bit and 16-bit statements. 
+	RSqlStatement stmt1, stmt2, stmt3, stmt4;
+	err = stmt1.Prepare(db2, _L("SELECT * FROM A"));
+	TEST2(err, KErrNone);
+	err = stmt2.Prepare(db2, _L8("SELECT * FROM A"));
+	TEST2(err, KErrNone);
+	err = stmt3.Prepare(db2, _L("INSERT INTO A(C1) VALUES(2)"));
+	TEST2(err, KErrNone);
+	err = stmt4.Prepare(db2, _L8("INSERT INTO A(C1) VALUES(3)"));
+	TEST2(err, KErrNone);
+	
+	//Modify the A table structure from the other connection
+	//err = TheDb.Exec(_L("ALTER TABLE A ADD C2 INTEGER"));
+	err = TheDb.Exec(_L("ALTER TABLE A RENAME TO B"));
+	TEST(err >= 0);
+	
+	//Try to execute the already prepared statements.
+	err = stmt1.Next();
+	TEST2(err, KSqlErrSchema);
+	err = stmt1.Next();
+	TEST2(err, KSqlErrStmtExpired);
+	err = stmt2.Next();
+	TEST2(err, KSqlErrStmtExpired);
+	err = stmt3.Exec();
+	TEST2(err, KSqlErrStmtExpired);
+	err = stmt4.Exec();
+	TEST2(err, KSqlErrStmtExpired);
+	//
+	stmt4.Close();
+	stmt3.Close();
+	stmt2.Close();
+	stmt1.Close();
+	db2.Close();
+	TheDb.Close();
+	err = RSqlDatabase::Delete(KTestDbName1);
+	TEST2(err, KErrNone);
+	}
+
 void DoTestsL()
 	{
 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3512 RSqlStatement::ColumnCount() tests "));
@@ -1735,6 +1803,8 @@
 	ProfilerTest();
 	TheTest.Next( _L(" Compound SELECT, stack overflow test"));
 	CompoundSelectStackOverflowTest();
+	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4198 Expired statements test"));
+	ExpiredStmtTest();
 	}
 
 TInt E32Main()
--- a/persistentstorage/sql/TEST/t_sqlattach.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlattach.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -333,11 +333,8 @@
 	TEST2(err, KErrPermissionDenied);
 
 	//Attempt to detach database using DETACH sql statement directly.
-	//Executed only in release mode because the server will panic in _DEBUG mode
-#ifndef _DEBUG	
 	err = TheDb.Exec(_L("DETACH DATABASE DB2"));
 	TEST2(err, KErrPermissionDenied);
-#endif	
 		
 	err = TheDb.Detach(KAttachDb2);
 	TEST2(err, KErrNone);	
--- a/persistentstorage/sql/TEST/t_sqlbadclient.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlbadclient.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 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"
@@ -18,6 +18,7 @@
 #include <e32math.h>
 #include <sqldb.h>
 #include "SqlUtil.h"
+#include "SqlSrvStartup.h" //KSqlMajorVer, KSqlMinorVer, KSqlBuildVer
 
 ///////////////////////////////////////////////////////////////////////////////////////
 
@@ -172,18 +173,18 @@
 class RTestSqlDbSession : public RSessionBase
 	{
 public:	
-	TInt Connect();
+	TInt Connect(const TVersion& aVersion);
 	void Close();
 	TInt SendReceive(TInt aFunction);
 	TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs);
 
 private:
-	TInt DoCreateSession();
+	TInt DoCreateSession(const TVersion& aVersion);
 	};
 	
-TInt RTestSqlDbSession::Connect()
+TInt RTestSqlDbSession::Connect(const TVersion& aVersion)
 	{
-	TInt err = DoCreateSession();
+	TInt err = DoCreateSession(aVersion);
 	if(err == KErrNone)
 		{
 		TIpcArgs ipcArgs(KTestDbName1().Length(), &KTestDbName1(), 0, 0);
@@ -215,18 +216,14 @@
 	return RSessionBase::SendReceive(aFunction, aArgs);	
 	}
 
-TInt RTestSqlDbSession::DoCreateSession()
+TInt RTestSqlDbSession::DoCreateSession(const TVersion& aVersion)
 	{
 	const TInt KTimesToRetryConnection = 2;
 	TInt retry = KTimesToRetryConnection;
 	_LIT(KSqlSrvName, "!SQL Server");//SqlDb server name
-	//SQL server: major version number, minor version number, build number constants.
-	const TInt KSqlMajorVer = 1;
-	const TInt KSqlMinorVer = 1;
-	const TInt KSqlBuildVer = 0;
 	for(;;)
 		{
-		TInt err = CreateSession(KSqlSrvName, TVersion(KSqlMajorVer, KSqlMinorVer, KSqlBuildVer));
+		TInt err = CreateSession(KSqlSrvName, aVersion);
 		if(err != KErrNotFound && err != KErrServerTerminated)
 			{
 			return err;
@@ -286,8 +283,9 @@
 	TTEST(p != NULL);
 	TThreadData& data = *p;
 
+	TVersion sqlSoftwareVersion(KSqlMajorVer, KSqlMinorVer, KSqlBuildVer);
 	RTestSqlDbSession sess;
-	TInt err = sess.Connect();
+	TInt err = sess.Connect(sqlSoftwareVersion);
 	TTEST2(err, KErrNone);
 
 	while(++data.iIteration <= KTestIterCount)
@@ -595,13 +593,62 @@
 	TheTest.Printf(_L("Delete database-2, err=%d\r\n"), err);
 	TEST(err != KErrNone);
 	}
+
+/**
+@SYMTestCaseID          PDS-SQL-CT-4200
+@SYMTestCaseDesc        Invalid sql software version test.
+@SYMTestPriority        High
+@SYMTestActions			The test verifies that the SQL server checks that the software version of SQL sessions
+						to be created is less or equal to the current version of the server software. 
+						If that is not true then the SQL server does not create the session annd returns KErrNotSupported.
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF145236
+*/  
+void InvalidSoftwareVersionTest()
+	{
+	(void)RSqlDatabase::Delete(KTestDbName1);
+	RSqlDatabase db;
+	TInt err = db.Create(KTestDbName1);
+	TEST2(err, KErrNone);
+	db.Close();
 	
+	//Smaller version number
+	TVersion sqlSoftwareVersion1(1, 0, 0);
+	RTestSqlDbSession sess1;
+	err = sess1.Connect(sqlSoftwareVersion1);
+	sess1.Close();
+	TEST2(err, KErrNone);
+	
+	//Bigger version number 1
+	TVersion sqlSoftwareVersion2(1, 97, 3);
+	RTestSqlDbSession sess2;
+	err = sess2.Connect(sqlSoftwareVersion2);
+	TEST2(err, KErrNotSupported);
+	
+	//Bigger version number 2
+	TVersion sqlSoftwareVersion3(78, 0, 1);
+	RTestSqlDbSession sess3;
+	err = sess3.Connect(sqlSoftwareVersion3);
+	TEST2(err, KErrNotSupported);
+
+	//The current version number
+	TVersion sqlSoftwareVersion4(KSqlMajorVer, KSqlMinorVer, KSqlBuildVer);
+	RTestSqlDbSession sess4;
+	err = sess4.Connect(sqlSoftwareVersion4);
+	sess4.Close();
+	TEST2(err, KErrNone);
+	
+	(void)RSqlDatabase::Delete(KTestDbName1);
+	}
+
 void DoTests()
 	{
 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1769 Bad client test "));
 	BadClientTest();
 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4048 Bad names test"));
 	BadNameTest();
+	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4200 Invalid software version test"));
+	InvalidSoftwareVersionTest();
 	}
 
 TInt E32Main()
--- a/persistentstorage/sql/TEST/t_sqlblob.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlblob.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2010 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"
@@ -1959,6 +1959,92 @@
 	CleanupStack::PopAndDestroy(2, blobWrBuf); // buf, blobWrBuf
 	}
 	
+/**
+@SYMTestCaseID          PDS-SQL-CT-4194
+@SYMTestCaseDesc        The test opens a test database, creates a table with a blob column and inserts one record.
+						Then the test uses RSqlBlobWriteStream to modify the blob column content.
+                        MStreamBuf::SeekL() is used to modify the blob data at specific positions.
+                        Then the test uses RSqlBlobReadStream object to read the just written blob data.
+                        MStreamBuf::SeekL() is used to read the column content at specific positions 
+                        (the same positions used during the blob write operation). The read byte values must
+                        match the written byte values.
+@SYMTestPriority        High
+@SYMTestActions         RSqlBlobReadStream and RSqlBlobWriteStream - MStreamBuf::SeekL() test.
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF145028
+*/  
+void StreamSeekTestL()
+	{
+    TInt rc = TheDb1.Exec(_L("CREATE TABLE A(Fld1 INTEGER, Fld2 BLOB)"));
+    TEST(rc >= 0);
+    
+    //Write a record to the database using a blob stream. MStreamBuf::SeekL() is used to modify the content at a specific position.
+    rc = TheDb1.Exec(_L("INSERT INTO A(Fld1, Fld2) VALUES(1, zeroblob(256))"));
+    TEST2(rc, 1);
+    RSqlBlobWriteStream strm1;
+    CleanupClosePushL(strm1);
+    strm1.OpenL(TheDb1, _L("A"), _L("Fld2"));
+    for(TInt i=0;i<256;++i)
+        {
+        strm1 << (TUint8)i;
+        }
+    
+    const TInt KStreamOffset = 10;
+    const TUint8 KByte = 'z';
+    _LIT8(KData, "QWERTYUIOPASDFG");
+    
+    MStreamBuf* strm1buf = strm1.Sink();
+    TEST(strm1buf != NULL);
+    
+    strm1buf->SeekL(MStreamBuf::EWrite, EStreamBeginning, 0);
+    strm1buf->WriteL(&KByte, 1);
+    
+    strm1buf->SeekL(MStreamBuf::EWrite, EStreamMark, KStreamOffset);
+    strm1buf->WriteL(&KByte, 1);
+    
+    strm1buf->SeekL(MStreamBuf::EWrite, EStreamEnd, -KData().Length());
+    strm1buf->WriteL(KData().Ptr(), KData().Length());
+    
+    strm1buf->SeekL(MStreamBuf::EWrite, EStreamEnd, -4 * KStreamOffset);
+    strm1buf->WriteL(&KByte, 1);
+    
+    strm1.CommitL();
+    CleanupStack::PopAndDestroy(&strm1);
+    
+    //Read the record using a blob stream. MStreamBuf::SeekL() is used to read the content at a specific position.
+    RSqlBlobReadStream strm2;
+    CleanupClosePushL(strm2);
+    strm2.OpenL(TheDb1, _L("A"), _L("Fld2"));
+
+    TUint8 byte = 0;
+    MStreamBuf* strm2buf = strm2.Source();
+    TEST(strm1buf != NULL);
+    
+    strm2buf->SeekL(MStreamBuf::ERead, EStreamBeginning, 0);
+    rc = strm2buf->ReadL(&byte, 1);
+    TEST2(rc, 1);
+    TEST2(byte, KByte);
+    
+    strm2buf->SeekL(MStreamBuf::ERead, EStreamMark, KStreamOffset);
+    rc = strm2buf->ReadL(&byte, 1);
+    TEST2(rc, 1);
+    TEST2(byte, KByte);
+    
+    strm2buf->SeekL(MStreamBuf::ERead, EStreamEnd, -KData().Length());
+    TUint8 buf[20];
+    rc = strm2buf->ReadL(buf, KData().Length());
+    TEST2(rc, KData().Length());
+    TPtrC8 bufptr(buf, rc);
+    TEST(bufptr == KData);
+    
+    strm2buf->SeekL(MStreamBuf::ERead, EStreamEnd, -4 * KStreamOffset);
+    rc = strm2buf->ReadL(&byte, 1);
+    TEST2(rc, 1);
+    TEST2(byte, KByte);
+    
+    CleanupStack::PopAndDestroy(&strm2);
+	}
+
 void DoTestsL()
 	{	
 	CreateTestDbs();
@@ -2015,6 +2101,9 @@
 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4114: Big blob test"));
 	BigBlobTestL();
 		
+	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4194: Blob streams. MStreamBuf::SeekL() test"));
+	StreamSeekTestL();
+		
 	DeleteTestDbs();
 	}
 
--- a/persistentstorage/sql/TEST/t_sqlbur.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlbur.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 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"
@@ -130,8 +130,13 @@
 //The SQL server would have the job to get a list of databases owned by
 //the given SID and to determine whether the backup flag is set
 //All databases that satisfy this requirement will be added to the array
-void CSqlBurTestHarness::GetBackUpListL(TSecureId /*aUid*/, RArray<TParse>& aFileList)
+void CSqlBurTestHarness::GetBackUpListL(TSecureId aUid, RArray<TParse>& aFileList)
 	{
+	if(aUid.iId == 0)
+		{//Simulates that there are no databases for backup
+		aFileList.Reset();
+		return;
+		}
 	//TheTest.Printf(_L("Getting backup file list for SID=%x\r\n"),aUid);
 	for(TInt i=0;i<KTestDbFileCnt;++i)
 		{
@@ -195,7 +200,7 @@
 	}
 
 //Reads the content of the db files and stores the content to a global memory buffer.
-//That buffer content will be sued later for  a verification of the restore process.
+//That buffer content will be used later for verification of the restore process.
 void StoreDbContentToBuf(RFs& aFs)
 	{
 	for(TInt i=0;i<KTestDbFileCnt;++i)
@@ -822,7 +827,95 @@
 
 	(void)TheTestHarness->Fs().Delete(KBackupFile2);
 	}
-			
+		
+/**
+@SYMTestCaseID			PDS-SQL-UT-4192
+@SYMTestCaseDesc		SQL Backup&Restore - empty backup file list test.
+						The test checks what will happen if the list with the files for backup is empty.
+						The GetBackupDataSectionL() should immediatelly set the flag parameter to true and do nothing.
+@SYMTestActions			SQL Backup&Restore - empty backup file list test.
+@SYMTestExpectedResults Test must not fail
+@SYMTestPriority		High
+@SYMDEF					DEF145198
+*/
+void EmptyBackupFileListTest()
+	{
+	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4192 Backup&Restore: empty backup file list"));
+	
+	CSqlBackupClient* backupClient = NULL;
+	TRAPD(err, backupClient = CSqlBackupClient::NewL(TheTestHarness));
+	TEST(backupClient != NULL);
+	
+	TRAP(err, backupClient->InitialiseGetProxyBackupDataL(KNullUid, EDriveC));
+	TEST2(err, KErrNone);
+
+	TBuf8<100> buf;
+	TPtr8 ptr((TUint8*)buf.Ptr(), 0, buf.MaxLength());
+	TBool finishedFlag = EFalse;
+	TRAP(err, backupClient->GetBackupDataSectionL(ptr, finishedFlag));
+	delete backupClient;
+	TEST2(err, KErrNone);
+	TEST(finishedFlag);
+	TEST2(buf.Length(), 0);
+	}
+
+
+/**
+@SYMTestCaseID			PDS-SQL-UT-4193
+@SYMTestCaseDesc		SQL Backup&Restore - file I/O error simulation test.
+						The test executes a backup, followed by a restore operation 
+						in a file I/O error simulation loop.
+@SYMTestActions			SQL Backup&Restore - file I/O error simulation test.
+@SYMTestExpectedResults Test must not fail
+@SYMTestPriority		High
+@SYMDEF					DEF145198
+*/
+void BackupRestoreFileIoErrTest()
+	{
+	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-UT-4193 Backup: File I/O error simulation test"));
+
+	//Make sure that the database content, just before the backup, will be copied to the test biffers.
+	//The buffers will be used during the restore testing for verification of the database content.
+	StoreDbContentToBuf(TheTestHarness->Fs());
+	
+	for(TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
+		{
+		TheTest.Printf(_L("===Backup&Restore, simulated file system error=%d\r\n"), fsError);
+		
+		TInt err = KErrGeneral;
+		TInt bytesStored = -1;
+		TInt it_cnt1 = 0;
+		for(;err<KErrNone;++it_cnt1)
+			{
+			__UHEAP_MARK;
+			(void)TheTestHarness->Fs().SetErrorCondition(fsError, it_cnt1);
+			TRAP(err, bytesStored = DoBackupL());
+			(void)TheTestHarness->Fs().SetErrorCondition(KErrNone);
+			__UHEAP_MARKEND;
+			}
+		TEST2(err, KErrNone);
+	
+		err = KErrGeneral;
+		TInt bytesRestored = -1;
+		TInt it_cnt2 = 0;
+	    for(;err<KErrNone;++it_cnt2)
+			{
+			__UHEAP_MARK;
+			(void)TheTestHarness->Fs().SetErrorCondition(fsError, it_cnt2);
+			TRAP(err, bytesRestored = DoRestoreL());
+			(void)TheTestHarness->Fs().SetErrorCondition(KErrNone);
+			__UHEAP_MARKEND;
+			}
+		TEST2(err, KErrNone);
+		
+		TEST2(bytesStored, bytesRestored);
+		CompareDbContentWithBuf(TheTestHarness->Fs());
+		
+		TheTest.Printf(_L("Backup&Restore file I/O error simulation test succeeded at backup iteration %d and restore itreration %d\r\n"), it_cnt1 - 1, it_cnt2 - 1);
+		}
+	}
+
+
 void DoMain()
 	{
 	TestEnvCreate();
@@ -837,6 +930,10 @@
 	FunctionalTest2();
 
 	LegacyFileFormatTest();
+	
+	EmptyBackupFileListTest();
+	
+	BackupRestoreFileIoErrTest();
 
 	TestEnvDestroy();
 	}
--- a/persistentstorage/sql/TEST/t_sqlcompact2.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlcompact2.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2010 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"
@@ -835,7 +835,7 @@
 			break;	
 			}
 		
-		(void)TheFs.SetErrorCondition(err, ++ioCounter);
+		(void)TheFs.SetErrorCondition(err, ioCounter++);
 
 		CSqlCompactEntry* impl = compactor->iEntries[0];
 		impl->iPageCount = freePageCount2;
--- a/persistentstorage/sql/TEST/t_sqlconfigfile.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlconfigfile.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 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"
@@ -730,7 +730,7 @@
 	TheDb.Close();
 	err = -1;
 	const TInt KTestRecCnt = 100;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{		
 		TheTest.Printf(_L("%d \r"), cnt);		
 		err = TheDb.Open(KTestDbName);
--- a/persistentstorage/sql/TEST/t_sqldbconfigfile.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqldbconfigfile.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1001,7 +1001,7 @@
 	err = KErrNotFound;
 	TInt iter = 0;
 	TheTest.Printf(_L("Iteration\r\n"));
-	for(TInt cnt = 1; !isFinished; ++cnt)
+	for(TInt cnt = 0; !isFinished; ++cnt)
 		{	
 		for(TInt fsError = KErrNotFound; fsError >= KErrUnderflow; --fsError) // errors -1 to -10 will be generated
 			{
--- a/persistentstorage/sql/TEST/t_sqldefect.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqldefect.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1394,7 +1394,7 @@
 	
 	// Begin test
 	TInt fsError = KErrGeneral;
-	TInt count = 1;
+	TInt count = 0;
 	
 	const TInt KMaxOps = 300;
 
--- a/persistentstorage/sql/TEST/t_sqlenvcreate.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlenvcreate.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 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"
@@ -12,7 +12,7 @@
 //
 // Description:
 // SQL security - copying secure test databases to C:
-// Please, ensure that t_sqlenvcreate test is executed before the other sql security tests
+// Please, ensure that t_sqlenvcreate test is executed before the other sql tests
 // 
 //
 
@@ -59,9 +59,19 @@
 _LIT(KDb8org, "z:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
 _LIT(KDb8, "c:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
 
+_LIT(KPrivateSubDir, "c:\\private\\10281e17\\TestDir.db");
+
 ///////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////
 //Test macros and functions
+static void Check(TInt aValue, TInt aLine)
+	{
+	if(!aValue)
+		{
+		RDebug::Print(_L("*** Line %d\r\n"), aLine);
+		TheTest(EFalse, aLine);
+		}
+	}
 static void Check(TInt aValue, TInt aExpected, TInt aLine)
 	{
 	if(aValue != aExpected)
@@ -70,6 +80,7 @@
 		TheTest(EFalse, aLine);
 		}
 	}
+#define TEST(arg) ::Check((arg), __LINE__)
 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -82,6 +93,11 @@
 
 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-LEGACY-T_SQLENVCREATE-0001 Copy secure databases from Z: to C: "));
 
+	//Create a subdir in the private datacage. The SQL production code should properly detects
+	//KPrivateSubDir is a directory not a database file
+	err = fs.MkDir(KPrivateSubDir);
+	TEST(err == KErrNone || err == KErrAlreadyExists);
+	
 	err = BaflUtils::CopyFile(fs, KDbZFileName1, KDbCFileName1);
 	TEST2(err, KErrNone);
 	err = fs.SetAtt(KDbCFileName1, 0, KEntryAttReadOnly);
--- a/persistentstorage/sql/TEST/t_sqlenvdestroy.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlenvdestroy.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 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"
@@ -36,6 +36,8 @@
 _LIT(KDb7, "c:\\private\\10281e17\\[98765432]t_invobject.db");
 _LIT(KDb8, "c:\\private\\10281e17\\[98765432]t_2defaultpolicies.db");
 
+_LIT(KPrivateSubDir, "c:\\private\\10281e17\\TestDir.db");
+
 ///////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////
 //Test macros and functions
@@ -83,6 +85,14 @@
 	DoDeleteFile(fs, KDb7);
 	DoDeleteFile(fs, KDb8);
 
+	//Create a subdir in the private datacage. The SQL production code should properly detects
+	//KPrivateSubDir is a directory not a database file
+	err = fs.RmDir(KPrivateSubDir);
+	if(err != KErrNone && err != KErrNotFound)
+		{
+		TheTest.Printf(_L("Error %d deleting \"%S\" directory.\n"), err, &KPrivateSubDir);
+		}
+	
 	fs.Close();
 	}
 
--- a/persistentstorage/sql/TEST/t_sqlfilebuf64.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlfilebuf64.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2009-2010 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"
@@ -30,6 +30,7 @@
 _LIT(KTestDir, "c:\\test\\");
 _LIT(KTestFile, "c:\\test\\t_sqlfilebuf64.bin");
 _LIT(KTestFile2, "\\test\\t_sqlfilebuf64_2.bin");
+_LIT(KTestFile3, "c:\\test\\t_sqlfilebuf64_3.bin");
 
 static TBuf8<1024> TheBuf;
 static TFileName TheDbName;
@@ -57,6 +58,7 @@
 		{
 		(void)TheFs.Delete(TheDbName);
 		}
+	(void)TheFs.Delete(KTestFile3);
 	(void)TheFs.Delete(KTestFile);
 	}
 
@@ -508,7 +510,7 @@
 	const TInt KBufMaxSize = 20;// This is half the file size
 	RFileBuf64 fbuf(KBufMaxSize);
 	TInt err = fbuf.Open(TheFs, KTestFile, EFileWrite | EFileRead | EFileShareReadersOrWriters);
-	TEST2(err, KErrNone); 
+	TEST2(err, KErrNone);
     fbuf.ProfilerReset();
     
 	//Zero max length request
@@ -521,7 +523,7 @@
 	TEST2(fbuf.iFileReadCount, 0);
 	TEST2(fbuf.iFileReadAmount, 0);
 	TEST2(fbuf.iFileSizeCount, 0);
-	
+
 	//Too big request
 	TBuf8<KBufMaxSize * 2> buf2;
 	err = fbuf.Read(0, buf2);
@@ -536,6 +538,30 @@
 	TEST2(err, KErrNone); 
 	TEST2(buf2.Length(), 0); 
 
+	//Write "5678" in the buffer, pos [4..8)
+	err = fbuf.Write(4, _L8("5678"));
+	TEST2(err, KErrNone); 
+
+	//Too big request. There are pending data in the buffer.
+	TBuf8<KBufMaxSize + 2> buf3;
+	err = fbuf.Read(1, buf3);
+	TEST2(err, KErrNone); 
+	VerifyFileContent(buf3, 1);
+
+	//Read from a non-zero file position to move the buffer start pos. The cached file pos will be 35 at the end.
+	TBuf8<5> buf4;
+	err = fbuf.Read(30, buf4);
+	TEST2(err, KErrNone); 
+	VerifyFileContent(buf4, 30);
+	err = fbuf.Read(35, buf4);
+	TEST2(err, KErrNone); 
+	VerifyFileContent(buf4, 35);
+
+	//Too big request. No pending data in the buffer. The file read pos is before the position of the cached data in the buffer.  
+	err = fbuf.Read(10, buf3);
+	TEST2(err, KErrNone); 
+	VerifyFileContent(buf3, 10);
+	
 	fbuf.Close();
 	}
 
@@ -981,6 +1007,113 @@
 	(void)TheFs.Delete(KTestFile);
 	}
 
+/**
+@SYMTestCaseID			PDS-SQL-UT-4195
+@SYMTestCaseDesc		RFileBuf64::Create() file I/O error simulation test.
+						The test calls RFileBuf64:Create() in a file I/O error simulation loop.
+@SYMTestActions			RFileBuf64::Create() file I/O error simulation test.
+@SYMTestExpectedResults Test must not fail
+@SYMTestPriority		High
+@SYMDEF					DEF145198
+*/
+void CreateFileIoErrTest()
+	{
+    TInt err = KErrGeneral;
+    TInt cnt = 0;
+    for(;err<KErrNone;++cnt)
+        {
+        TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
+        for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
+            {
+            TheTest.Printf(_L("%d "), fsError);
+        	__UHEAP_MARK;
+            (void)TheFs.SetErrorCondition(fsError, cnt);
+        	RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes
+        	err = fbuf.Create(TheFs, KTestFile3, EFileRead | EFileWrite);
+            (void)TheFs.SetErrorCondition(KErrNone);
+            fbuf.Close();
+            __UHEAP_MARKEND;
+			TInt err2 = TheFs.Delete(KTestFile3);
+			TInt expectedErr = err == KErrNone ? KErrNone : KErrNotFound;
+			TEST2(err2, expectedErr);
+            }
+        TheTest.Printf(_L("\r\n"));
+        }
+    TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
+	}
+
+/**
+@SYMTestCaseID			PDS-SQL-UT-4196
+@SYMTestCaseDesc		RFileBuf64::Open() file I/O error simulation test.
+						The test calls RFileBuf64:Open() in a file I/O error simulation loop.
+@SYMTestActions			RFileBuf64::Open() file I/O error simulation test.
+@SYMTestExpectedResults Test must not fail
+@SYMTestPriority		High
+@SYMDEF					DEF145198
+*/
+void OpenFileIoErrTest()
+	{
+	RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes
+	TInt err = fbuf.Create(TheFs, KTestFile3, EFileRead | EFileWrite);
+	fbuf.Close();
+	TEST2(err, KErrNone);
+    err = KErrGeneral;
+    TInt cnt = 0;
+    for(;err<KErrNone;++cnt)
+        {
+        TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
+        for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
+            {
+            TheTest.Printf(_L("%d "), fsError);
+        	__UHEAP_MARK;
+            (void)TheFs.SetErrorCondition(fsError, cnt);
+        	err = fbuf.Open(TheFs, KTestFile3, EFileRead | EFileWrite);
+            (void)TheFs.SetErrorCondition(KErrNone);
+            fbuf.Close();
+            __UHEAP_MARKEND;
+            }
+        TheTest.Printf(_L("\r\n"));
+        }
+    TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
+	(void)TheFs.Delete(KTestFile3);
+	}
+
+/**
+@SYMTestCaseID			PDS-SQL-UT-4197
+@SYMTestCaseDesc		RFileBuf64::Temp() file I/O error simulation test.
+						The test calls RFileBuf64:Temp() in a file I/O error simulation loop.
+@SYMTestActions			RFileBuf64::temp() file I/O error simulation test.
+@SYMTestExpectedResults Test must not fail
+@SYMTestPriority		High
+@SYMDEF					DEF145198
+*/
+void TempFileIoErrTest()
+	{
+    TInt err = KErrGeneral;
+    TInt cnt = 0;
+    for(;err<KErrNone;++cnt)
+        {
+        TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt);       
+        for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError)
+            {
+            TheTest.Printf(_L("%d "), fsError);
+        	__UHEAP_MARK;
+            (void)TheFs.SetErrorCondition(fsError, cnt);
+        	RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes
+        	TFileName tmpFileName;
+			err = fbuf.Temp(TheFs, KTestDir, tmpFileName, EFileWrite | EFileRead);
+            (void)TheFs.SetErrorCondition(KErrNone);
+            fbuf.Close();
+            __UHEAP_MARKEND;
+			TInt err2 = TheFs.Delete(tmpFileName);
+			TInt expectedErr = err == KErrNone ? KErrNone : KErrNotFound;
+			TEST2(err2, expectedErr);
+            }
+        TheTest.Printf(_L("\r\n"));
+        }
+    TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt);
+	}
+
 void DoTests()
 	{
 	TheTest.Start(_L(" @SYMTestCaseID:PDS-SQL-UT-4132 RFileBuf64 write test 1"));
@@ -1015,6 +1148,13 @@
 	OomTest(EOomOpenTest);
 	TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4142 RFileBuf64::Temp() OOM test"));
 	OomTest(EOomTempTest);
+	
+	TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4195 RFileBuf64::Create() file I/O error simulation test"));
+	CreateFileIoErrTest();
+	TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4196 RFileBuf64::Open() file I/O error simulation test"));
+	OpenFileIoErrTest();
+	TheTest.Next( _L(" @SYMTestCaseID:PDS-SQL-UT-4197 RFileBuf64::Temp() file I/O error simulation test"));
+	OpenFileIoErrTest();
 	}
 
 TInt E32Main()
--- a/persistentstorage/sql/TEST/t_sqlfserr.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlfserr.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 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"
@@ -165,7 +165,7 @@
 	TEST(err >= 0);
 	TheDb.Close();
 	err = KErrNotFound;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{
 		TheTest.Printf(_L("%d \r"), cnt);		
 		for (TInt fsError=KErrNotFound;fsError>=KErrDied;--fsError)
@@ -225,7 +225,7 @@
 	TEST(err >= 0);
 	TheDb.Close();
 	err = KErrNotFound;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{
 		TheTest.Printf(_L("%d \r"), cnt);		
 		for (TInt fsError=KErrNotFound;fsError>=KErrDied;--fsError)
@@ -334,7 +334,7 @@
         {	
         TheTest.Printf(_L("Database: \"%S\"\r\n"), &dbName[k]);       
         TInt err = KErrNotFound;
-        for(TInt cnt=1;err<KErrNone;++cnt)
+        for(TInt cnt=0;err<KErrNone;++cnt)
             {		
             TheTest.Printf(_L("%d \r"), cnt);		
             for (TInt fsError=KErrNotFound;fsError>=KErrDied;--fsError)
@@ -390,7 +390,7 @@
 	    {
         TheTest.Printf(_L("Database: \"%S\"\r\n"), &dbName[k]);       
         TInt err = -1;
-        for(TInt cnt=1;err<KErrNone;++cnt)
+        for(TInt cnt=0;err<KErrNone;++cnt)
             {		
             TheTest.Printf(_L("%d \r"), cnt);		
             for (TInt fsError=KErrNotFound;fsError>=KErrDied;--fsError)
@@ -442,7 +442,7 @@
         {
         TheTest.Printf(_L("Database: \"%S\"\r\n"), &dbName[k]);       
         TInt err = KErrGeneral;
-        for(TInt cnt=1;err<KErrNone;++cnt)
+        for(TInt cnt=0;err<KErrNone;++cnt)
             {
             TheTest.Printf(_L("%d \r"), cnt);       
             for(TInt fsError=KErrNotFound;fsError>=KErrDied;--fsError)
@@ -516,7 +516,7 @@
 	TEST2(err, 1);
 	TheDb.Close();
 	err = -1;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{		
 		TheTest.Printf(_L("%d \r"), cnt);		
 		err = TheDb.Open(KTestDbName);
@@ -581,7 +581,7 @@
 	TEST2(err, 1);
 	TheDb.Close();
 	err = -1;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{		
 		TheTest.Printf(_L("%d \r"), cnt);		
 		err = TheDb.Open(KTestDbName);
@@ -799,7 +799,7 @@
 	TInt rc = -1;
 	TBuf8<KMaxFileName + 1> dbFileName8;
 	dbFileName8.Copy(TheRmvMediaDbFileName);
-	for(TInt cnt=1;rc!=SQLITE_OK;++cnt)
+	for(TInt cnt=0;rc!=SQLITE_OK;++cnt)
 		{		
 		TheTest.Printf(_L("%d \r"), cnt);		
 		sqlite3* dbHandle = NULL;
@@ -900,7 +900,7 @@
 	TheDb.Close();
 	//"File I/O" error simulation loop
 	err = KErrCorrupt;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{
 		TheTest.Printf(_L("%d \r"), cnt);		
 		TEST2(TheDb.Open(KTestDbName), KErrNone);
@@ -983,7 +983,7 @@
 	TEST(size.iFree > 0);
 	//"File I/O" error simulation loop
 	err = KErrCorrupt;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{
 		TheTest.Printf(_L("%d \r"), cnt);		
 		TEST2(TheDb.Open(KTestDbName), KErrNone);
@@ -1073,7 +1073,7 @@
 	TheDb.Close();
 	
 	err = KErrCorrupt;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{
 		TheTest.Printf(_L("%d \r"), cnt);		
 		TEST2(TheDb.Open(KTestDbName), KErrNone);
@@ -1172,7 +1172,7 @@
 	TPtr8 bufptr = buf->Des();
 	
 	err = KErrCorrupt;
-	for(TInt cnt=1;err<KErrNone;++cnt)
+	for(TInt cnt=0;err<KErrNone;++cnt)
 		{
 		TheTest.Printf(_L("%d \r"), cnt);		
 		TEST2(TheDb.Open(KTestDbName), KErrNone);
--- a/persistentstorage/sql/TEST/t_sqlload.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlload.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 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"
@@ -532,10 +532,76 @@
 	CloseTestThreads(threads, statuses, KTestThreadCnt);
 	}
 
+/**
+@SYMTestCaseID          PDS-SQL-CT-4201
+@SYMTestCaseDesc        Max number of SQL statements test.
+@SYMTestPriority        High
+@SYMTestActions         The test creates a table with couple of records and then
+						creates as many as possible SQL statements. The expected result is
+						that either the statement creation process will fail with KErrNoMemory or
+						the max number of statements to be created is reached (100000).
+						Then the test deletes 1/2 of the created statements object and
+						after that attempts to execute Next() on the rest of them.
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF145236
+*/  
+void StatementMaxNumberTest()
+	{
+	(void)RSqlDatabase::Delete(KTestDbName1);
+	RSqlDatabase db;
+	TInt err = db.Create(KTestDbName1);
+	TEST2(err, KErrNone);
+	err = db.Exec(_L("CREATE TABLE A(I INTEGER); INSERT INTO A(I) VALUES(1); INSERT INTO A(I) VALUES(2);"));
+	TEST(err >= 0);
+	
+	//Reserve memory for the statement objects
+	const TInt KMaxStmtCount = 100000;
+	RSqlStatement* stmt = new RSqlStatement[KMaxStmtCount];
+	TEST(stmt != NULL);
+	TInt stmtCnt = 0;
+	
+	//Create as many statement objects as possible
+	err = KErrNone;
+	for(TInt i=0;(i<KMaxStmtCount) && (err == KErrNone);++i,++stmtCnt)
+		{
+		err = stmt[i].Prepare(db, _L("SELECT * FROM A WHERE I>=0 AND I<10"));
+		}
+	TheTest.Printf(_L("%d created statement objects. Last error: %d.\r\n"), stmtCnt, err);
+	TEST(err == KErrNone || err == KErrNoMemory);
+
+	//Close 1/2 of the statements to free some memory
+	for(TInt i=stmtCnt-1;i>=0;i-=2)
+		{
+		stmt[i].Close();
+		}
+	
+	//Now, there should be enough memory to be able to execute Next() on the rest of the statements
+	for(TInt i=stmtCnt-2;i>=0;i-=2)
+		{
+		err = stmt[i].Next();
+		TEST2(err, KSqlAtRow);
+		err = stmt[i].Next();
+		TEST2(err, KSqlAtRow);
+		err = stmt[i].Next();
+		TEST2(err, KSqlAtEnd);
+		}
+	
+	//Cleanup
+	for(TInt i=stmtCnt-1;i>=0;--i)
+		{
+		stmt[i].Close();
+		}
+	delete [] stmt;
+	db.Close();
+	(void)RSqlDatabase::Delete(KTestDbName1);
+	}
+
 void DoTests()
 	{
 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1627-0001 SQL server load test "));
 	SqlLoadTest();
+	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4201 Statement max number test"));
+	StatementMaxNumberTest();
 	}
 
 TInt E32Main()
--- a/persistentstorage/sql/TEST/t_sqloom5.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqloom5.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -614,7 +614,7 @@
                         attached (secure and non-secure).
                         UTF8 encoded database is used.
 @SYMTestExpectedResults Test must not fail
-@SYMDEF                 DEF????
+@SYMDEF                 DEF144603
 */  
 void Utf8OpenAttachDatabaseOomTest()
     {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/persistentstorage/sql/TEST/t_sqlsecurity6.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -0,0 +1,126 @@
+// Copyright (c) 2010 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"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+// 
+//
+#include <e32test.h>
+#include <bautils.h>
+#include <sqldb.h>
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+RSqlDatabase TheDb;
+RTest TheTest(_L("t_sqlsecurity6 test"));
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+void DestroyTestEnv()
+	{
+	TheDb.Close();
+	(void)RSqlDatabase::Delete(_L("c:[00009876]"));
+	}
+
+///////////////////////////////////////////////////////////////////////////////////////
+//Test macros and functions
+void Check1(TInt aValue, TInt aLine)
+	{
+	if(!aValue)
+		{
+		DestroyTestEnv();
+		RDebug::Print(_L("*** Boolean expression evaluated to false. Line %d\r\n"), aLine);
+		TheTest(EFalse, aLine);
+		}
+	}
+void Check2(TInt aValue, TInt aExpected, TInt aLine)
+	{
+	if(aValue != aExpected)
+		{
+		DestroyTestEnv();
+		RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
+		TheTest(EFalse, aLine);
+		}
+	}
+#define TEST(arg) ::Check1((arg), __LINE__)
+#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+/**
+@SYMTestCaseID          PDS-SQL-CT-4199
+@SYMTestCaseDesc        Invalid secure database UIDs test.
+@SYMTestPriority        High
+@SYMTestActions         The test attempts to create a secure database using invalid UIDs:
+						- with length less than 8 hes digits;
+						- with invalid characters in the UID;
+						- wiht database name containing the UID only;
+@SYMTestExpectedResults Test must not fail
+@SYMDEF                 DEF145236
+*/  
+void InvalidSecureUidsTest()
+	{
+	RSqlSecurityPolicy policy;
+	TInt err = policy.Create(TSecurityPolicy::EAlwaysPass);
+	TEST2(err, KErrNone);
+	
+	//The UID in the database name is too short. It must be 8 hex digits UID. 
+	err = TheDb.Create(_L("c:[9876]t_sqlsecurity6.db"), policy);
+	TEST2(err, KErrArgument);
+	
+	//Short UID, used as a database name. 
+	err = TheDb.Create(_L("c:[9876]"), policy);
+	TEST2(err, KErrArgument);
+
+	//Invalid UID. 
+	err = TheDb.Create(_L("c:[KH0A0Q0J]"), policy);
+	TEST2(err, KErrArgument);
+	
+	//UID, used as a database name. 
+	err = TheDb.Create(_L("c:[00009876]"), policy);
+	TEST2(err, KErrNone);
+	err = TheDb.Exec(_L("CREATE TABLE A(I INTEGER)"));
+	TEST(err >= 0);
+	TheDb.Close();
+	err = RSqlDatabase::Delete(_L("c:[00009876]"));
+	TEST2(err, KErrNone);
+	
+	policy.Close();
+	}
+
+void DoTestsL()
+	{
+	TheTest.Start(_L("@SYMTestCaseID:PDS-SQL-CT-4199"));
+	InvalidSecureUidsTest();
+	}
+
+TInt E32Main()
+	{
+	TheTest.Title();
+	
+	CTrapCleanup* tc = CTrapCleanup::New();
+	TheTest(tc != NULL);
+	
+	__UHEAP_MARK;
+		
+	TRAPD(err, DoTestsL());
+	TEST2(err, KErrNone);
+
+	__UHEAP_MARKEND;
+	
+	TheTest.End();
+	TheTest.Close();
+	
+	delete tc;
+
+	User::Heap().Check();
+	return KErrNone;
+	}
--- a/persistentstorage/sql/TEST/t_sqlstartup.cpp	Wed Apr 14 17:46:32 2010 +0300
+++ b/persistentstorage/sql/TEST/t_sqlstartup.cpp	Tue Apr 27 18:25:57 2010 +0300
@@ -22,6 +22,9 @@
 _LIT(KCfgDb1ConfigFilePath, "c:\\private\\10281e17\\cfg[10281E17]t_sqlstartup1.db.02"); // config file version 2 for t_sqlstartup1.db
 _LIT(KCfgDb2ConfigFilePath, "c:\\private\\10281e17\\cfg[10281E17]t_sqlstartup2.db.05"); // config file version 5 for t_sqlstartup2.db
 
+//This subdir is created by t_sqlenvcreate app. It should not be returned in the list of files for backup.
+_LIT(KPrivateSubDir, "c:\\private\\10281e17\\TestDir.db");
+
 ///////////////////////////////////////////////////////////////////////////////////////
 
 RTest TheTest(_L("t_sqlstartup test"));
@@ -189,7 +192,18 @@
         const TUid KDbUd = {0x98765432};
         RArray<TParse> files;
         TRAP(err, server->GetBackUpListL(KDbUd, files));
-        fileCnt = files.Count(); 
+        fileCnt = files.Count();
+        if(err == KErrNone)
+        	{
+			//No directories should be returned in the list of files for backup
+			for(TInt i=0;i<fileCnt;++i)
+				{
+				const TParse& parse = files[i];
+				TPtrC fname = parse.FullName();
+				TInt rc = KPrivateSubDir().CompareF(parse.FullName());
+				TEST(rc != 0);
+				}
+        	}
         files.Close();
         OomPostStep();
         }
@@ -221,7 +235,7 @@
         {
         TheTest.Printf(_L("===Simulated error: %d\r\nIteration: "), fsError);
         err = KErrNotFound;
-        TInt cnt=1;
+        TInt cnt=0;
         while(err<KErrNone)
             {
             TheTest.Printf(_L("%d "), cnt);
@@ -259,7 +273,7 @@
         TheTest.Printf(_L("===Simulated error: %d\r\nIteration: "), fsError);
         err = KErrNotFound;
         TInt fileCnt = 0;
-        TInt cnt=1;
+        TInt cnt=0;
         while(err<KErrNone)
             {
             TheTest.Printf(_L("%d "), cnt);
@@ -268,6 +282,17 @@
             RArray<TParse> files;
             TRAP(err, server->GetBackUpListL(KDbUd, files));
             fileCnt = files.Count(); 
+            if(err == KErrNone)
+            	{
+    			//No directories should be returned in the list of files for backup
+    			for(TInt i=0;i<fileCnt;++i)
+    				{
+    				const TParse& parse = files[i];
+    				TPtrC fname = parse.FullName();
+    				TInt rc = KPrivateSubDir().CompareF(parse.FullName());
+    				TEST(rc != 0);
+    				}
+            	}
             files.Close();
             (void)server->Fs().SetErrorCondition(KErrNone);
             if(err != KErrNone)
@@ -306,17 +331,6 @@
     name2[1] = TChar(0xFC00); 
     rc = UTF16ToUTF8(name2, bufout);
     TEST(!rc);
-#ifndef _DEBUG    
-    //Test where the input buffer is too big
-    TBuf<KMaxFileName + 1> bufin;
-    bufin.SetLength(bufin.MaxLength());
-    rc = UTF16ToUTF8(bufin, bufout);
-    TEST(!rc);
-    //Test where the output buffer max length is less than KMaxFileName
-    TBuf8<KMaxFileName / 2> bufout2;
-    rc = UTF16ToUTF8(name2, bufout2);
-    TEST(!rc);
-#endif    
     /////////       UTF16ToUTF8Z()       ///////////////////////
     _LIT8(KStr8Z, "abcd\x0");
     rc = UTF16ToUTF8Z(KStr16, bufout);