persistentstorage/sql/TEST/t_sqlperformance2.cpp
changeset 55 44f437012c90
parent 29 cce6680bbf1c
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    14 //
    14 //
    15 
    15 
    16 #include <e32test.h>
    16 #include <e32test.h>
    17 #include <bautils.h>
    17 #include <bautils.h>
    18 #include <sqldb.h>
    18 #include <sqldb.h>
       
    19 #include <hal.h>
    19 #include "t_sqlcmdlineutil.h"
    20 #include "t_sqlcmdlineutil.h"
    20 
    21 
    21 ///////////////////////////////////////////////////////////////////////////////////////
    22 ///////////////////////////////////////////////////////////////////////////////////////
    22 
    23 
    23 RTest			TheTest(_L("t_sqlperformance2 test"));
    24 RTest			TheTest(_L("t_sqlperformance2 test"));
    27 
    28 
    28 TBuf<200> 		TheTestTitle;
    29 TBuf<200> 		TheTestTitle;
    29 TCmdLineParams 	TheCmdLineParams;
    30 TCmdLineParams 	TheCmdLineParams;
    30 TBuf8<200> 		TheSqlConfigString;
    31 TBuf8<200> 		TheSqlConfigString;
    31 
    32 
       
    33 TBuf<250> 		TheLogLine;
       
    34 TBuf8<250> 		TheLogLine8;
       
    35 RFile 			TheLogFile; 
       
    36 
    32 _LIT(KUtf8,  "UTF8 ");
    37 _LIT(KUtf8,  "UTF8 ");
    33 _LIT(KUtf16, "UTF16");
    38 _LIT(KUtf16, "UTF16");
    34 
    39 
    35 TInt TheBlobSize = 1024 * 256;
    40 TInt TheBlobSize = 1024 * 256;
       
    41 TInt TheDbSize1, TheDbSize2;
       
    42 TUint32 TheStartTicks, TheEndTicks;
    36 
    43 
    37 ///////////////////////////////////////////////////////////////////////////////////////
    44 ///////////////////////////////////////////////////////////////////////////////////////
    38 
    45 
    39 void TestEnvDestroy()
    46 void TestEnvDestroy()
    40 	{
    47 	{
       
    48 	if(TheCmdLineParams.iLogFileName.Length() > 0)
       
    49 		{
       
    50 		(void)TheLogFile.Flush();
       
    51 		TheLogFile.Close();
       
    52 		}
    41 	TheDb.Close();
    53 	TheDb.Close();
    42 	(void)RSqlDatabase::Delete(TheDbFileName);
    54 	(void)RSqlDatabase::Delete(TheDbFileName);
    43 	TheFs.Close();
    55 	TheFs.Close();
    44 	}
    56 	}
    45 
    57 
    96 	_LIT(KType9, "Remote drive");
   108 	_LIT(KType9, "Remote drive");
    97 	_LIT(KType10,"NAND flash");
   109 	_LIT(KType10,"NAND flash");
    98 	_LIT(KType11,"Rotating media");
   110 	_LIT(KType11,"Rotating media");
    99 	TPtrC KMediaTypeNames[] = {KType1(), KType2(), KType3(), KType4(), KType5(), KType6(), KType7(), KType8(), KType9(), KType10(), KType11()};
   111 	TPtrC KMediaTypeNames[] = {KType1(), KType2(), KType3(), KType4(), KType5(), KType6(), KType7(), KType8(), KType9(), KType10(), KType11()};
   100 	TheTest.Printf(_L("Drive %C: %S. File: \"%S\"\r\n"), 'A' + driveNo, &KMediaTypeNames[driveInfo.iType], &TheDbFileName);
   112 	TheTest.Printf(_L("Drive %C: %S. File: \"%S\"\r\n"), 'A' + driveNo, &KMediaTypeNames[driveInfo.iType], &TheDbFileName);
   101 	}
   113 	
   102 	
   114 	if(TheCmdLineParams.iLogFileName.Length() > 0)
   103 void PrintWriteTime(TTimeIntervalMicroSeconds aTime, TTimeIntervalMicroSeconds aWriteTime, TTimeIntervalMicroSeconds aCommitTime)
   115 		{
   104 	{
   116 		err = TheLogFile.Replace(TheFs, TheCmdLineParams.iLogFileName, EFileRead | EFileWrite);
   105 	TheTest.Printf(_L("####Execution time: %d ms, Write: %d ms, Commit: %d ms\r\n"), 
   117 		TEST2(err, KErrNone);
   106 		(TInt)(aTime.Int64() / 1000), (TInt)(aWriteTime.Int64() / 1000), (TInt)(aCommitTime.Int64() / 1000));
   118 		LogConfig(TheLogFile, TheCmdLineParams);
   107 	}
   119 		}
   108 
   120     }
   109 void PrintReadTime(TTimeIntervalMicroSeconds aPrepareTime, TTimeIntervalMicroSeconds aNextTime, TTimeIntervalMicroSeconds aReadTime)
   121 	
   110 	{
   122 //Prints the test case title and execution time in microseconds
   111 	TInt executionTime = (TInt)(aPrepareTime.Int64() / 1000) + (TInt)(aNextTime.Int64() / 1000) + (TInt)(aReadTime.Int64() / 1000);
   123 void PrintWriteStats()
   112 	TheTest.Printf(_L("####Execution time: %d ms, Prepare: %d ms, Next: %d ms, Read: %d ms\r\n"), 
   124 	{
   113 		executionTime, (TInt)(aPrepareTime.Int64() / 1000), (TInt)(aNextTime.Int64() / 1000), (TInt)(aReadTime.Int64() / 1000));
   125 	static TInt freq = 0;
   114 	}
   126 	if(freq == 0)
   115 
   127 		{
   116 void PrintReadTime(TTimeIntervalMicroSeconds aOpenTime, TTimeIntervalMicroSeconds aReadTime)
   128 		TEST2(HAL::Get(HAL::EFastCounterFrequency, freq), KErrNone);
   117 	{
   129 		}
   118 	TInt executionTime = (TInt)(aOpenTime.Int64() / 1000) + (TInt)(aReadTime.Int64() / 1000);
   130 	TInt64 diffTicks = (TInt64)TheEndTicks - (TInt64)TheStartTicks;
   119 	TheTest.Printf(_L("####Execution time: %d ms, Open: %d ms, Read: %d ms\r\n"), 
   131 	if(diffTicks < 0)
   120 		executionTime, (TInt)(aOpenTime.Int64() / 1000), (TInt)(aReadTime.Int64() / 1000));
   132 		{
   121 	}
   133 		diffTicks = KMaxTUint32 + diffTicks + 1;
   122 	
   134 		}
   123 void PrintFileSize(RSqlDatabase& aDb)
   135 	const TInt KMicroSecIn1Sec = 1000000;
   124 	{
   136 	TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq;
   125 	TheTest.Printf(_L("####FileSize: %d\r\n"), aDb.Size());
   137 	TheTest.Printf(_L("%S, blob: %d Kb, db size before: %d Kb, db size after: %d Kb, %d us\r\n"), 
   126 	}
   138 		&TheTestTitle, TheBlobSize / 1024, TheDbSize1 / 1024, TheDbSize2 / 1024, us);
   127 		
   139 	if(TheCmdLineParams.iLogFileName.Length() > 0)
       
   140 		{
       
   141 		TheLogLine.Format(_L("%S, blob: %d Kb, db size before: %d Kb, db size after: %d Kb¬%d¬us\r\n"), 
       
   142 			&TheTestTitle, TheBlobSize / 1024, TheDbSize1 / 1024, TheDbSize2 / 1024, us);
       
   143 		TheLogLine8.Copy(TheLogLine);
       
   144 		(void)TheLogFile.Write(TheLogLine8);
       
   145 		}
       
   146 	}
       
   147 
       
   148 //Prints the test case title and execution time in microseconds
       
   149 void PrintReadStats()
       
   150 	{
       
   151 	static TInt freq = 0;
       
   152 	if(freq == 0)
       
   153 		{
       
   154 		TEST2(HAL::Get(HAL::EFastCounterFrequency, freq), KErrNone);
       
   155 		}
       
   156 	TInt64 diffTicks = (TInt64)TheEndTicks - (TInt64)TheStartTicks;
       
   157 	if(diffTicks < 0)
       
   158 		{
       
   159 		diffTicks = KMaxTUint32 + diffTicks + 1;
       
   160 		}
       
   161 	const TInt KMicroSecIn1Sec = 1000000;
       
   162 	TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq;
       
   163 	TheTest.Printf(_L("%S, blob: %d Kb, %d us\r\n"), &TheTestTitle, TheBlobSize / 1024, us);
       
   164 	if(TheCmdLineParams.iLogFileName.Length() > 0)
       
   165 		{
       
   166 		TheLogLine.Format(_L("%S, blob: %d Kb¬%d¬us\r\n"), &TheTestTitle, TheBlobSize / 1024, us);
       
   167 		TheLogLine8.Copy(TheLogLine);
       
   168 		(void)TheLogFile.Write(TheLogLine8);
       
   169 		}
       
   170 	}
       
   171 
   128 ///////////////////////////////////////////////////////////////////////////////////////
   172 ///////////////////////////////////////////////////////////////////////////////////////
   129 	
   173 	
   130 void CreateTestDb()
   174 void CreateTestDb()
   131 	{
   175 	{
   132 	(void)RSqlDatabase::Delete(TheDbFileName);
   176 	(void)RSqlDatabase::Delete(TheDbFileName);
   134 	TEST2(err, KErrNone);
   178 	TEST2(err, KErrNone);
   135 	err = TheDb.Exec(_L8("CREATE TABLE A(B BLOB)"));
   179 	err = TheDb.Exec(_L8("CREATE TABLE A(B BLOB)"));
   136 	TEST2(err, 1);
   180 	TEST2(err, 1);
   137 	}
   181 	}
   138 
   182 
   139 void DoWriteBlobIncrL(const TDesC8& aData, 
   183 void DoWriteBlobIncrL(const TDesC8& aData)
   140 					  TTime& aT1, 
   184 	{
   141 					  TTime& aT2,
       
   142 					  TTime& aT3,
       
   143 					  TTime& aT4)
       
   144 	{
       
   145 	
       
   146 	RSqlBlobWriteStream strm;
   185 	RSqlBlobWriteStream strm;
   147 	CleanupClosePushL(strm);
   186 	CleanupClosePushL(strm);
   148 	
   187 	
   149 	aT1.HomeTime();
       
   150 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   188 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   151 	strm.WriteL(aData);
   189 	strm.WriteL(aData);
   152 	aT2.HomeTime();
   190 	
   153 	
       
   154 	aT3.HomeTime();
       
   155 	strm.CommitL();
   191 	strm.CommitL();
   156 	aT4.HomeTime();
       
   157 	
   192 	
   158 	CleanupStack::PopAndDestroy(&strm);
   193 	CleanupStack::PopAndDestroy(&strm);
   159 	}
   194 	}
   160 	
   195 	
   161 void InsertZeroBlob(TBool aDoPrintTime = EFalse)
   196 void InsertZeroBlob()
   162 	{
   197 	{
   163 	TBuf<100> sql;
   198 	TBuf<100> sql;
   164 	sql.Format(_L("INSERT INTO A VALUES(zeroblob(%d))"), TheBlobSize);
   199 	sql.Format(_L("INSERT INTO A VALUES(zeroblob(%d))"), TheBlobSize);
   165 	
   200 	
   166 	TTime t1, t2;
   201 	TheStartTicks = User::FastCounter();
   167 	t1.HomeTime();
       
   168 	TInt err = TheDb.Exec(sql);
   202 	TInt err = TheDb.Exec(sql);
   169 	t2.HomeTime();
   203 	TheEndTicks = User::FastCounter();
       
   204 	
   170 	TEST2(err, 1);
   205 	TEST2(err, 1);
   171 	TTimeIntervalMicroSeconds insertTime = t2.MicroSecondsFrom(t1);
       
   172 	
       
   173 	if(aDoPrintTime)
       
   174 		{
       
   175 		PrintWriteTime(insertTime, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
       
   176 		}
       
   177 	}
   206 	}
   178 	
   207 	
   179 void InsertRealBlob()
   208 void InsertRealBlob()
   180 	{
   209 	{
   181 	HBufC8* data = HBufC8::New(TheBlobSize);
   210 	HBufC8* data = HBufC8::New(TheBlobSize);
   211 	TEST(data != NULL);
   240 	TEST(data != NULL);
   212 	TPtr8 dataptr = data->Des();
   241 	TPtr8 dataptr = data->Des();
   213 	dataptr.SetLength(TheBlobSize);
   242 	dataptr.SetLength(TheBlobSize);
   214 	dataptr.Fill(TChar('B'));
   243 	dataptr.Fill(TChar('B'));
   215 	
   244 	
   216 	TTimeIntervalMicroSeconds totalTime, writeTime, commitTime;
       
   217 
       
   218 	TBuf<100> sql;
   245 	TBuf<100> sql;
   219 	sql.Format(_L("INSERT INTO A VALUES(zeroblob(%d))"), TheBlobSize);
   246 	sql.Format(_L("INSERT INTO A VALUES(zeroblob(%d))"), TheBlobSize);
   220 
   247 
   221 	TTime t1, t2, subt1, subt2, subt3, subt4;
   248 	TheStartTicks = User::FastCounter();
   222 	t1.HomeTime();
       
   223 	
   249 	
   224 	TInt err = TheDb.Exec(_L8("BEGIN"));
   250 	TInt err = TheDb.Exec(_L8("BEGIN"));
   225 	TEST(err >= 0);
   251 	TEST(err >= 0);
   226 	
   252 	
   227 	err = TheDb.Exec(sql);
   253 	err = TheDb.Exec(sql);
   228 	TEST2(err, 1);
   254 	TEST2(err, 1);
   229 	
   255 	
   230 	TRAP(err, DoWriteBlobIncrL(dataptr, subt1, subt2, subt3, subt4));
   256 	TRAP(err, DoWriteBlobIncrL(dataptr));
   231 	TEST2(err, KErrNone);
   257 	TEST2(err, KErrNone);
   232 	
   258 	
   233 	err = TheDb.Exec(_L8("COMMIT"));
   259 	err = TheDb.Exec(_L8("COMMIT"));
   234 	TEST(err >= 0);
   260 	TEST(err >= 0);
   235 		
   261 		
   236 	t2.HomeTime();
   262 	TheEndTicks = User::FastCounter();
   237 	totalTime = t2.MicroSecondsFrom(t1);
       
   238 	
       
   239 	writeTime = subt2.MicroSecondsFrom(subt1);
       
   240 	commitTime = subt4.MicroSecondsFrom(subt3);
       
   241 	
       
   242 	PrintWriteTime(totalTime, writeTime, commitTime);
       
   243 	
   263 	
   244 	delete data;
   264 	delete data;
   245 	}
   265 	}
   246 	
   266 	
   247 void InsertBlobExec()
   267 void InsertBlobExec()
   253 	sql.SetLength(TheBlobSize * 2 + KStr().Length());
   273 	sql.SetLength(TheBlobSize * 2 + KStr().Length());
   254 	sql.Fill(TChar('A'));
   274 	sql.Fill(TChar('A'));
   255 	sql.Replace(0, KStr().Length(), KStr);
   275 	sql.Replace(0, KStr().Length(), KStr);
   256 	sql.Append(_L8("')"));
   276 	sql.Append(_L8("')"));
   257 
   277 
   258 	TTime t1, t2;
   278 	TheStartTicks = User::FastCounter();
   259 	
   279 	
   260 	t1.HomeTime();		
       
   261 	TInt err = TheDb.Exec(sql);
   280 	TInt err = TheDb.Exec(sql);
   262 	t2.HomeTime();
       
   263 	TEST2(err, 1);
   281 	TEST2(err, 1);
   264 
   282 
   265 	TTimeIntervalMicroSeconds totalTime = t2.MicroSecondsFrom(t1);
   283 	TheEndTicks = User::FastCounter();
   266 	
       
   267 	PrintWriteTime(totalTime, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
       
   268 	
   284 	
   269 	delete buf;	
   285 	delete buf;	
   270 	}
   286 	}
   271 
   287 
   272 void InsertBlobBindStreamPrm()
   288 void InsertBlobBindStreamPrm()
   275 	TEST(data != NULL);
   291 	TEST(data != NULL);
   276 	TPtr8 dataptr = data->Des();
   292 	TPtr8 dataptr = data->Des();
   277 	dataptr.SetLength(TheBlobSize);
   293 	dataptr.SetLength(TheBlobSize);
   278 	dataptr.Fill(TChar('A'));
   294 	dataptr.Fill(TChar('A'));
   279 	
   295 	
   280 	TTimeIntervalMicroSeconds totalTime, writeTime, commitTime;
   296 	TheStartTicks = User::FastCounter();
   281 
       
   282 	TTime t1, t2, t3, t4, t5, t6;
       
   283 	t1.HomeTime();
       
   284 				
   297 				
   285 	RSqlStatement stmt;
   298 	RSqlStatement stmt;
   286 	TInt err = stmt.Prepare(TheDb, _L8("INSERT INTO A VALUES(:Prm)"));
   299 	TInt err = stmt.Prepare(TheDb, _L8("INSERT INTO A VALUES(:Prm)"));
   287 	TEST2(err, KErrNone);
   300 	TEST2(err, KErrNone);
   288 
   301 
   289 	RSqlParamWriteStream strm;
   302 	RSqlParamWriteStream strm;
   290 	err = strm.BindBinary(stmt, 0);
   303 	err = strm.BindBinary(stmt, 0);
   291 	TEST2(err, KErrNone);
   304 	TEST2(err, KErrNone);
   292 	
   305 	
   293 	t3.HomeTime();
       
   294 	TRAP(err, strm.WriteL(dataptr));
   306 	TRAP(err, strm.WriteL(dataptr));
   295 	t4.HomeTime();
   307 	TEST2(err, KErrNone);
   296 	TEST2(err, KErrNone);
   308 	
   297 	
       
   298 	t5.HomeTime();
       
   299 	TRAP(err, strm.CommitL());
   309 	TRAP(err, strm.CommitL());
   300 	t6.HomeTime();
       
   301 	TEST2(err, KErrNone);
   310 	TEST2(err, KErrNone);
   302 	
   311 	
   303 	err = stmt.Exec();	
   312 	err = stmt.Exec();	
       
   313 	TEST2(err, 1);
   304 	
   314 	
   305 	strm.Close();
   315 	strm.Close();
   306 	stmt.Close();	
   316 	stmt.Close();	
   307 	
   317 	
   308 	t2.HomeTime();
   318 	TheEndTicks = User::FastCounter();
   309 	TEST2(err, 1);
       
   310 					
   319 					
   311 	totalTime = t2.MicroSecondsFrom(t1);
       
   312 	
       
   313 	writeTime = t4.MicroSecondsFrom(t3);
       
   314 	commitTime = t6.MicroSecondsFrom(t5);
       
   315 	
       
   316 	PrintWriteTime(totalTime, writeTime, commitTime);
       
   317 			
       
   318 	delete data;	
   320 	delete data;	
   319 	}
   321 	}
   320 	
   322 	
   321 void UpdateBlobIncr()
   323 void UpdateBlobIncr()
   322 	{
   324 	{
   324 	TEST(data != NULL);
   326 	TEST(data != NULL);
   325 	TPtr8 dataptr = data->Des();
   327 	TPtr8 dataptr = data->Des();
   326 	dataptr.SetLength(TheBlobSize);
   328 	dataptr.SetLength(TheBlobSize);
   327 	dataptr.Fill(TChar('A'));
   329 	dataptr.Fill(TChar('A'));
   328 	
   330 	
   329 	TTimeIntervalMicroSeconds totalTime, writeTime, commitTime;
   331 	TheStartTicks = User::FastCounter();
   330 
       
   331 	TTime t1, t2, subt1, subt2, subt3, subt4;
       
   332 	t1.HomeTime();
       
   333 	
   332 	
   334 	TInt err = TheDb.Exec(_L8("BEGIN"));
   333 	TInt err = TheDb.Exec(_L8("BEGIN"));
   335 	TEST(err >= 0);
   334 	TEST(err >= 0);
   336 		
   335 		
   337 	TRAP(err, DoWriteBlobIncrL(dataptr, subt1, subt2, subt3, subt4));
   336 	TRAP(err, DoWriteBlobIncrL(dataptr));
   338 	TEST2(err, KErrNone);
   337 	TEST2(err, KErrNone);
   339 	
   338 	
   340 	err = TheDb.Exec(_L8("COMMIT"));
   339 	err = TheDb.Exec(_L8("COMMIT"));
   341 	TEST(err >= 0);
   340 	TEST(err >= 0);
   342 		
   341 			
   343 	t2.HomeTime();
   342 	TheEndTicks = User::FastCounter();
   344 	totalTime = t2.MicroSecondsFrom(t1);
       
   345 	
       
   346 	writeTime = subt2.MicroSecondsFrom(subt1);
       
   347 	commitTime = subt4.MicroSecondsFrom(subt3);
       
   348 	
       
   349 	PrintWriteTime(totalTime, writeTime, commitTime);
       
   350 	
   343 	
   351 	delete data;
   344 	delete data;
   352 	}
   345 	}
   353 	
   346 	
   354 void UpdateBlobExec()
   347 void UpdateBlobExec()
   360 	sql.SetLength(TheBlobSize * 2 + KStr().Length());
   353 	sql.SetLength(TheBlobSize * 2 + KStr().Length());
   361 	sql.Fill(TChar('B'));
   354 	sql.Fill(TChar('B'));
   362 	sql.Replace(0, KStr().Length(), KStr);
   355 	sql.Replace(0, KStr().Length(), KStr);
   363 	sql.Append(_L8("'"));
   356 	sql.Append(_L8("'"));
   364 
   357 
   365 	TTime t1, t2;
   358 	TheStartTicks = User::FastCounter();
   366 	t1.HomeTime();			
       
   367 	TInt err = TheDb.Exec(sql);	
   359 	TInt err = TheDb.Exec(sql);	
   368 	t2.HomeTime();
       
   369 	TEST2(err, 1);
   360 	TEST2(err, 1);
   370 
   361 	TheEndTicks = User::FastCounter();
   371 	TTimeIntervalMicroSeconds totalTime = t2.MicroSecondsFrom(t1);
   362 
   372 	
       
   373 	PrintWriteTime(totalTime, TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0));
       
   374 	
       
   375 	delete buf;	
   363 	delete buf;	
   376 	}
   364 	}
   377 
   365 
   378 void UpdateBlobBindStreamPrm()
   366 void UpdateBlobBindStreamPrm()
   379 	{
   367 	{
   381 	TEST(data != NULL);
   369 	TEST(data != NULL);
   382 	TPtr8 dataptr = data->Des();
   370 	TPtr8 dataptr = data->Des();
   383 	dataptr.SetLength(TheBlobSize);
   371 	dataptr.SetLength(TheBlobSize);
   384 	dataptr.Fill(TChar('B'));
   372 	dataptr.Fill(TChar('B'));
   385 	
   373 	
   386 	TTimeIntervalMicroSeconds totalTime, writeTime, commitTime;
   374 	TheStartTicks = User::FastCounter();
   387 
       
   388 	TTime t1, t2, t3, t4, t5, t6;
       
   389 	t1.HomeTime();
       
   390 				
   375 				
   391 	RSqlStatement stmt;
   376 	RSqlStatement stmt;
   392 	TInt err = stmt.Prepare(TheDb, _L8("UPDATE A SET B=(:Prm)"));
   377 	TInt err = stmt.Prepare(TheDb, _L8("UPDATE A SET B=(:Prm)"));
   393 	TEST2(err, KErrNone);
   378 	TEST2(err, KErrNone);
   394 
   379 
   395 	RSqlParamWriteStream strm;
   380 	RSqlParamWriteStream strm;
   396 	err = strm.BindBinary(stmt, 0);
   381 	err = strm.BindBinary(stmt, 0);
   397 	TEST2(err, KErrNone);
   382 	TEST2(err, KErrNone);
   398 	
   383 	
   399 	t3.HomeTime();;
       
   400 	TRAP(err, strm.WriteL(dataptr));
   384 	TRAP(err, strm.WriteL(dataptr));
   401 	t4.HomeTime();
   385 	TEST2(err, KErrNone);
   402 	TEST2(err, KErrNone);
   386 	
   403 	
       
   404 	t5.HomeTime();
       
   405 	TRAP(err, strm.CommitL());
   387 	TRAP(err, strm.CommitL());
   406 	t6.HomeTime();
       
   407 	TEST2(err, KErrNone);
   388 	TEST2(err, KErrNone);
   408 	
   389 	
   409 	err = stmt.Exec();	
   390 	err = stmt.Exec();	
       
   391 	TEST2(err, 1);
   410 
   392 
   411 	strm.Close();		
   393 	strm.Close();		
   412 	stmt.Close();	
   394 	stmt.Close();	
   413 
   395 
   414 	t2.HomeTime();
   396 	TheEndTicks = User::FastCounter();
   415 	TEST2(err, 1);
   397 	
   416 	
       
   417 	totalTime = t2.MicroSecondsFrom(t1);
       
   418 	
       
   419 	writeTime = t4.MicroSecondsFrom(t3);
       
   420 	commitTime = t6.MicroSecondsFrom(t5);
       
   421 	
       
   422 	PrintWriteTime(totalTime, writeTime, commitTime);
       
   423 			
       
   424 	delete data;	
   398 	delete data;	
   425 	}
   399 	}
   426 
   400 
   427 /**
   401 /**
   428 @SYMTestCaseID			SYSLIB-SQL-UT-4084
   402 @SYMTestCaseID			SYSLIB-SQL-UT-4084
   434 @SYMTestExpectedResults Test must not fail
   408 @SYMTestExpectedResults Test must not fail
   435 @SYMREQ					REQ5912
   409 @SYMREQ					REQ5912
   436 */
   410 */
   437 void BlobWriteTest()
   411 void BlobWriteTest()
   438 	{	
   412 	{	
   439 	TheTest.Printf(_L("Blob size=%d Kb\r\n"), TheBlobSize / 1024);
       
   440 	
       
   441 	//Insert a blob
   413 	//Insert a blob
   442 	TheTest.Printf(_L("==================================================================\r\n"));
   414 	
   443 	
   415 	CreateTestDb();
   444 	CreateTestDb();
   416 	TheTestTitle.Copy(_L("INSERT zeroblob - RSqlDatabase::Exec()"));
   445 	TheTest.Printf(_L("INSERT zeroblob - RSqlDatabase::Exec()\r\n"));
   417 	TheDbSize1 = TheDb.Size();
   446 	PrintFileSize(TheDb);
   418 	InsertZeroBlob();
   447 	InsertZeroBlob(ETrue);
   419 	TheDbSize2 = TheDb.Size();
   448 	PrintFileSize(TheDb);
   420 	TheDb.Close();
   449 	TheDb.Close();
   421 	(void)RSqlDatabase::Delete(TheDbFileName);
   450 	(void)RSqlDatabase::Delete(TheDbFileName);
   422 	PrintWriteStats();
   451 				
   423 				
   452 	CreateTestDb();
   424 	CreateTestDb();
   453 	TheTest.Printf(_L("INSERT blob - RSqlParamWriteStream\r\n"));
   425 	TheTestTitle.Copy(_L("INSERT blob - RSqlParamWriteStream"));
   454 	PrintFileSize(TheDb);
   426 	TheDbSize1 = TheDb.Size();
   455 	InsertBlobBindStreamPrm();
   427 	InsertBlobBindStreamPrm();
   456 	PrintFileSize(TheDb);
   428 	TheDbSize2 = TheDb.Size();
   457 	TheDb.Close();
   429 	TheDb.Close();
   458 	(void)RSqlDatabase::Delete(TheDbFileName);
   430 	(void)RSqlDatabase::Delete(TheDbFileName);
   459 	
   431 	PrintWriteStats();
   460 	CreateTestDb();
   432 	
   461 	TheTest.Printf(_L("INSERT blob - RSqlDatabase::Exec()\r\n"));
   433 	CreateTestDb();
   462 	PrintFileSize(TheDb);
   434 	TheTestTitle.Copy(_L("INSERT blob - RSqlDatabase::Exec()"));
       
   435 	TheDbSize1 = TheDb.Size();
   463 	InsertBlobExec();
   436 	InsertBlobExec();
   464 	PrintFileSize(TheDb);
   437 	TheDbSize2 = TheDb.Size();
   465 	TheDb.Close();
   438 	TheDb.Close();
   466 	(void)RSqlDatabase::Delete(TheDbFileName);
   439 	(void)RSqlDatabase::Delete(TheDbFileName);
   467 	
   440 	PrintWriteStats();
   468 	CreateTestDb();
   441 	
   469 	TheTest.Printf(_L("INSERT blob - RSqlBlobWriteStream + transaction\r\n"));
   442 	CreateTestDb();
   470 	PrintFileSize(TheDb);
   443 	TheTestTitle.Copy(_L("INSERT blob - RSqlBlobWriteStream + transaction"));
       
   444 	TheDbSize1 = TheDb.Size();
   471 	InsertBlobIncr();
   445 	InsertBlobIncr();
   472 	PrintFileSize(TheDb);
   446 	TheDbSize2 = TheDb.Size();
   473 	TheDb.Close();
   447 	TheDb.Close();
   474 	(void)RSqlDatabase::Delete(TheDbFileName);
   448 	(void)RSqlDatabase::Delete(TheDbFileName);
       
   449 	PrintWriteStats();
   475 						
   450 						
   476 	// Update a blob 
   451 	// Update a blob 
   477 	TheTest.Printf(_L("==================================================================\r\n"));
   452 		
   478 		
   453 	CreateTestDb();
   479 	CreateTestDb();
   454 	TheTestTitle.Copy(_L("UPDATE zeroblob - RSqlParamWriteStream"));
   480 	TheTest.Printf(_L("UPDATE zeroblob - RSqlParamWriteStream\r\n"));
   455 	TheDbSize1 = TheDb.Size();
   481 	PrintFileSize(TheDb);
       
   482 	InsertZeroBlob();
   456 	InsertZeroBlob();
   483 	UpdateBlobBindStreamPrm();
   457 	UpdateBlobBindStreamPrm();
   484 	PrintFileSize(TheDb);
   458 	TheDbSize2 = TheDb.Size();
   485 	TheDb.Close();
   459 	TheDb.Close();
   486 	(void)RSqlDatabase::Delete(TheDbFileName);
   460 	(void)RSqlDatabase::Delete(TheDbFileName);
   487 		
   461 	PrintWriteStats();
   488 	CreateTestDb();
   462 		
   489 	TheTest.Printf(_L("UPDATE blob - RSqlParamWriteStream\r\n"));
   463 	CreateTestDb();
   490 	PrintFileSize(TheDb);
   464 	TheTestTitle.Copy(_L("UPDATE blob - RSqlParamWriteStream"));
       
   465 	TheDbSize1 = TheDb.Size();
   491 	InsertRealBlob();
   466 	InsertRealBlob();
   492 	UpdateBlobBindStreamPrm();
   467 	UpdateBlobBindStreamPrm();
   493 	PrintFileSize(TheDb);
   468 	TheDbSize2 = TheDb.Size();
   494 	TheDb.Close();
   469 	TheDb.Close();
   495 	(void)RSqlDatabase::Delete(TheDbFileName);
   470 	(void)RSqlDatabase::Delete(TheDbFileName);
       
   471 	PrintWriteStats();
   496 			
   472 			
   497 	CreateTestDb();
   473 	CreateTestDb();
   498 	TheTest.Printf(_L("UPDATE zeroblob - RSqlDatabase::Exec()\r\n"));
   474 	TheTestTitle.Copy(_L("UPDATE zeroblob - RSqlDatabase::Exec()"));
   499 	PrintFileSize(TheDb);
   475 	TheDbSize1 = TheDb.Size();
   500 	InsertZeroBlob();
   476 	InsertZeroBlob();
   501 	UpdateBlobExec();
   477 	UpdateBlobExec();
   502 	PrintFileSize(TheDb);
   478 	TheDbSize2 = TheDb.Size();
   503 	TheDb.Close();
   479 	TheDb.Close();
   504 	(void)RSqlDatabase::Delete(TheDbFileName);
   480 	(void)RSqlDatabase::Delete(TheDbFileName);
   505 		
   481 	PrintWriteStats();
   506 	CreateTestDb();
   482 		
   507 	TheTest.Printf(_L("UPDATE blob - RSqlDatabase::Exec()\r\n"));
   483 	CreateTestDb();
   508 	PrintFileSize(TheDb);
   484 	TheTestTitle.Copy(_L("UPDATE blob - RSqlDatabase::Exec()"));
       
   485 	TheDbSize1 = TheDb.Size();
   509 	InsertRealBlob();
   486 	InsertRealBlob();
   510 	UpdateBlobExec();
   487 	UpdateBlobExec();
   511 	PrintFileSize(TheDb);
   488 	TheDbSize2 = TheDb.Size();
   512 	TheDb.Close();
   489 	TheDb.Close();
   513 	(void)RSqlDatabase::Delete(TheDbFileName);
   490 	(void)RSqlDatabase::Delete(TheDbFileName);
   514 		
   491 	PrintWriteStats();
   515 	CreateTestDb();
   492 		
   516 	TheTest.Printf(_L("UPDATE zeroblob - RSqlBlobWriteStream + transaction\r\n"));
   493 	CreateTestDb();
   517 	PrintFileSize(TheDb);
   494 	TheTestTitle.Copy(_L("UPDATE zeroblob - RSqlBlobWriteStream + transaction"));
       
   495 	TheDbSize1 = TheDb.Size();
   518 	InsertZeroBlob();
   496 	InsertZeroBlob();
   519 	UpdateBlobIncr();
   497 	UpdateBlobIncr();
   520 	PrintFileSize(TheDb);
   498 	TheDbSize2 = TheDb.Size();
   521 	TheDb.Close();
   499 	TheDb.Close();
   522 	(void)RSqlDatabase::Delete(TheDbFileName);
   500 	(void)RSqlDatabase::Delete(TheDbFileName);
   523 		
   501 	PrintWriteStats();
   524 	CreateTestDb();
   502 		
   525 	TheTest.Printf(_L("UPDATE blob - RSqlBlobWriteStream + transaction\r\n"));
   503 	CreateTestDb();
   526 	PrintFileSize(TheDb);
   504 	TheTestTitle.Copy(_L("UPDATE blob - RSqlBlobWriteStream + transaction"));
       
   505 	TheDbSize1 = TheDb.Size();
   527 	InsertRealBlob();
   506 	InsertRealBlob();
   528 	UpdateBlobIncr();
   507 	UpdateBlobIncr();
   529 	PrintFileSize(TheDb);
   508 	TheDbSize2 = TheDb.Size();
   530 	TheDb.Close();
   509 	TheDb.Close();
   531 	(void)RSqlDatabase::Delete(TheDbFileName);	
   510 	(void)RSqlDatabase::Delete(TheDbFileName);	
       
   511 	PrintWriteStats();
   532 	}
   512 	}
   533 
   513 
   534 void DoReadBlobIncrL(TDes8& aDes, TInt aMaxLength)
   514 void DoReadBlobIncrL(TDes8& aDes, TInt aMaxLength)
   535 	{
   515 	{
   536 	TTime t1, t2, t3, t4;
   516 	TheStartTicks = User::FastCounter();
   537 	
       
   538 	TTimeIntervalMicroSeconds openTime, readTime; 
       
   539 	
   517 	
   540 	RSqlBlobReadStream strm;
   518 	RSqlBlobReadStream strm;
   541 	CleanupClosePushL(strm);
   519 	CleanupClosePushL(strm);
   542 	
       
   543 	t1.HomeTime();
       
   544 	strm.OpenL(TheDb, _L("A"), _L("B"), 1);
   520 	strm.OpenL(TheDb, _L("A"), _L("B"), 1);
   545 	t2.HomeTime();
       
   546 	
       
   547 	openTime = t2.MicroSecondsFrom(t1);
       
   548 		
       
   549 	t3.HomeTime();
       
   550 	strm.ReadL(aDes, aMaxLength);
   521 	strm.ReadL(aDes, aMaxLength);
   551 	t4.HomeTime();
       
   552 
       
   553 	readTime = t4.MicroSecondsFrom(t3);
       
   554 	
       
   555 	PrintReadTime(openTime, readTime);
       
   556 
       
   557 	CleanupStack::PopAndDestroy(&strm);
   522 	CleanupStack::PopAndDestroy(&strm);
       
   523 
       
   524 	TheEndTicks = User::FastCounter();
   558 	}
   525 	}
   559 
   526 
   560 void ReadBlobIncr()
   527 void ReadBlobIncr()
   561 	{
   528 	{
   562 	HBufC8* data = HBufC8::New(TheBlobSize);
   529 	HBufC8* data = HBufC8::New(TheBlobSize);
   574 	{
   541 	{
   575 	HBufC8* data = HBufC8::New(TheBlobSize);
   542 	HBufC8* data = HBufC8::New(TheBlobSize);
   576 	TEST(data != NULL);
   543 	TEST(data != NULL);
   577 	TPtr8 dataptr = data->Des();
   544 	TPtr8 dataptr = data->Des();
   578 	
   545 	
   579 	TTime t1, t2, t3, t4, t5, t6;
   546 	TheStartTicks = User::FastCounter();
   580 	TTimeIntervalMicroSeconds prepareTime, nextTime, readTime;
       
   581 	
   547 	
   582 	RSqlStatement stmt;
   548 	RSqlStatement stmt;
   583 	t1.HomeTime();
       
   584 	TInt err = stmt.Prepare(TheDb, _L8("SELECT B FROM A WHERE ROWID=1"));
   549 	TInt err = stmt.Prepare(TheDb, _L8("SELECT B FROM A WHERE ROWID=1"));
   585 	t2.HomeTime();
   550 	TEST2(err, KErrNone);
   586 	TEST2(err, KErrNone);
   551 
   587 	prepareTime = t2.MicroSecondsFrom(t1);
       
   588 
       
   589 	t3.HomeTime();
       
   590 	err = stmt.Next();
   552 	err = stmt.Next();
   591 	t4.HomeTime();
       
   592 	TEST2(err, KSqlAtRow);
   553 	TEST2(err, KSqlAtRow);
   593 	nextTime = t4.MicroSecondsFrom(t3);
   554 	
   594 	
       
   595 	t5.HomeTime();
       
   596 	err = stmt.ColumnBinary(0, dataptr);
   555 	err = stmt.ColumnBinary(0, dataptr);
   597 	t6.HomeTime();
       
   598 	TEST2(err, KErrNone);
   556 	TEST2(err, KErrNone);
   599 	TEST2(dataptr.Length(), TheBlobSize);
   557 	TEST2(dataptr.Length(), TheBlobSize);
   600 	readTime = t6.MicroSecondsFrom(t5);
       
   601 		
       
   602 	PrintReadTime(prepareTime, nextTime, readTime);
       
   603 	stmt.Close();
   558 	stmt.Close();
       
   559 
       
   560 	TheEndTicks = User::FastCounter();
   604 	
   561 	
   605 	delete data;
   562 	delete data;
   606 	}
   563 	}
   607 
   564 
   608 void ReadBlobColPtr()
   565 void ReadBlobColPtr()
   609 	{
   566 	{
   610 	TTime t1, t2, t3, t4, t5, t6;
   567 	TheStartTicks = User::FastCounter();
   611 	TTimeIntervalMicroSeconds prepareTime, nextTime, readTime;
       
   612 	
   568 	
   613 	RSqlStatement stmt;
   569 	RSqlStatement stmt;
   614 	t1.HomeTime();
       
   615 	TInt err = stmt.Prepare(TheDb, _L8("SELECT B FROM A WHERE ROWID=1"));
   570 	TInt err = stmt.Prepare(TheDb, _L8("SELECT B FROM A WHERE ROWID=1"));
   616 	t2.HomeTime();
   571 	TEST2(err, KErrNone);
   617 	TEST2(err, KErrNone);
   572 	
   618 	prepareTime = t2.MicroSecondsFrom(t1);
       
   619 	
       
   620 	t3.HomeTime();
       
   621 	err = stmt.Next();
   573 	err = stmt.Next();
   622 	t4.HomeTime();
       
   623 	TEST2(err, KSqlAtRow);
   574 	TEST2(err, KSqlAtRow);
   624 	nextTime = t4.MicroSecondsFrom(t3);
       
   625 	
   575 	
   626 	TPtrC8 data;
   576 	TPtrC8 data;
   627 	t5.HomeTime();
       
   628 	err = stmt.ColumnBinary(0, data);
   577 	err = stmt.ColumnBinary(0, data);
   629 	t6.HomeTime();
       
   630 	TEST2(err, KErrNone);
   578 	TEST2(err, KErrNone);
   631 	TEST2(data.Length(), TheBlobSize);
   579 	TEST2(data.Length(), TheBlobSize);
   632 	readTime = t6.MicroSecondsFrom(t5);
   580 
   633 
       
   634 	PrintReadTime(prepareTime, nextTime, readTime);
       
   635 	stmt.Close();
   581 	stmt.Close();
       
   582 
       
   583 	TheEndTicks = User::FastCounter();
   636 	}
   584 	}
   637 
   585 
   638 void ReadBlobStreamCol()
   586 void ReadBlobStreamCol()
   639 	{
   587 	{
   640 	HBufC8* data = HBufC8::New(TheBlobSize);
   588 	HBufC8* data = HBufC8::New(TheBlobSize);
   641 	TEST(data != NULL);
   589 	TEST(data != NULL);
   642 	TPtr8 dataptr = data->Des();
   590 	TPtr8 dataptr = data->Des();
   643 	
   591 	
   644 	TTime t1, t2, t3, t4, t5, t6;
   592 	TheStartTicks = User::FastCounter();
   645 	TTimeIntervalMicroSeconds prepareTime, nextTime, readTime;
       
   646 	
   593 	
   647 	RSqlStatement stmt;
   594 	RSqlStatement stmt;
   648 	t1.HomeTime();
       
   649 	TInt err = stmt.Prepare(TheDb, _L8("SELECT B FROM A WHERE ROWID=1"));
   595 	TInt err = stmt.Prepare(TheDb, _L8("SELECT B FROM A WHERE ROWID=1"));
   650 	t2.HomeTime();
   596 	TEST2(err, KErrNone);
   651 	TEST2(err, KErrNone);
   597 
   652 	prepareTime = t2.MicroSecondsFrom(t1);
       
   653 
       
   654 	t3.HomeTime();
       
   655 	err = stmt.Next();
   598 	err = stmt.Next();
   656 	t4.HomeTime();
       
   657 	TEST2(err, KSqlAtRow);
   599 	TEST2(err, KSqlAtRow);
   658 	nextTime = t4.MicroSecondsFrom(t3);
       
   659 
   600 
   660 	RSqlColumnReadStream strm;
   601 	RSqlColumnReadStream strm;
   661 	t5.HomeTime();
       
   662 	err = strm.ColumnBinary(stmt, 0);
   602 	err = strm.ColumnBinary(stmt, 0);
   663 	TEST2(err, KErrNone);
   603 	TEST2(err, KErrNone);
   664 	TRAP(err, strm.ReadL(dataptr, TheBlobSize));
   604 	TRAP(err, strm.ReadL(dataptr, TheBlobSize));
   665 	t6.HomeTime();
       
   666 	TEST2(err, KErrNone);
   605 	TEST2(err, KErrNone);
   667 	TEST2(dataptr.Length(), TheBlobSize);
   606 	TEST2(dataptr.Length(), TheBlobSize);
   668 	readTime = t6.MicroSecondsFrom(t5);
       
   669 
   607 
   670 	strm.Close();
   608 	strm.Close();
   671 	stmt.Close();
   609 	stmt.Close();
   672 	
   610 	
   673 	PrintReadTime(prepareTime, nextTime, readTime);
   611 	TheEndTicks = User::FastCounter();
   674 		
   612 		
   675 	delete data;
   613 	delete data;
   676 	}
   614 	}
   677 	
   615 	
   678 /**
   616 /**
   685 @SYMTestExpectedResults Test must not fail
   623 @SYMTestExpectedResults Test must not fail
   686 @SYMREQ					REQ5912
   624 @SYMREQ					REQ5912
   687 */
   625 */
   688 void BlobReadTest()
   626 void BlobReadTest()
   689 	{
   627 	{
   690 	TheTest.Printf(_L("Blob size=%d Kb\r\n"), TheBlobSize / 1024);
       
   691 	
       
   692 	// Insert a blob
   628 	// Insert a blob
   693 	TheTest.Printf(_L("==================================================================\r\n"));
   629 	CreateTestDb();
   694 	TheTest.Printf(_L("Insert blob\r\n"));
       
   695 		
       
   696 	CreateTestDb();
       
   697 	PrintFileSize(TheDb);
       
   698 	InsertBlobExec();
   630 	InsertBlobExec();
   699 	PrintFileSize(TheDb);
       
   700 	TheDb.Close();
   631 	TheDb.Close();
   701 		
   632 		
   702 	// Read the blob
   633 	// Read the blob
   703 	TheTest.Printf(_L("==================================================================\r\n"));
   634 		
   704 		
   635 	TheTestTitle.Copy(_L("Read blob - RSqlBlobReadStream"));
   705 	TheTest.Printf(_L("Read blob - RSqlBlobReadStream\r\n"));	
       
   706 	TInt err = TheDb.Open(TheDbFileName);
   636 	TInt err = TheDb.Open(TheDbFileName);
   707 	TEST2(err, KErrNone);
   637 	TEST2(err, KErrNone);
   708 	ReadBlobIncr();
   638 	ReadBlobIncr();
   709 	TheDb.Close();
   639 	TheDb.Close();
   710 
   640 	PrintReadStats();
   711 	TheTest.Printf(_L("Read blob - RSqlStatement::ColumnBinary(TInt, TDes8&)\r\n"));	
   641 
       
   642 	TheTestTitle.Copy(_L("Read blob - RSqlStatement::ColumnBinary(TInt, TDes8&)"));
   712 	err = TheDb.Open(TheDbFileName);
   643 	err = TheDb.Open(TheDbFileName);
   713 	TEST2(err, KErrNone);
   644 	TEST2(err, KErrNone);
   714 	ReadBlobColDes();
   645 	ReadBlobColDes();
   715 	TheDb.Close();
   646 	TheDb.Close();
   716 		
   647 	PrintReadStats();
   717 	TheTest.Printf(_L("Read blob - RSqlStatement::ColumnBinary(TInt, TPtrC8&)\r\n"));	
   648 		
       
   649 	TheTestTitle.Copy(_L("Read blob - RSqlStatement::ColumnBinary(TInt, TPtrC8&)"));
   718 	err = TheDb.Open(TheDbFileName);
   650 	err = TheDb.Open(TheDbFileName);
   719 	TEST2(err, KErrNone);
   651 	TEST2(err, KErrNone);
   720 	ReadBlobColPtr();
   652 	ReadBlobColPtr();
   721 	TheDb.Close();
   653 	TheDb.Close();
   722 		
   654 	PrintReadStats();
   723 	TheTest.Printf(_L("Read blob - RSqlColumnReadStream\r\n"));	
   655 		
       
   656 	TheTestTitle.Copy(_L("Read blob - RSqlColumnReadStream"));
   724 	err = TheDb.Open(TheDbFileName);
   657 	err = TheDb.Open(TheDbFileName);
   725 	TEST2(err, KErrNone);
   658 	TEST2(err, KErrNone);
   726 	ReadBlobStreamCol();
   659 	ReadBlobStreamCol();
   727 	TheDb.Close();
   660 	TheDb.Close();
       
   661 	PrintReadStats();
   728 		
   662 		
   729 	(void)RSqlDatabase::Delete(TheDbFileName);
   663 	(void)RSqlDatabase::Delete(TheDbFileName);
   730 	}
   664 	}
   731 	
   665 	
   732 /**
   666 /**
   747 	HBufC8* buf = HBufC8::NewL(KBufLen);
   681 	HBufC8* buf = HBufC8::NewL(KBufLen);
   748 	TPtr8 dataPtr =	buf->Des();
   682 	TPtr8 dataPtr =	buf->Des();
   749 	dataPtr.SetLength(KBufLen);
   683 	dataPtr.SetLength(KBufLen);
   750 	dataPtr.Fill('A', KBufLen);	
   684 	dataPtr.Fill('A', KBufLen);	
   751 	
   685 	
       
   686 	TheTestTitle.Copy(_L("Sequential BLOB writes"));
       
   687 	
   752 	CreateTestDb();
   688 	CreateTestDb();
   753 	InsertZeroBlob(); // insert zeroblob of "TheBlobSize" size
   689 	InsertZeroBlob(); // insert zeroblob of "TheBlobSize" size
   754 		
   690 		
       
   691 	TheDbSize1 = TheDb.Size();
       
   692 	TheStartTicks = User::FastCounter();
       
   693 	
   755 	RSqlBlobWriteStream strm;
   694 	RSqlBlobWriteStream strm;
   756 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   695 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   757 								
   696 								
   758 	// Sequentially write 32Kb blocks of data to the 
   697 	// Sequentially write 32Kb blocks of data to the 
   759 	// blob until the 1Mb cache is full and writes to the disk begin.
   698 	// blob until the 1Mb cache is full and writes to the disk begin.
   760 	// 32 * 32Kb = 1Mb = soft heap limit
   699 	// 32 * 32Kb = 1Mb = soft heap limit
   761 	const TInt KItCount = TheBlobSize / KBufLen - 1;
   700 	const TInt KItCount = TheBlobSize / KBufLen - 1;
   762 	for(TInt i = 1; i <= KItCount; ++i)
   701 	for(TInt i = 1; i <= KItCount; ++i)
   763 		{
   702 		{
   764 		TheTest.Printf(_L("***Iteration %d\r\n"), i);
       
   765 		
       
   766 		PrintFileSize(TheDb);
       
   767 	
       
   768 		TTimeIntervalMicroSeconds writeTime;
       
   769 		TTime t1, t2;
       
   770 
       
   771 		t1.HomeTime();
       
   772 		strm.WriteL(dataPtr);
   703 		strm.WriteL(dataPtr);
   773 		t2.HomeTime();		
       
   774 
       
   775 		writeTime = t2.MicroSecondsFrom(t1);
       
   776 							
       
   777 		PrintWriteTime(TTimeIntervalMicroSeconds(0), writeTime, TTimeIntervalMicroSeconds(0));		
       
   778 		PrintFileSize(TheDb);		
       
   779 		}	
   704 		}	
   780 			
       
   781 	TTimeIntervalMicroSeconds commitTime;
       
   782 	TTime t3, t4;
       
   783 	t3.HomeTime();
       
   784 	strm.CommitL();
   705 	strm.CommitL();
   785 	t4.HomeTime();	
   706 	strm.Close();
   786 	commitTime = t4.MicroSecondsFrom(t3);
   707 	
   787 		
   708 	TheEndTicks = User::FastCounter();
   788 	PrintWriteTime(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0), commitTime);		
   709 	TheDbSize2 = TheDb.Size();
   789 	PrintFileSize(TheDb);		
   710 	
   790 			
   711 	TheDb.Close();
   791 	strm.Close();		
   712 	(void)RSqlDatabase::Delete(TheDbFileName);
   792 	TheDb.Close();
   713 	
   793 	(void)RSqlDatabase::Delete(TheDbFileName);
   714 	PrintWriteStats();
   794 		
   715 		
   795 	delete buf;
   716 	delete buf;
   796 	}
   717 	}
   797 	
   718 	
   798 /**
   719 /**
   813 	const TInt KBufLen = 32768; // 32Kb
   734 	const TInt KBufLen = 32768; // 32Kb
   814 	HBufC8* buf = HBufC8::NewL(KBufLen);
   735 	HBufC8* buf = HBufC8::NewL(KBufLen);
   815 	TPtr8 dataPtr =	buf->Des();
   736 	TPtr8 dataPtr =	buf->Des();
   816 	dataPtr.SetLength(KBufLen);
   737 	dataPtr.SetLength(KBufLen);
   817 	dataPtr.Fill('A', KBufLen);	
   738 	dataPtr.Fill('A', KBufLen);	
       
   739 
       
   740 	TheTestTitle.Copy(_L("Sequential BLOB writes in transaction"));
   818 	
   741 	
   819 	CreateTestDb();
   742 	CreateTestDb();
   820 	InsertZeroBlob(); // insert zeroblob of "TheBlobSize" size
   743 	InsertZeroBlob(); // insert zeroblob of "TheBlobSize" size
   821 		
   744 		
       
   745 	TheDbSize1 = TheDb.Size();
       
   746 	TheStartTicks = User::FastCounter();
       
   747 	
   822 	RSqlBlobWriteStream strm;
   748 	RSqlBlobWriteStream strm;
   823 	strm.OpenL(TheDb, _L("A"), _L("B"));
   749 	strm.OpenL(TheDb, _L("A"), _L("B"));
   824 	
   750 	
   825 	TInt err = TheDb.Exec(_L8("BEGIN"));
   751 	TInt err = TheDb.Exec(_L8("BEGIN"));
   826 	TEST(err >= 0);	
   752 	TEST(err >= 0);	
   829 	// blob until the 1Mb cache is full and writes to the disk begin.
   755 	// blob until the 1Mb cache is full and writes to the disk begin.
   830 	// 32 * 32Kb = 1Mb = soft heap limit
   756 	// 32 * 32Kb = 1Mb = soft heap limit
   831 	const TInt KItCount = TheBlobSize / KBufLen - 1;
   757 	const TInt KItCount = TheBlobSize / KBufLen - 1;
   832 	for(TInt i = 1; i <= KItCount; ++i)
   758 	for(TInt i = 1; i <= KItCount; ++i)
   833 		{
   759 		{
   834 		TheTest.Printf(_L("***Iteration %d\r\n"), i);
       
   835 		
       
   836 		PrintFileSize(TheDb);
       
   837 	
       
   838 		TTimeIntervalMicroSeconds writeTime;
       
   839 		TTime t1, t2;
       
   840 		
       
   841 		t1.HomeTime();
       
   842 		strm.WriteL(dataPtr);
   760 		strm.WriteL(dataPtr);
   843 		t2.HomeTime();	
       
   844 
       
   845 		writeTime = t2.MicroSecondsFrom(t1);
       
   846 							
       
   847 		PrintWriteTime(TTimeIntervalMicroSeconds(0), writeTime, TTimeIntervalMicroSeconds(0));		
       
   848 		PrintFileSize(TheDb);		
       
   849 		}	
   761 		}	
   850 		
       
   851 	TTimeIntervalMicroSeconds commitTime;
       
   852 	TTime t3, t4;
       
   853 	
       
   854 	t3.HomeTime();
       
   855 	strm.CommitL();
   762 	strm.CommitL();
   856 	t4.HomeTime();	
       
   857 	commitTime = t4.MicroSecondsFrom(t3);
       
   858 
       
   859 	PrintWriteTime(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0), commitTime);		
       
   860 	PrintFileSize(TheDb);		
       
   861 		
       
   862 	TTime t5, t6;
       
   863 	t5.HomeTime();	
       
   864 	err = TheDb.Exec(_L8("COMMIT"));
   763 	err = TheDb.Exec(_L8("COMMIT"));
   865 	t6.HomeTime();	
       
   866 	TEST(err >= 0);
   764 	TEST(err >= 0);
   867 	
   765 	strm.Close();
   868 	TTimeIntervalMicroSeconds transCommitTime = t6.MicroSecondsFrom(t5);		
   766 
   869 	PrintWriteTime(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(0), transCommitTime);		
   767 	TheEndTicks = User::FastCounter();
   870 	PrintFileSize(TheDb);	
   768 	TheDbSize2 = TheDb.Size();
   871 			
   769 	
   872 	strm.Close();		
   770 	TheDb.Close();
   873 	TheDb.Close();
   771 	(void)RSqlDatabase::Delete(TheDbFileName);
   874 	(void)RSqlDatabase::Delete(TheDbFileName);
   772 
   875 		
   773 	PrintWriteStats();
       
   774 	
   876 	delete buf;
   775 	delete buf;
   877 	}
   776 	}
   878 
   777 
   879 /**
   778 /**
   880 @SYMTestCaseID			SYSLIB-SQL-UT-4117
   779 @SYMTestCaseID			SYSLIB-SQL-UT-4117
   891 	TInt bufLen = TheBlobSize; 
   790 	TInt bufLen = TheBlobSize; 
   892 	HBufC8* buf = HBufC8::NewL(bufLen);
   791 	HBufC8* buf = HBufC8::NewL(bufLen);
   893 	TPtr8 dataPtr =	buf->Des();
   792 	TPtr8 dataPtr =	buf->Des();
   894 	dataPtr.SetLength(bufLen);
   793 	dataPtr.SetLength(bufLen);
   895 	dataPtr.Fill('Z', bufLen);	
   794 	dataPtr.Fill('Z', bufLen);	
       
   795 
       
   796 	TheTestTitle.Copy(_L("Whole BLOB write - TSqlBlob::Set()"));
   896 	
   797 	
   897 	CreateTestDb();
   798 	CreateTestDb();
   898 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   799 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   899 			
   800 			
   900 	TheTest.Printf(_L("***WholeWriteTestL - %dKb blob \r\n"), TheBlobSize / 1024);		
   801 	TheDbSize1 = TheDb.Size();
   901 	PrintFileSize(TheDb);
   802 	TheStartTicks = User::FastCounter();
   902 	
   803 	
   903 	// TSqlBlob::Set
       
   904 	TTimeIntervalMicroSeconds writeTime;
       
   905 	TTime t1, t2, t3, t4;
       
   906 
       
   907 	t1.HomeTime();
       
   908 	TSqlBlob::SetL(TheDb, _L("A"), _L("B"), dataPtr);	
   804 	TSqlBlob::SetL(TheDb, _L("A"), _L("B"), dataPtr);	
   909 	t2.HomeTime();	
   805 		
   910 		
   806 	TheEndTicks = User::FastCounter();
   911 	writeTime = t2.MicroSecondsFrom(t1);
   807 	TheDbSize2 = TheDb.Size();
   912 								
   808 
   913 	PrintWriteTime(TTimeIntervalMicroSeconds(0), writeTime, TTimeIntervalMicroSeconds(0));		
   809 	PrintWriteStats();
   914 	PrintFileSize(TheDb);
   810 	
   915 	
   811 	TheDb.Close();
       
   812 	(void)RSqlDatabase::Delete(TheDbFileName);		
       
   813 
   916 	// to avoid caching issues, close and re-create the database for the next part
   814 	// to avoid caching issues, close and re-create the database for the next part
   917 	TheDb.Close();
   815 	
   918 	(void)RSqlDatabase::Delete(TheDbFileName);		
   816 	TheTestTitle.Copy(_L("Whole BLOB write - RSqlBlobWriteStream::WriteL()"));
       
   817 	
   919 	CreateTestDb();
   818 	CreateTestDb();
   920 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   819 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   921 	PrintFileSize(TheDb);
   820 
   922 
   821 	TheDbSize1 = TheDb.Size();
   923 	// RSqlBlobWriteStream::WriteL
   822 	TheStartTicks = User::FastCounter();
   924 	t3.HomeTime();
   823 	
   925 	RSqlBlobWriteStream strm;
   824 	RSqlBlobWriteStream strm;
   926 	CleanupClosePushL(strm);
   825 	CleanupClosePushL(strm);
   927 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   826 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   928 	strm.WriteL(dataPtr);
   827 	strm.WriteL(dataPtr);
   929 	CleanupStack::PopAndDestroy(&strm);
   828 	CleanupStack::PopAndDestroy(&strm);
   930 	t4.HomeTime();	
   829 		
   931 		
   830 	TheEndTicks = User::FastCounter();
   932 	writeTime = t4.MicroSecondsFrom(t3);
   831 	TheDbSize2 = TheDb.Size();
   933 							
   832 	PrintWriteStats();
   934 	PrintWriteTime(TTimeIntervalMicroSeconds(0), writeTime, TTimeIntervalMicroSeconds(0));		
       
   935 	PrintFileSize(TheDb);				
       
   936 				
   833 				
   937 	TheDb.Close();
   834 	TheDb.Close();
   938 	(void)RSqlDatabase::Delete(TheDbFileName);
   835 	(void)RSqlDatabase::Delete(TheDbFileName);
   939 		
   836 		
   940 	delete buf;
   837 	delete buf;
   957 	HBufC8* buf = HBufC8::NewL(bufLen);
   854 	HBufC8* buf = HBufC8::NewL(bufLen);
   958 	TPtr8 dataPtr =	buf->Des();
   855 	TPtr8 dataPtr =	buf->Des();
   959 	dataPtr.SetLength(bufLen);
   856 	dataPtr.SetLength(bufLen);
   960 	dataPtr.Fill('Z', bufLen);	
   857 	dataPtr.Fill('Z', bufLen);	
   961 	
   858 	
       
   859 	TheTestTitle.Copy(_L("Whole BLOB write - TSqlBlob::Set() in transaction"));
       
   860 	
   962 	CreateTestDb();
   861 	CreateTestDb();
   963 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   862 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   964 	
   863 	
   965 	TheTest.Printf(_L("***TransWholeWriteTestL - %dKb blob\r\n"), TheBlobSize / 1024);	
   864 	TheDbSize1 = TheDb.Size();
   966 	PrintFileSize(TheDb);
   865 	TheStartTicks = User::FastCounter();
   967 		
   866 		
   968 	// TSqlBlob::Set
       
   969 	TTimeIntervalMicroSeconds writeTime;
       
   970 	TTime t1, t2, t3, t4;
       
   971 
       
   972 	t1.HomeTime();
       
   973 	TInt err = TheDb.Exec(_L8("BEGIN"));
   867 	TInt err = TheDb.Exec(_L8("BEGIN"));
   974 	TEST(err >= 0);		
   868 	TEST(err >= 0);		
   975 	TSqlBlob::SetL(TheDb, _L("A"), _L("B"), dataPtr);			
   869 	TSqlBlob::SetL(TheDb, _L("A"), _L("B"), dataPtr);			
   976 	err = TheDb.Exec(_L8("COMMIT"));
   870 	err = TheDb.Exec(_L8("COMMIT"));
   977 	t2.HomeTime();	
       
   978 	TEST(err >= 0);	
   871 	TEST(err >= 0);	
   979 
   872 
   980 	writeTime = t2.MicroSecondsFrom(t1);
   873 	TheEndTicks = User::FastCounter();
   981 							
   874 	TheDbSize2 = TheDb.Size();
   982 	PrintWriteTime(TTimeIntervalMicroSeconds(0), writeTime, TTimeIntervalMicroSeconds(0));		
   875 
   983 	PrintFileSize(TheDb);	
   876 	PrintWriteStats();
   984 	
   877 	
       
   878 	TheDb.Close();
       
   879 	(void)RSqlDatabase::Delete(TheDbFileName);
       
   880 
   985 	// to avoid caching issues, close and re-create the database for the next part
   881 	// to avoid caching issues, close and re-create the database for the next part
   986 	TheDb.Close();
   882 	
   987 	(void)RSqlDatabase::Delete(TheDbFileName);
   883 	TheTestTitle.Copy(_L("Whole BLOB write - RSqlBlobWriteStream::WriteL() in transaction"));
       
   884 	
   988 	CreateTestDb();
   885 	CreateTestDb();
   989 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   886 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   990 	PrintFileSize(TheDb);
   887 	
   991 	
   888 	TheDbSize1 = TheDb.Size();
   992 	// RSqlBlobWriteStream::WriteL
   889 	TheStartTicks = User::FastCounter();
   993 	t3.HomeTime();
   890 	
   994 	err = TheDb.Exec(_L8("BEGIN"));
   891 	err = TheDb.Exec(_L8("BEGIN"));
   995 	TEST(err >= 0);	
   892 	TEST(err >= 0);	
   996 	RSqlBlobWriteStream strm;
   893 	RSqlBlobWriteStream strm;
   997 	CleanupClosePushL(strm);
   894 	CleanupClosePushL(strm);
   998 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   895 	strm.OpenL(TheDb, _L("A"), _L("B"));	
   999 	strm.WriteL(dataPtr);
   896 	strm.WriteL(dataPtr);
  1000 	CleanupStack::PopAndDestroy(&strm);
   897 	CleanupStack::PopAndDestroy(&strm);
  1001 	err = TheDb.Exec(_L8("COMMIT"));
   898 	err = TheDb.Exec(_L8("COMMIT"));
  1002 	t4.HomeTime();
       
  1003 	TEST(err >= 0);	
   899 	TEST(err >= 0);	
  1004 
   900 
  1005 	writeTime = t4.MicroSecondsFrom(t3);
   901 	TheEndTicks = User::FastCounter();
  1006 							
   902 	TheDbSize2 = TheDb.Size();
  1007 	PrintWriteTime(TTimeIntervalMicroSeconds(0), writeTime, TTimeIntervalMicroSeconds(0));		
   903 
  1008 	PrintFileSize(TheDb);				
   904 	PrintWriteStats();
  1009 				
   905 				
  1010 	TheDb.Close();
   906 	TheDb.Close();
  1011 	(void)RSqlDatabase::Delete(TheDbFileName);
   907 	(void)RSqlDatabase::Delete(TheDbFileName);
  1012 		
   908 		
  1013 	delete buf;
   909 	delete buf;
  1029 	HBufC8* buf = HBufC8::NewL(bufLen);
   925 	HBufC8* buf = HBufC8::NewL(bufLen);
  1030 	TPtr8 dataPtr =	buf->Des();
   926 	TPtr8 dataPtr =	buf->Des();
  1031 	dataPtr.SetLength(bufLen);
   927 	dataPtr.SetLength(bufLen);
  1032 	dataPtr.Fill('A', bufLen);	
   928 	dataPtr.Fill('A', bufLen);	
  1033 	
   929 	
       
   930 	TheTestTitle.Copy(_L("Whole BLOB read - TSqlBlob::GetLC()"));
       
   931 	
  1034 	CreateTestDb();
   932 	CreateTestDb();
  1035 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   933 	InsertRealBlob(); // insert blob of "TheBlobSize" size
  1036 	
   934 
  1037 	TheTest.Printf(_L("***WholeReadTestL - %dKb blob \r\n"), TheBlobSize / 1024);
   935 	TheDbSize1 = TheDb.Size();
  1038 	PrintFileSize(TheDb);
   936 	TheStartTicks = User::FastCounter();
  1039 	
   937 	
  1040 	// TSqlBlob::GetLC
       
  1041 	TTimeIntervalMicroSeconds readTime;
       
  1042 	TTime t1, t2, t3, t4, t5, t6;
       
  1043 
       
  1044 	t1.HomeTime();
       
  1045 	HBufC8* readBuf = TSqlBlob::GetLC(TheDb, _L("A"), _L("B"));
   938 	HBufC8* readBuf = TSqlBlob::GetLC(TheDb, _L("A"), _L("B"));
  1046 	t2.HomeTime();
   939 	TheEndTicks = User::FastCounter();
       
   940 	TheDbSize2 = TheDb.Size();
       
   941 	
  1047 	TEST(readBuf->Des().Compare(buf->Des()) == 0);
   942 	TEST(readBuf->Des().Compare(buf->Des()) == 0);
  1048 	
       
  1049 	readTime = t2.MicroSecondsFrom(t1);
       
  1050 							
       
  1051 	PrintReadTime(TTimeIntervalMicroSeconds(0), readTime);
       
  1052 	PrintFileSize(TheDb);				
       
  1053 	CleanupStack::PopAndDestroy(readBuf);
   943 	CleanupStack::PopAndDestroy(readBuf);
  1054 	
   944 	
       
   945 	PrintReadStats();
       
   946 	
       
   947 	TheDb.Close();
       
   948 	(void)RSqlDatabase::Delete(TheDbFileName);
       
   949 	
  1055 	// to avoid caching issues, close and re-create the database for the next part
   950 	// to avoid caching issues, close and re-create the database for the next part
  1056 	TheDb.Close();
   951 	TheTestTitle.Copy(_L("Whole BLOB read - TSqlBlob::Get()"));
  1057 	(void)RSqlDatabase::Delete(TheDbFileName);
   952 	
  1058 	CreateTestDb();
   953 	CreateTestDb();
  1059 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   954 	InsertRealBlob(); // insert blob of "TheBlobSize" size
  1060 	PrintFileSize(TheDb);
   955 	
  1061 	
       
  1062 	// TSqlBlob::Get
       
  1063 	HBufC8* preBuf = HBufC8::NewLC(bufLen);
   956 	HBufC8* preBuf = HBufC8::NewLC(bufLen);
  1064 	TPtr8 preBufPtr(preBuf->Des());
   957 	TPtr8 preBufPtr(preBuf->Des());
  1065 	t3.HomeTime();
   958 	
       
   959 	TheDbSize1 = TheDb.Size();
       
   960 	TheStartTicks = User::FastCounter();
       
   961 	
  1066 	TInt err = TSqlBlob::Get(TheDb, _L("A"), _L("B"), preBufPtr);	
   962 	TInt err = TSqlBlob::Get(TheDb, _L("A"), _L("B"), preBufPtr);	
  1067 	t4.HomeTime();
   963 	TEST2(err, KErrNone);
  1068 	TEST2(err, KErrNone);
   964 	
       
   965 	TheEndTicks = User::FastCounter();
       
   966 	TheDbSize2 = TheDb.Size();
       
   967 	
  1069 	TEST(preBufPtr.Compare(buf->Des()) == 0);
   968 	TEST(preBufPtr.Compare(buf->Des()) == 0);
  1070 
       
  1071 	readTime = t4.MicroSecondsFrom(t3);
       
  1072 							
       
  1073 	PrintReadTime(TTimeIntervalMicroSeconds(0), readTime);
       
  1074 	PrintFileSize(TheDb);				
       
  1075 	CleanupStack::PopAndDestroy(preBuf);
   969 	CleanupStack::PopAndDestroy(preBuf);
  1076 	
   970 	
       
   971 	PrintReadStats();
       
   972 	
       
   973 	TheDb.Close();
       
   974 	(void)RSqlDatabase::Delete(TheDbFileName);
       
   975 	
  1077 	// to avoid caching issues, close and re-create the database for the next part
   976 	// to avoid caching issues, close and re-create the database for the next part
  1078 	TheDb.Close();
   977 	TheTestTitle.Copy(_L("Whole BLOB read - RSqlBlobReadStream::ReadL()"));
  1079 	(void)RSqlDatabase::Delete(TheDbFileName);
   978 	
  1080 	CreateTestDb();
   979 	CreateTestDb();
  1081 	InsertRealBlob(); // insert blob of "TheBlobSize" size
   980 	InsertRealBlob(); // insert blob of "TheBlobSize" size
  1082 	PrintFileSize(TheDb);
   981 	
  1083 	
       
  1084 	// RSqlBlobReadStream::ReadL
       
  1085 	preBuf = HBufC8::NewLC(bufLen);	
   982 	preBuf = HBufC8::NewLC(bufLen);	
  1086 	TPtr8 preBufP(preBuf->Des());
   983 	TPtr8 preBufP(preBuf->Des());
  1087 	t5.HomeTime();
   984 	
       
   985 	TheDbSize1 = TheDb.Size();
       
   986 	TheStartTicks = User::FastCounter();
       
   987 	
  1088 	RSqlBlobReadStream strm;
   988 	RSqlBlobReadStream strm;
  1089 	CleanupClosePushL(strm);
   989 	CleanupClosePushL(strm);
  1090 	strm.OpenL(TheDb, _L("A"), _L("B"));
   990 	strm.OpenL(TheDb, _L("A"), _L("B"));
  1091 	strm.ReadL(preBufP, bufLen);
   991 	strm.ReadL(preBufP, bufLen);
  1092 	CleanupStack::PopAndDestroy(&strm);
   992 	CleanupStack::PopAndDestroy(&strm);
  1093 	t6.HomeTime();
   993 
       
   994 	TheEndTicks = User::FastCounter();
       
   995 	TheDbSize2 = TheDb.Size();
       
   996 	
  1094 	TEST(preBufP.Compare(buf->Des()) == 0);
   997 	TEST(preBufP.Compare(buf->Des()) == 0);
  1095 		
       
  1096 	readTime = t6.MicroSecondsFrom(t5);
       
  1097 							
       
  1098 	PrintReadTime(TTimeIntervalMicroSeconds(0), readTime);
       
  1099 	PrintFileSize(TheDb);	
       
  1100 	CleanupStack::PopAndDestroy(preBuf);
   998 	CleanupStack::PopAndDestroy(preBuf);
  1101 			
   999 
       
  1000 	PrintReadStats();
       
  1001 	
  1102 	TheDb.Close();
  1002 	TheDb.Close();
  1103 	(void)RSqlDatabase::Delete(TheDbFileName);
  1003 	(void)RSqlDatabase::Delete(TheDbFileName);
  1104 		
  1004 		
  1105 	delete buf;
  1005 	delete buf;
  1106 	}
  1006 	}
  1117 	TheTestTitle.Format(_L("@SYMTestCaseID:SYSLIB-SQL-UT-4085 SQL, BLOB read, performance tests, encoding: \"%S\", page size: %d\r\n"), 
  1017 	TheTestTitle.Format(_L("@SYMTestCaseID:SYSLIB-SQL-UT-4085 SQL, BLOB read, performance tests, encoding: \"%S\", page size: %d\r\n"), 
  1118 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1018 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1119 	TheTest.Next(TheTestTitle);
  1019 	TheTest.Next(TheTestTitle);
  1120 	BlobReadTest();
  1020 	BlobReadTest();
  1121 
  1021 
  1122 	TheTest.Printf(_L("==================================================================\r\n"));
       
  1123 	
       
  1124 	// Bigger blob tests - only on hardware, release mode
       
  1125 #if !defined __WINS__ && !defined __WINSCW__ && !defined _DEBUG
       
  1126 	
       
  1127 	TheBlobSize = 1024 * 1024 + 128 * 1024;//1.125Mb 
  1022 	TheBlobSize = 1024 * 1024 + 128 * 1024;//1.125Mb 
  1128 
  1023 
  1129 	TheTestTitle.Format(_L("@SYMTestCaseID:SYSLIB-SQL-UT-4115 SQL, sequential BLOB writes, performance tests, encoding: \"%S\", page size: %d\r\n"), 
  1024 	TheTestTitle.Format(_L("@SYMTestCaseID:SYSLIB-SQL-UT-4115 SQL, sequential BLOB writes, performance tests, encoding: \"%S\", page size: %d\r\n"), 
  1130 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1025 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1131 	TheTest.Next(TheTestTitle);
  1026 	TheTest.Next(TheTestTitle);
  1155 	TheTestTitle.Format(_L("@SYMTestCaseID:SYSLIB-SQL-UT-4119 SQL, whole BLOB read, performance tests, encoding: \"%S\", page size: %d\r\n"), 
  1050 	TheTestTitle.Format(_L("@SYMTestCaseID:SYSLIB-SQL-UT-4119 SQL, whole BLOB read, performance tests, encoding: \"%S\", page size: %d\r\n"), 
  1156 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1051 			TheCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf16 ? &KUtf16 : &KUtf8, TheCmdLineParams.iPageSize);
  1157 	TheTest.Next(TheTestTitle);
  1052 	TheTest.Next(TheTestTitle);
  1158 	TRAP(err, WholeReadTestL());
  1053 	TRAP(err, WholeReadTestL());
  1159 	TEST2(err, KErrNone);
  1054 	TEST2(err, KErrNone);
  1160 	
       
  1161 #endif//!defined __WINS__ && !defined __WINSCW__ && !defined _DEBUG
       
  1162 	}
  1055 	}
  1163 
  1056 
  1164 TInt E32Main()
  1057 TInt E32Main()
  1165 	{
  1058 	{
  1166 	TheTest.Title();
  1059 	TheTest.Title();