os/persistentdata/persistentstorage/sql/TEST/t_sqloom2.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "t_sqloom.h"
sl@0
    17
sl@0
    18
RTest TheTest(_L("t_sqloom2 test"));
sl@0
    19
sl@0
    20
const TInt KSqlBufMaxLen = 16 * 1024;
sl@0
    21
const TInt KBlobStrLen = KSqlBufMaxLen / 2 - 100;
sl@0
    22
const TInt KBlobLen = KBlobStrLen;
sl@0
    23
sl@0
    24
TBuf8<KSqlBufMaxLen> TheSqlBuf;
sl@0
    25
TBuf8<KBlobStrLen> TheSqlBuf2;
sl@0
    26
sl@0
    27
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    28
///////////////         RSqlStatement OOM tests         ///////////////////////////////
sl@0
    29
///////////////////////////////////////////////////////////////////////////////////////
sl@0
    30
sl@0
    31
_LIT8(KSqlDbString, "BEGIN;\
sl@0
    32
					 CREATE TABLE BBB(Fld1 INTEGER, Fld2 BIGINT, Fld3 DOUBLE, Fld4 TEXT, Fld5 LONGBLOB);\
sl@0
    33
                     INSERT INTO BBB(fld1, fld2, fld3, fld4) VALUES(4562, 123456789012345, 78612.0091, 'text data');\
sl@0
    34
                     COMMIT;");
sl@0
    35
_LIT8(KSqlDbString2,"INSERT INTO BBB(fld1, fld2, fld3, fld4) VALUES(1, 34, 10.9897, 'data2');");
sl@0
    36
sl@0
    37
const TInt KLongColumnSize = 3013;
sl@0
    38
const TInt KLongParameterSize = 4501;
sl@0
    39
sl@0
    40
#define MAX(a, b) ((a) > (b) ? (a) : (b))
sl@0
    41
sl@0
    42
static TUint16 TheTextColumnData[MAX(KLongColumnSize, KLongParameterSize)];
sl@0
    43
static TUint8 TheBinaryColumnData[MAX(KLongColumnSize, KLongParameterSize) * sizeof(TUint16)];
sl@0
    44
sl@0
    45
//"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement)
sl@0
    46
void PrepareStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
    47
	{
sl@0
    48
	_LIT8(KSqlString, "SELECT * FROM BBB WHERE Fld1=? AND Fld4<>?");
sl@0
    49
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
    50
	User::LeaveIfError(err);
sl@0
    51
	}
sl@0
    52
sl@0
    53
//"RSqlStatement::PrepareL()" OOM test (8-bit SELECT SQL statement)
sl@0
    54
void PrepareStmt8_2L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
    55
	{
sl@0
    56
	_LIT8(KSqlString, "SELECT * FROM BBB WHERE Fld1=? AND Fld4<>?");
sl@0
    57
	aStmt.PrepareL(aDb, KSqlString);
sl@0
    58
	}
sl@0
    59
sl@0
    60
//"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement), syntax error
sl@0
    61
void PrepareBadStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
    62
	{
sl@0
    63
	_LIT8(KSqlString, "SELECT123 * FROM BBB WHERE Fld1=? AND Fld4<>?");
sl@0
    64
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
    65
	User::LeaveIfError(err);
sl@0
    66
	}
sl@0
    67
sl@0
    68
//"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement, move next)
sl@0
    69
void PrepareMoveStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
    70
	{
sl@0
    71
	_LIT8(KSqlString, "SELECT * FROM BBB WHERE Fld1=? AND Fld4<>?");
sl@0
    72
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
    73
    User::LeaveIfError(err);
sl@0
    74
    err = aStmt.BindInt(0, 1);
sl@0
    75
    User::LeaveIfError(err);
sl@0
    76
    err = aStmt.BindText(1, _L("data244weewfn43wr83224iu23ewkjfbrektug4i433b3k45b"));
sl@0
    77
    User::LeaveIfError(err);
sl@0
    78
    err = aStmt.Next();
sl@0
    79
    if(err == KSqlAtRow)
sl@0
    80
        {
sl@0
    81
        err = KErrNone;
sl@0
    82
        }
sl@0
    83
	User::LeaveIfError(err);
sl@0
    84
	}
sl@0
    85
sl@0
    86
//"RSqlStatement::Prepare()" OOM test (8-bit INSERT SQL statement)
sl@0
    87
void PrepareInsertStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
    88
	{
sl@0
    89
	_LIT8(KSqlString, "INSERT INTO BBB(fld1, fld2, fld3, fld4) VALUES(2, 22, 22.2222, '2-2-2-2');");
sl@0
    90
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
    91
	User::LeaveIfError(err);
sl@0
    92
	}
sl@0
    93
sl@0
    94
//"RSqlStatement::Prepare(), RSqlStatement::Exec(), RSqlStatement::Next()" OOM test (8-bit INSERT SQL statement, long column)
sl@0
    95
void ExecInsertNextStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
    96
	{
sl@0
    97
	_LIT8(KSqlString1, "INSERT INTO BBB(fld1, fld2, fld3, fld4, fld5) VALUES(10, 100, 100.001, :Prm1, :Prm2);");
sl@0
    98
	_LIT8(KSqlString2, "SELECT * FROM BBB WHERE fld1 = 10");
sl@0
    99
	TInt err = aStmt.Prepare(aDb, KSqlString1);
sl@0
   100
	if(err == KErrNone)
sl@0
   101
		{
sl@0
   102
		for(TInt i=0;i<KLongColumnSize;++i)
sl@0
   103
			{
sl@0
   104
			TheTextColumnData[i] = (TUint16)i;
sl@0
   105
			}
sl@0
   106
		const TPtrC textVal(TheTextColumnData, KLongColumnSize);
sl@0
   107
		const TPtrC8 binVal((TUint8*)TheTextColumnData, KLongColumnSize * sizeof(TUint16));
sl@0
   108
		TInt err = aStmt.BindText(0, textVal);
sl@0
   109
		if(err == KErrNone)
sl@0
   110
			{
sl@0
   111
			err = aStmt.BindBinary(1, binVal);
sl@0
   112
			}
sl@0
   113
		if(err == KErrNone)
sl@0
   114
			{
sl@0
   115
			err = aStmt.Exec();
sl@0
   116
			}
sl@0
   117
		}
sl@0
   118
	if(err >= 0)
sl@0
   119
		{
sl@0
   120
		aStmt.Close();
sl@0
   121
		err = aStmt.Prepare(aDb, KSqlString2);
sl@0
   122
		if(err == KErrNone)
sl@0
   123
			{
sl@0
   124
			err = aStmt.Next();
sl@0
   125
			}
sl@0
   126
		}
sl@0
   127
	User::LeaveIfError(err);
sl@0
   128
	}
sl@0
   129
sl@0
   130
//"RSqlStatement::Prepare()" OOM test (8-bit INSERT SQL statement with parameters)
sl@0
   131
void PrepareInsertPrmStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   132
	{
sl@0
   133
	_LIT8(KSqlString, "INSERT INTO BBB(fld1, fld2, fld3, fld4) VALUES(:Prm0, :Prm1, :Prm2, :Prm3);");
sl@0
   134
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
   135
	User::LeaveIfError(err);
sl@0
   136
	}
sl@0
   137
sl@0
   138
//"RSqlStatement::Prepare()" OOM test (16-bit SELECT SQL statement)
sl@0
   139
void PrepareStmt16L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   140
	{
sl@0
   141
	_LIT(KSqlString, "SELECT * FROM BBB");
sl@0
   142
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
   143
	User::LeaveIfError(err);
sl@0
   144
	}
sl@0
   145
sl@0
   146
//"RSqlStatement::PrepareL()" OOM test (16-bit SELECT SQL statement)
sl@0
   147
void PrepareStmt16_2L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   148
	{
sl@0
   149
	_LIT(KSqlString, "SELECT * FROM BBB");
sl@0
   150
	aStmt.PrepareL(aDb, KSqlString);
sl@0
   151
	}
sl@0
   152
sl@0
   153
//"RSqlStatement::Prepare()" OOM test (16-bit SELECT SQL statement), syntax error
sl@0
   154
void PrepareBadStmt16L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   155
	{
sl@0
   156
	_LIT(KSqlString, "23478SELECT * FROM BBB");
sl@0
   157
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
   158
	User::LeaveIfError(err);
sl@0
   159
	}
sl@0
   160
sl@0
   161
//"RSqlStatement::Prepare()" OOM test (16-bit SELECT SQL statement, move next)
sl@0
   162
void PrepareMoveStmt16L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   163
	{
sl@0
   164
	_LIT(KSqlString, "SELECT * FROM BBB");
sl@0
   165
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
   166
	if(err == KErrNone)
sl@0
   167
		{
sl@0
   168
		err = aStmt.Next();
sl@0
   169
		if(err == KSqlAtRow)
sl@0
   170
			{
sl@0
   171
			err = KErrNone;
sl@0
   172
			}
sl@0
   173
		}
sl@0
   174
	User::LeaveIfError(err);
sl@0
   175
	}
sl@0
   176
sl@0
   177
//"RSqlStatement::Prepare()" OOM test (16-bit INSERT SQL statement)
sl@0
   178
void PrepareInsertStmt16L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   179
	{
sl@0
   180
	_LIT(KSqlString, "INSERT INTO BBB(fld1, fld2, fld3, fld4) VALUES(2, 22, 22.2222, '2-2-2-2');");
sl@0
   181
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
   182
	User::LeaveIfError(err);
sl@0
   183
	}
sl@0
   184
sl@0
   185
//"RSqlStatement::Prepare(), RSqlStatement::Exec(), RSqlStatement::Next()" OOM test (16-bit INSERT SQL statement, long column)
sl@0
   186
void ExecInsertNextStmt16L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   187
	{
sl@0
   188
	_LIT(KSqlString1, "INSERT INTO BBB(fld1, fld2, fld3, fld4, fld5) VALUES(10, 100, 100.001, :Prm1, :Prm2);");
sl@0
   189
	_LIT(KSqlString2, "SELECT * FROM BBB WHERE fld1 = 10");
sl@0
   190
	TInt err = aStmt.Prepare(aDb, KSqlString1);
sl@0
   191
	if(err == KErrNone)
sl@0
   192
		{
sl@0
   193
		for(TInt i=0;i<KLongColumnSize;++i)
sl@0
   194
			{
sl@0
   195
			TheTextColumnData[i] = (TUint16)i;
sl@0
   196
			}
sl@0
   197
		const TPtrC textVal(TheTextColumnData, KLongColumnSize);
sl@0
   198
		const TPtrC8 binVal((TUint8*)TheTextColumnData, KLongColumnSize * sizeof(TUint16));
sl@0
   199
		TInt err = aStmt.BindText(0, textVal);
sl@0
   200
		if(err == KErrNone)
sl@0
   201
			{
sl@0
   202
			err = aStmt.BindBinary(1, binVal);
sl@0
   203
			}
sl@0
   204
		if(err == KErrNone)
sl@0
   205
			{
sl@0
   206
			err = aStmt.Exec();
sl@0
   207
			}
sl@0
   208
		}
sl@0
   209
	if(err >= 0)
sl@0
   210
		{
sl@0
   211
		aStmt.Close();
sl@0
   212
		err = aStmt.Prepare(aDb, KSqlString2);
sl@0
   213
		if(err == KErrNone)
sl@0
   214
			{
sl@0
   215
			err = aStmt.Next();
sl@0
   216
			}
sl@0
   217
		}
sl@0
   218
	User::LeaveIfError(err);
sl@0
   219
	}
sl@0
   220
sl@0
   221
//"RSqlStatement::Prepare()" OOM test (16-bit INSERT SQL statement with parameters)
sl@0
   222
void PrepareInsertPrmStmt16L(RSqlDatabase& aDb, RSqlStatement& aStmt)
sl@0
   223
	{
sl@0
   224
	_LIT(KSqlString, "INSERT INTO BBB(fld1, fld2, fld3, fld4) VALUES(:Prm0, :Prm1, :Prm2, :Prm3);");
sl@0
   225
	TInt err = aStmt.Prepare(aDb, KSqlString);
sl@0
   226
	User::LeaveIfError(err);
sl@0
   227
	}
sl@0
   228
sl@0
   229
/**
sl@0
   230
@SYMTestCaseID			SYSLIB-SQL-CT-1617
sl@0
   231
@SYMTestCaseDesc		RSqlStatement::Prepare() OOM test
sl@0
   232
						Precondition: the database exists, opened, some record(s) inserted.
sl@0
   233
						The test calls the given as an argument function while simulating OOM failures
sl@0
   234
						and checks that there are no memory and resource leaks.
sl@0
   235
@SYMTestPriority		High
sl@0
   236
@SYMTestActions			RSqlStatement::Prepare() OOM test
sl@0
   237
@SYMTestExpectedResults Test must not fail
sl@0
   238
@SYMREQ					REQ5792
sl@0
   239
                        REQ5793
sl@0
   240
*/
sl@0
   241
void DoStmtPrepareOomTestL(TStmtFuncPtrL aStmtFuncPtrL, const TDesC& aDbFileName, TDbType aDbType, TInt aExpectedError = KErrNone)
sl@0
   242
	{
sl@0
   243
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1617 RSqlStatement::Prepare() - OOM test"));
sl@0
   244
	RSqlSecurityPolicy securityPolicy;
sl@0
   245
	CreateTestSecurityPolicy(securityPolicy);
sl@0
   246
	for(TInt i=0;i<(TInt)(sizeof(TheOomTestType)/sizeof(TheOomTestType[0]));++i)
sl@0
   247
		{
sl@0
   248
		RSqlDatabase::Delete(aDbFileName);
sl@0
   249
		RSqlDatabase db;
sl@0
   250
		TInt err = aDbType == ESecureDb ? db.Create(aDbFileName, securityPolicy) : db.Create(aDbFileName);
sl@0
   251
		TEST2(err, KErrNone);
sl@0
   252
		err = db.Exec(KSqlDbString);
sl@0
   253
		TEST(err >= 0);
sl@0
   254
		//The next operation is executed to force the SQL server side session to make one memory allocation
sl@0
   255
		//for the statement handle in its RDbObjContainer contrainer data member. Otherwise the OOM test will fail,
sl@0
   256
		//because the server side session will do one additional allocation, which stays alive untill the
sl@0
   257
		//session gets closed.
sl@0
   258
		RSqlStatement dummyStmt;
sl@0
   259
		err = dummyStmt.Prepare(db, _L("SELECT * FROM BBB"));
sl@0
   260
		TEST2(err, KErrNone);
sl@0
   261
		dummyStmt.Close();
sl@0
   262
sl@0
   263
		err = KErrNoMemory;
sl@0
   264
		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
sl@0
   265
		TInt allocationNo = 0;
sl@0
   266
		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
sl@0
   267
		while(allocationNo < KMaxAllocation)
sl@0
   268
			{
sl@0
   269
			MarkHandles();
sl@0
   270
			MarkAllocatedCells();
sl@0
   271
sl@0
   272
			__UHEAP_MARK;
sl@0
   273
sl@0
   274
			SetHeapFailure(TheOomTestType[i], ++allocationNo);
sl@0
   275
sl@0
   276
	    	RSqlStatement stmt;
sl@0
   277
			TRAP(err, (*aStmtFuncPtrL)(db, stmt));
sl@0
   278
			stmt.Close();
sl@0
   279
			if(err != KErrNoMemory)
sl@0
   280
				{
sl@0
   281
				TEST2(err, aExpectedError);
sl@0
   282
				}
sl@0
   283
			else
sl@0
   284
				{
sl@0
   285
				failingAllocationNo = allocationNo;	
sl@0
   286
				}
sl@0
   287
sl@0
   288
			ResetHeapFailure(TheOomTestType[i]);
sl@0
   289
sl@0
   290
			__UHEAP_MARKEND;
sl@0
   291
sl@0
   292
			CheckAllocatedCells();
sl@0
   293
			CheckHandles();
sl@0
   294
			}
sl@0
   295
sl@0
   296
		db.Close();
sl@0
   297
		TEST2(err, aExpectedError);
sl@0
   298
		PrintEndOfOomTest(TheOomTestType[i], failingAllocationNo);
sl@0
   299
		}
sl@0
   300
	//Delete the database file
sl@0
   301
	RSqlDatabase::Delete(aDbFileName);
sl@0
   302
	securityPolicy.Close();
sl@0
   303
	}
sl@0
   304
sl@0
   305
//"RSqlStatement::Reset()" OOM test
sl@0
   306
void ResetStmtL(RSqlStatement& aStmt)
sl@0
   307
	{
sl@0
   308
	TInt err = aStmt.Next();
sl@0
   309
	if(err == KErrNone)
sl@0
   310
		{
sl@0
   311
		err = aStmt.Reset();
sl@0
   312
		}
sl@0
   313
	User::LeaveIfError(err);
sl@0
   314
	}
sl@0
   315
sl@0
   316
//"RSqlStatement::Exec()" OOM test
sl@0
   317
void ExecStmtL(RSqlStatement& aStmt)
sl@0
   318
	{
sl@0
   319
	TInt err = aStmt.Exec();
sl@0
   320
	User::LeaveIfError(err);
sl@0
   321
	}
sl@0
   322
sl@0
   323
//"RSqlStatement::Next()" OOM test
sl@0
   324
void NextStmtL(RSqlStatement& aStmt)
sl@0
   325
	{
sl@0
   326
	TInt err = aStmt.Next();
sl@0
   327
	if(err == KErrNone)
sl@0
   328
		{
sl@0
   329
		err = aStmt.Next();
sl@0
   330
		}
sl@0
   331
	User::LeaveIfError(err);
sl@0
   332
	}
sl@0
   333
sl@0
   334
//"RSqlStatement::ParameterIndex()" OOM test
sl@0
   335
void StmtParameterIndexL(RSqlStatement& aStmt)
sl@0
   336
	{
sl@0
   337
	TInt err = aStmt.ParameterIndex(_L(":Prm2"));
sl@0
   338
	if(err == 1) //":Prm2" index is 1
sl@0
   339
		{
sl@0
   340
		err = KErrNone;
sl@0
   341
		}
sl@0
   342
	User::LeaveIfError(err);
sl@0
   343
	}
sl@0
   344
sl@0
   345
//"RSqlStatement::ParameterName()" OOM test
sl@0
   346
void StmtParameterNameL(RSqlStatement& aStmt)
sl@0
   347
	{
sl@0
   348
	// _LIT(KExcpected, ":Prm2");
sl@0
   349
	TPtrC paramName;
sl@0
   350
	TInt err = aStmt.ParameterName(1, paramName);
sl@0
   351
	User::LeaveIfError(err);
sl@0
   352
	}
sl@0
   353
sl@0
   354
//"RSqlStatement::ParamName()" OOM test
sl@0
   355
void StmtParamNameL(RSqlStatement& aStmt)
sl@0
   356
	{
sl@0
   357
	TPtrC paramName;
sl@0
   358
	TInt err = aStmt.ParamName(1, paramName);
sl@0
   359
	User::LeaveIfError(err);
sl@0
   360
	}
sl@0
   361
sl@0
   362
//"RSqlStatement::ColumnIndex()" OOM test
sl@0
   363
void StmtColumnIndexL(RSqlStatement& aStmt)
sl@0
   364
	{
sl@0
   365
	TInt err = aStmt.ColumnIndex(_L("fLd3"));
sl@0
   366
	if(err == 2) //"fLd3" index is 2
sl@0
   367
		{
sl@0
   368
		err = KErrNone;
sl@0
   369
		}
sl@0
   370
	User::LeaveIfError(err);
sl@0
   371
	}
sl@0
   372
sl@0
   373
//"RSqlStatement::ColumnName()" OOM test
sl@0
   374
void StmtColumnNameL(RSqlStatement& aStmt)
sl@0
   375
	{
sl@0
   376
	//_LIT(KExpected, "fLd3");
sl@0
   377
	TPtrC colName;
sl@0
   378
	TInt err = aStmt.ColumnName(2, colName);
sl@0
   379
	User::LeaveIfError(err);
sl@0
   380
	}
sl@0
   381
sl@0
   382
sl@0
   383
//"RSqlStatement::ColumnType()" OOM test
sl@0
   384
void StmtColumnTypeL(RSqlStatement& aStmt)
sl@0
   385
	{
sl@0
   386
	TSqlColumnType coltype = aStmt.ColumnType(2);
sl@0
   387
	TEST(coltype == ESqlReal);
sl@0
   388
	}
sl@0
   389
sl@0
   390
//"RSqlStatement::ColumnSize()" OOM test
sl@0
   391
void StmtColumnSizeL(RSqlStatement& aStmt)
sl@0
   392
	{
sl@0
   393
	TInt colsize = aStmt.ColumnSize(2);
sl@0
   394
	TEST(colsize == sizeof(TReal));
sl@0
   395
	}
sl@0
   396
sl@0
   397
//"RSqlStatement::BindNull()" OOM test
sl@0
   398
void StmtBindNullL(RSqlStatement& aStmt)
sl@0
   399
	{
sl@0
   400
	TInt err = aStmt.BindNull(1);
sl@0
   401
	//The bindings will be transferred on the server side right before Next() or Exec() call
sl@0
   402
	if(err == KErrNone)
sl@0
   403
		{
sl@0
   404
		err = aStmt.Exec();
sl@0
   405
		}
sl@0
   406
	User::LeaveIfError(err);
sl@0
   407
	}
sl@0
   408
sl@0
   409
//"RSqlStatement::BindInt()" OOM test
sl@0
   410
void StmtBindIntL(RSqlStatement& aStmt)
sl@0
   411
	{
sl@0
   412
	TInt val = 184;
sl@0
   413
	TInt err = aStmt.BindInt(0, val);
sl@0
   414
	//The bindings will be transferred on the server side right before Next() or Exec() call
sl@0
   415
	if(err == KErrNone)
sl@0
   416
		{
sl@0
   417
		err = aStmt.Exec();
sl@0
   418
		}
sl@0
   419
	User::LeaveIfError(err);
sl@0
   420
	}
sl@0
   421
sl@0
   422
//"RSqlStatement::BindInt64()" OOM test
sl@0
   423
void StmtBindInt64L(RSqlStatement& aStmt)
sl@0
   424
	{
sl@0
   425
	TInt64 val = MAKE_TINT64(0x00FF00FF, 0x12345678);
sl@0
   426
	TInt err = aStmt.BindInt64(1, val);
sl@0
   427
	//The bindings will be transferred on the server side right before Next() or Exec() call
sl@0
   428
	if(err == KErrNone)
sl@0
   429
		{
sl@0
   430
		err = aStmt.Exec();
sl@0
   431
		}
sl@0
   432
	User::LeaveIfError(err);
sl@0
   433
	}
sl@0
   434
sl@0
   435
//"RSqlStatement::BindReal()" OOM test
sl@0
   436
void StmtBindRealL(RSqlStatement& aStmt)
sl@0
   437
	{
sl@0
   438
	TReal val = 25.2423;
sl@0
   439
	TInt err = aStmt.BindReal(2, val);
sl@0
   440
	//The bindings will be transferred on the server side right before Next() or Exec() call
sl@0
   441
	if(err == KErrNone)
sl@0
   442
		{
sl@0
   443
		err = aStmt.Exec();
sl@0
   444
		}
sl@0
   445
	User::LeaveIfError(err);
sl@0
   446
	}
sl@0
   447
sl@0
   448
//"RSqlStatement::BindText()" OOM test
sl@0
   449
void StmtBindTextL(RSqlStatement& aStmt)
sl@0
   450
	{
sl@0
   451
	for(TInt i=0;i<KLongParameterSize;++i)
sl@0
   452
		{
sl@0
   453
		TheTextColumnData[i] = (TUint16)i;
sl@0
   454
		}
sl@0
   455
	const TPtrC val(TheTextColumnData, KLongParameterSize);
sl@0
   456
	TInt err = aStmt.BindText(3, val);
sl@0
   457
	//The bindings will be transferred on the server side right before a Next() or Exec() call
sl@0
   458
	if(err == KErrNone)
sl@0
   459
		{
sl@0
   460
		err = aStmt.Exec();
sl@0
   461
		}
sl@0
   462
	User::LeaveIfError(err);
sl@0
   463
	}
sl@0
   464
sl@0
   465
//"RSqlStatement::BindBinary()" OOM test
sl@0
   466
void StmtBindBinaryL(RSqlStatement& aStmt)
sl@0
   467
	{
sl@0
   468
	for(TInt i=0;i<KLongParameterSize;++i)
sl@0
   469
		{
sl@0
   470
		TheBinaryColumnData[i] = (TUint8)i;
sl@0
   471
		}
sl@0
   472
	const TPtrC8 val(TheBinaryColumnData, KLongParameterSize);
sl@0
   473
	TInt err = aStmt.BindBinary(3, val);
sl@0
   474
	//The bindings will be transferred on the server side right before a Next() or Exec() call
sl@0
   475
	if(err == KErrNone)
sl@0
   476
		{
sl@0
   477
		err = aStmt.Exec();
sl@0
   478
		}
sl@0
   479
	User::LeaveIfError(err);
sl@0
   480
	}
sl@0
   481
sl@0
   482
//"RSqlStatement::BindZeroBlob()" OOM test
sl@0
   483
void StmtBindZeroBlobL(RSqlStatement& aStmt)
sl@0
   484
	{
sl@0
   485
	TInt err = aStmt.BindZeroBlob(3, KLongParameterSize);
sl@0
   486
	//The bindings will be transferred on the server side right before a Next() or Exec() call
sl@0
   487
	if(err == KErrNone)
sl@0
   488
		{
sl@0
   489
		err = aStmt.Exec();
sl@0
   490
		}
sl@0
   491
	User::LeaveIfError(err);
sl@0
   492
	}
sl@0
   493
sl@0
   494
//"RSqlStatement::IsNull()" OOM test
sl@0
   495
void StmtIsNullColumnL(RSqlStatement& aStmt)
sl@0
   496
	{
sl@0
   497
	TBool rc = aStmt.IsNull(0);
sl@0
   498
	TEST(!rc);
sl@0
   499
	}
sl@0
   500
sl@0
   501
//"RSqlStatement::ColumnInt()" OOM test
sl@0
   502
void StmtColumnIntL(RSqlStatement& aStmt)
sl@0
   503
	{
sl@0
   504
	TInt val = aStmt.ColumnInt(0);
sl@0
   505
	TEST(val == 10);
sl@0
   506
	}
sl@0
   507
sl@0
   508
//"RSqlStatement::ColumnInt64()" OOM test
sl@0
   509
void StmtColumnInt64L(RSqlStatement& aStmt)
sl@0
   510
	{
sl@0
   511
	TInt64 val = aStmt.ColumnInt64(1);
sl@0
   512
	TEST(val == 100);
sl@0
   513
	}
sl@0
   514
sl@0
   515
//"RSqlStatement::ColumnReal()" OOM test
sl@0
   516
void StmtColumnRealL(RSqlStatement& aStmt)
sl@0
   517
	{
sl@0
   518
	TReal val = aStmt.ColumnReal(2);
sl@0
   519
	TEST(Abs(val - 100.001) < 0.000001);
sl@0
   520
	}
sl@0
   521
sl@0
   522
//"RSqlStatement::ColumnTextL()" OOM test
sl@0
   523
void StmtColumnText1L(RSqlStatement& aStmt)
sl@0
   524
	{
sl@0
   525
	TPtrC val = aStmt.ColumnTextL(3);
sl@0
   526
	TEST(val.Length() == KLongColumnSize);
sl@0
   527
	for(TInt i=0;i<KLongColumnSize;++i)
sl@0
   528
		{
sl@0
   529
		TEST(val[i] == (TUint16)i);
sl@0
   530
		}
sl@0
   531
	}
sl@0
   532
sl@0
   533
//"RSqlStatement::ColumnText()" OOM test
sl@0
   534
void StmtColumnText2L(RSqlStatement& aStmt)
sl@0
   535
	{
sl@0
   536
	TPtrC val;
sl@0
   537
	TInt err = aStmt.ColumnText(3, val);
sl@0
   538
	User::LeaveIfError(err);
sl@0
   539
	TEST(val.Length() == KLongColumnSize);
sl@0
   540
	for(TInt i=0;i<KLongColumnSize;++i)
sl@0
   541
		{
sl@0
   542
		TEST(val[i] == (TUint16)i);
sl@0
   543
		}
sl@0
   544
	}
sl@0
   545
sl@0
   546
//"RSqlStatement::ColumnText()" OOM test
sl@0
   547
void StmtColumnText3L(RSqlStatement& aStmt)
sl@0
   548
	{
sl@0
   549
	TPtr val(TheTextColumnData, KLongColumnSize);
sl@0
   550
	TInt err = aStmt.ColumnText(3, val);
sl@0
   551
	User::LeaveIfError(err);
sl@0
   552
	TEST(val.Length() == KLongColumnSize);
sl@0
   553
	for(TInt i=0;i<KLongColumnSize;++i)
sl@0
   554
		{
sl@0
   555
		TEST(val[i] == (TUint16)i);
sl@0
   556
		}
sl@0
   557
	}
sl@0
   558
sl@0
   559
//"RSqlStatement::ColumnBinaryL()" OOM test
sl@0
   560
void StmtColumnBinary1L(RSqlStatement& aStmt)
sl@0
   561
	{
sl@0
   562
	TPtrC8 val = aStmt.ColumnBinaryL(4);
sl@0
   563
	TEST(val.Length() == KLongColumnSize * sizeof(TUint16));
sl@0
   564
	for(TInt i=0,j=0;i<KLongColumnSize;++i,j+=2)
sl@0
   565
		{
sl@0
   566
		TUint8 valLow = val[j];
sl@0
   567
		TUint8 valHigh = val[j + 1];
sl@0
   568
		TEST(valLow == (TUint8)(i & 0xFF));
sl@0
   569
		TEST(valHigh == (TUint8)(((TUint)i >> 8) & 0xFF));
sl@0
   570
		}
sl@0
   571
	}
sl@0
   572
sl@0
   573
//"RSqlStatement::ColumnBinary()" OOM test
sl@0
   574
void StmtColumnBinary2L(RSqlStatement& aStmt)
sl@0
   575
	{
sl@0
   576
	TPtrC8 val;
sl@0
   577
	TInt err = aStmt.ColumnBinary(4, val);
sl@0
   578
	User::LeaveIfError(err);
sl@0
   579
	TEST(val.Length() == KLongColumnSize * sizeof(TUint16));
sl@0
   580
	for(TInt i=0,j=0;i<KLongColumnSize;++i,j+=2)
sl@0
   581
		{
sl@0
   582
		TUint8 valLow = val[j];
sl@0
   583
		TUint8 valHigh = val[j + 1];
sl@0
   584
		TEST(valLow == (TUint8)(i & 0xFF));
sl@0
   585
		TEST(valHigh == (TUint8)(((TUint)i >> 8) & 0xFF));
sl@0
   586
		}
sl@0
   587
	}
sl@0
   588
sl@0
   589
//"RSqlStatement::ColumnBinary()" OOM test
sl@0
   590
void StmtColumnBinary3L(RSqlStatement& aStmt)
sl@0
   591
	{
sl@0
   592
	TPtr8 val(TheBinaryColumnData, KLongColumnSize * sizeof(TUint16));
sl@0
   593
	TInt err = aStmt.ColumnBinary(4, val);
sl@0
   594
	User::LeaveIfError(err);
sl@0
   595
	TEST(val.Length() == KLongColumnSize * sizeof(TUint16));
sl@0
   596
	for(TInt i=0,j=0;i<KLongColumnSize;++i,j+=2)
sl@0
   597
		{
sl@0
   598
		TUint8 valLow = val[j];
sl@0
   599
		TUint8 valHigh = val[j + 1];
sl@0
   600
		TEST(valLow == (TUint8)(i & 0xFF));
sl@0
   601
		TEST(valHigh == (TUint8)(((TUint)i >> 8) & 0xFF));
sl@0
   602
		}
sl@0
   603
	}
sl@0
   604
sl@0
   605
//"RSqlStatement::ColumnCount()" OOM test
sl@0
   606
void StmtColumnCount(RSqlStatement& aStmt)
sl@0
   607
	{
sl@0
   608
	TInt cnt = aStmt.ColumnCount();
sl@0
   609
	TEST2(cnt, 5);
sl@0
   610
	}
sl@0
   611
sl@0
   612
//"RSqlStatement::DeclaredColumnType()" OOM test
sl@0
   613
void StmtDeclaredColumnTypeL(RSqlStatement& aStmt)
sl@0
   614
	{
sl@0
   615
	TInt cnt = aStmt.ColumnCount();
sl@0
   616
	TEST2(cnt, 5);
sl@0
   617
	const TSqlColumnType KColTypes[] = {ESqlInt, ESqlInt, ESqlReal, ESqlText, ESqlBinary};
sl@0
   618
	for(TInt i=0;i<cnt;++i)
sl@0
   619
		{
sl@0
   620
		TSqlColumnType colType;
sl@0
   621
		TInt err = aStmt.DeclaredColumnType(i, colType);
sl@0
   622
		User::LeaveIfError(err);
sl@0
   623
		TEST2(colType, KColTypes[i]);
sl@0
   624
		}
sl@0
   625
	}
sl@0
   626
sl@0
   627
//"RSqlColumnReadStream::ColumnBinary()" OOM test
sl@0
   628
void StmtColumnBinaryStreamL(RSqlStatement& aStmt)
sl@0
   629
	{
sl@0
   630
	RSqlColumnReadStream strm;
sl@0
   631
	CleanupClosePushL(strm);
sl@0
   632
	TInt err = strm.ColumnBinary(aStmt, 4);
sl@0
   633
	User::LeaveIfError(err);
sl@0
   634
	strm.ReadL(TheBinaryColumnData, KLongColumnSize * sizeof(TUint16));
sl@0
   635
	CleanupStack::PopAndDestroy(&strm);
sl@0
   636
	for(TInt i=0,j=0;i<KLongColumnSize;++i,j+=2)
sl@0
   637
		{
sl@0
   638
		TUint8 valLow = TheBinaryColumnData[j];
sl@0
   639
		TUint8 valHigh = TheBinaryColumnData[j + 1];
sl@0
   640
		TEST(valLow == (TUint8)(i & 0xFF));
sl@0
   641
		TEST(valHigh == (TUint8)(((TUint)i >> 8) & 0xFF));
sl@0
   642
		}
sl@0
   643
	}
sl@0
   644
sl@0
   645
//"RSqlColumnReadStream::ColumnText()" OOM test
sl@0
   646
void StmtColumnTextStreamL(RSqlStatement& aStmt)
sl@0
   647
	{
sl@0
   648
	RSqlColumnReadStream strm;
sl@0
   649
	CleanupClosePushL(strm);
sl@0
   650
	TInt err = strm.ColumnText(aStmt, 3);
sl@0
   651
	User::LeaveIfError(err);
sl@0
   652
	strm.ReadL(TheTextColumnData, KLongColumnSize);
sl@0
   653
	CleanupStack::PopAndDestroy(&strm);
sl@0
   654
	for(TInt i=0;i<KLongColumnSize;++i)
sl@0
   655
		{
sl@0
   656
		TEST(TheTextColumnData[i] == (TUint16)i);
sl@0
   657
		}
sl@0
   658
	}
sl@0
   659
sl@0
   660
//"RSqlParamWriteStream::BindBinary()" OOM test
sl@0
   661
void StmtParamBinaryStreamL(RSqlStatement& aStmt)
sl@0
   662
	{
sl@0
   663
	for(TInt i=0;i<KLongParameterSize;++i)
sl@0
   664
		{
sl@0
   665
		TheTextColumnData[i] = (TUint16)i;
sl@0
   666
		}
sl@0
   667
sl@0
   668
	RSqlParamWriteStream strm;
sl@0
   669
	CleanupClosePushL(strm);
sl@0
   670
	TInt err = strm.BindBinary(aStmt, 3);
sl@0
   671
	User::LeaveIfError(err);
sl@0
   672
	strm.WriteL((TUint8*)TheTextColumnData, KLongColumnSize * sizeof(TUint16));
sl@0
   673
	CleanupStack::PopAndDestroy(&strm);
sl@0
   674
	}
sl@0
   675
sl@0
   676
//"RSqlParamWriteStream::BindText()" OOM test
sl@0
   677
void StmtParamTextStreamL(RSqlStatement& aStmt)
sl@0
   678
	{
sl@0
   679
	for(TInt i=0;i<KLongParameterSize;++i)
sl@0
   680
		{
sl@0
   681
		TheTextColumnData[i] = (TUint16)i;
sl@0
   682
		}
sl@0
   683
sl@0
   684
	RSqlParamWriteStream strm;
sl@0
   685
	CleanupClosePushL(strm);
sl@0
   686
	TInt err = strm.BindText(aStmt, 3);
sl@0
   687
	User::LeaveIfError(err);
sl@0
   688
	strm.WriteL(TheTextColumnData, KLongColumnSize);
sl@0
   689
	CleanupStack::PopAndDestroy(&strm);
sl@0
   690
	}
sl@0
   691
sl@0
   692
/**
sl@0
   693
@SYMTestCaseID			SYSLIB-SQL-CT-1618
sl@0
   694
@SYMTestCaseDesc		RSqlStatement methods OOM tests
sl@0
   695
						Precondition: the database exists, opened, some record(s) inserted.
sl@0
   696
						The test calls the given as an argument function while simulating OOM failures
sl@0
   697
						and checks that there are no memory and resource leaks.
sl@0
   698
@SYMTestPriority		High
sl@0
   699
@SYMTestActions			RSqlStatement methods OOM tests
sl@0
   700
@SYMTestExpectedResults Test must not fail
sl@0
   701
@SYMREQ					REQ5792
sl@0
   702
                        REQ5793
sl@0
   703
*/
sl@0
   704
void DoStmtOomTestL(TStmtFuncPtrL aStmtPrepareFuncPtrL, TStmtFuncPtr2L aStmtTestFuncPtrL, const TDesC& aDbFileName, TDbType aDbType)
sl@0
   705
	{
sl@0
   706
	//This is not really an OOM test, because:
sl@0
   707
	//(A) The test forces the server to simulate heap failure on determied allocation step
sl@0
   708
	//(B) SQL server counts only the number of active statement and stream objects, the allocated memory cells
sl@0
   709
	//    are not counted.
sl@0
   710
	//    The reason that the allocated memory cells are not counted and in case of OOM failure - checked is
sl@0
   711
	//    because the SQL server may make some per-connection persistent memory allocations (cache pages, etc.)
sl@0
   712
	//    which will not be deallocated when the statement object is closed.
sl@0
   713
sl@0
   714
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1618 RSqlStatement - OOM test"));
sl@0
   715
	RSqlSecurityPolicy securityPolicy;
sl@0
   716
	CreateTestSecurityPolicy(securityPolicy);
sl@0
   717
	for(TInt i=0;i<(TInt)(sizeof(TheOomTestType)/sizeof(TheOomTestType[0]));++i)
sl@0
   718
		{
sl@0
   719
		RSqlDatabase::Delete(aDbFileName);
sl@0
   720
		RSqlDatabase db;
sl@0
   721
		TInt err = aDbType == ESecureDb ? db.Create(aDbFileName, securityPolicy) : db.Create(aDbFileName);
sl@0
   722
		TEST2(err, KErrNone);
sl@0
   723
		err = db.Exec(KSqlDbString);
sl@0
   724
		TEST(err >= 0);
sl@0
   725
		err = db.Exec(KSqlDbString2);
sl@0
   726
		TEST(err >= 0);
sl@0
   727
sl@0
   728
		err = KErrNoMemory;
sl@0
   729
		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
sl@0
   730
		TInt allocationNo = 0;
sl@0
   731
		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
sl@0
   732
		while(allocationNo < KMaxAllocation)
sl@0
   733
			{
sl@0
   734
			MarkHandles();
sl@0
   735
			MarkAllocatedCells();
sl@0
   736
sl@0
   737
			__UHEAP_MARK;
sl@0
   738
sl@0
   739
	    	RSqlStatement stmt;
sl@0
   740
			TRAP(err, (*aStmtPrepareFuncPtrL)(db, stmt));
sl@0
   741
			TEST2(err, KErrNone);
sl@0
   742
sl@0
   743
			SetHeapFailure(TheOomTestType[i], ++allocationNo);
sl@0
   744
sl@0
   745
			TRAP(err, (*aStmtTestFuncPtrL)(stmt));
sl@0
   746
sl@0
   747
			//ResetHeapFailure() has to be called before stmt.Close() because,
sl@0
   748
			//otherwise it will panic the server (the server resource count, marked by
sl@0
   749
			//SetHeapFailure() call, is 1 (there is one prepared statement))
sl@0
   750
			ResetHeapFailure(TheOomTestType[i]);
sl@0
   751
sl@0
   752
			stmt.Close();
sl@0
   753
sl@0
   754
			if(err != KErrNoMemory)
sl@0
   755
				{
sl@0
   756
				TEST2(err, KErrNone);
sl@0
   757
				}
sl@0
   758
			else
sl@0
   759
				{
sl@0
   760
				failingAllocationNo = allocationNo;	
sl@0
   761
				}
sl@0
   762
sl@0
   763
			__UHEAP_MARKEND;
sl@0
   764
sl@0
   765
			CheckAllocatedCells();
sl@0
   766
			CheckHandles();
sl@0
   767
			}
sl@0
   768
sl@0
   769
		db.Close();
sl@0
   770
		TEST2(err, KErrNone);
sl@0
   771
		PrintEndOfOomTest(TheOomTestType[i], failingAllocationNo);
sl@0
   772
		}
sl@0
   773
	//Delete the database file
sl@0
   774
	RSqlDatabase::Delete(aDbFileName);
sl@0
   775
	securityPolicy.Close();
sl@0
   776
	}
sl@0
   777
sl@0
   778
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   779
//////////////////               RSqlBlobReadStream, RSqlBlobWriteStream - OOM tests          /////////////////////
sl@0
   780
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   781
sl@0
   782
//RSqlBlobReadStream, RSqlBlobWriteStream - OOM test preparation.
sl@0
   783
void ExecInsertBlobL(RSqlDatabase& aDb)
sl@0
   784
	{
sl@0
   785
	_LIT8(KSqlString1, "CREATE TABLE BBB(Fld1 INTEGER, Fld2 BIGINT, Fld3 DOUBLE, Fld4 TEXT, Fld5 LONGBLOB)");
sl@0
   786
	TInt err = aDb.Exec(KSqlString1);
sl@0
   787
	User::LeaveIfError(err);
sl@0
   788
	_LIT8(KSqlString2, "INSERT INTO BBB(fld1, fld2, fld3, fld4, fld5) VALUES(10, 100, 100.001, 'AAA', x'");
sl@0
   789
	TheSqlBuf.Copy(KSqlString2);
sl@0
   790
	for(TInt i=0;i<KBlobStrLen;++i)	
sl@0
   791
		{
sl@0
   792
		TheSqlBuf.Append(_L8("A5"));
sl@0
   793
		}
sl@0
   794
	TheSqlBuf.Append(_L8("')"));
sl@0
   795
	err = aDb.Exec(TheSqlBuf);
sl@0
   796
	User::LeaveIfError(err);
sl@0
   797
	}
sl@0
   798
sl@0
   799
//"RSqlBlobReadStream::OpenL()/RSqlBlobReadStream::ReadL()" OOM test
sl@0
   800
void BlobReadStreamOpenL(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   801
	{
sl@0
   802
	RSqlBlobReadStream strm;
sl@0
   803
	CleanupClosePushL(strm);
sl@0
   804
	if(aAttachDbName.Length() > 0)
sl@0
   805
		{
sl@0
   806
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1, aAttachDbName);
sl@0
   807
		}
sl@0
   808
	else
sl@0
   809
		{
sl@0
   810
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1);
sl@0
   811
		}
sl@0
   812
	const TInt KReadOpCnt = 8;
sl@0
   813
	for(TInt j=0;j<KReadOpCnt;++j)
sl@0
   814
		{
sl@0
   815
		strm.ReadL(TheSqlBuf, KBlobLen / KReadOpCnt);
sl@0
   816
		TEST2(TheSqlBuf.Length(), (KBlobLen / KReadOpCnt));
sl@0
   817
		for(TInt i=0;i<(KBlobLen / KReadOpCnt);++i)
sl@0
   818
			{
sl@0
   819
			TUint8 val = TheSqlBuf[i];
sl@0
   820
			TEST2(val, 0xA5);
sl@0
   821
			}
sl@0
   822
		}
sl@0
   823
	CleanupStack::PopAndDestroy(&strm);
sl@0
   824
	}
sl@0
   825
sl@0
   826
//"RSqlBlobReadStream::OpenL()/RSqlBlobReadStream::SizeL()" OOM test
sl@0
   827
void BlobReadStreamSizeL(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   828
	{
sl@0
   829
	RSqlBlobReadStream strm;
sl@0
   830
	CleanupClosePushL(strm);
sl@0
   831
	if(aAttachDbName.Length() > 0)
sl@0
   832
		{
sl@0
   833
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1, aAttachDbName);
sl@0
   834
		}
sl@0
   835
	else
sl@0
   836
		{
sl@0
   837
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1);
sl@0
   838
		}
sl@0
   839
	TInt size = strm.SizeL();	
sl@0
   840
	TEST2(size, KBlobLen);
sl@0
   841
	CleanupStack::PopAndDestroy(&strm);
sl@0
   842
	}
sl@0
   843
sl@0
   844
//"RSqlBlobWriteStream::OpenL()/RSqlBlobWriteStream::WriteL()" OOM test
sl@0
   845
void BlobWriteStreamOpenL(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   846
	{
sl@0
   847
	RSqlBlobWriteStream strm;
sl@0
   848
	CleanupClosePushL(strm);
sl@0
   849
	if(aAttachDbName.Length() > 0)
sl@0
   850
		{
sl@0
   851
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1, aAttachDbName);
sl@0
   852
		}
sl@0
   853
	else
sl@0
   854
		{
sl@0
   855
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1);
sl@0
   856
		}
sl@0
   857
	const TInt KWriteOpCnt = 8;
sl@0
   858
	TheSqlBuf.SetLength(KBlobLen / KWriteOpCnt);
sl@0
   859
	TheSqlBuf.Fill(TChar('Z'));
sl@0
   860
	for(TInt j=0;j<KWriteOpCnt;++j)
sl@0
   861
		{
sl@0
   862
		strm.WriteL(TheSqlBuf, KBlobLen / KWriteOpCnt);
sl@0
   863
		}
sl@0
   864
	strm.CommitL();		
sl@0
   865
	CleanupStack::PopAndDestroy(&strm);
sl@0
   866
	}
sl@0
   867
sl@0
   868
//"RSqlBlobWriteStream::OpenL()/RSqlBlobWriteStream::SizeL()" OOM test
sl@0
   869
void BlobWriteStreamSizeL(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   870
	{
sl@0
   871
	RSqlBlobWriteStream strm;
sl@0
   872
	CleanupClosePushL(strm);
sl@0
   873
	if(aAttachDbName.Length() > 0)
sl@0
   874
		{
sl@0
   875
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1, aAttachDbName);
sl@0
   876
		}
sl@0
   877
	else
sl@0
   878
		{
sl@0
   879
		strm.OpenL(aDb, _L("BBB"), _L("fld5"), 1);
sl@0
   880
		}
sl@0
   881
	TInt size = strm.SizeL();	
sl@0
   882
	TEST2(size, KBlobLen);
sl@0
   883
	CleanupStack::PopAndDestroy(&strm);
sl@0
   884
	}
sl@0
   885
	
sl@0
   886
//"TSqlBlob::GetLC()" OOM test
sl@0
   887
void BlobWholeGet1L(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   888
	{
sl@0
   889
	HBufC8* buf = NULL;
sl@0
   890
	if(aAttachDbName.Length() > 0)
sl@0
   891
		{
sl@0
   892
		buf = TSqlBlob::GetLC(aDb, _L("BBB"), _L("fld5"), 1, aAttachDbName);
sl@0
   893
		}
sl@0
   894
	else
sl@0
   895
		{
sl@0
   896
		buf = TSqlBlob::GetLC(aDb, _L("BBB"), _L("fld5"), 1);
sl@0
   897
		}
sl@0
   898
	TEST(buf->Length() == KBlobStrLen);
sl@0
   899
	CleanupStack::PopAndDestroy(buf);
sl@0
   900
	}
sl@0
   901
	
sl@0
   902
//"TSqlBlob::Get()" OOM test
sl@0
   903
void BlobWholeGet2L(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   904
	{
sl@0
   905
	if(aAttachDbName.Length() > 0)
sl@0
   906
		{
sl@0
   907
		TSqlBlob::Get(aDb, _L("BBB"), _L("fld5"), TheSqlBuf2, 1, aAttachDbName);
sl@0
   908
		}
sl@0
   909
	else
sl@0
   910
		{
sl@0
   911
		TSqlBlob::Get(aDb, _L("BBB"), _L("fld5"), TheSqlBuf2, 1);
sl@0
   912
		}
sl@0
   913
	}
sl@0
   914
sl@0
   915
//"TSqlBlob::SetL()" OOM test
sl@0
   916
void BlobWholeSetL(RSqlDatabase& aDb, const TDesC& aAttachDbName)
sl@0
   917
	{
sl@0
   918
	if(aAttachDbName.Length() > 0)
sl@0
   919
		{
sl@0
   920
		TSqlBlob::SetL(aDb, _L("BBB"), _L("fld5"), TheSqlBuf, 1, aAttachDbName);
sl@0
   921
		}
sl@0
   922
	else
sl@0
   923
		{
sl@0
   924
		TSqlBlob::Get(aDb, _L("BBB"), _L("fld5"), TheSqlBuf, 1);
sl@0
   925
		}
sl@0
   926
	}
sl@0
   927
sl@0
   928
/**
sl@0
   929
@SYMTestCaseID			SYSLIB-SQL-UT-4091
sl@0
   930
@SYMTestCaseDesc		RSqlBlobReadStream, RSqlBlobWriteStream methods OOM tests
sl@0
   931
						Precondition: the database exists, opened, some record(s) inserted.
sl@0
   932
						The test calls the given as an argument function while simulating OOM failures
sl@0
   933
						and checks that there are no memory and resource leaks.
sl@0
   934
@SYMTestPriority		High
sl@0
   935
@SYMTestActions			RSqlBlobReadStream, RSqlBlobWriteStream methods OOM tests
sl@0
   936
@SYMTestExpectedResults Test must not fail
sl@0
   937
@SYMREQ					REQ5792
sl@0
   938
                        REQ10410
sl@0
   939
                        REQ10411
sl@0
   940
                        REQ10418
sl@0
   941
*/
sl@0
   942
void DoBlobOomTestL(TBlobPrepareFuncPtrL aBlobPrepareFuncPtrL, TBlobTestFuncPtrL aBlobTestFuncPtrL, 
sl@0
   943
					const TDesC& aDbFileName, TDbType aDbType, TBool aAttachDb = EFalse)
sl@0
   944
	{
sl@0
   945
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-4091 RSqlBlobReadStream, RSqlBlobWriteStream - OOM test"));
sl@0
   946
	RSqlSecurityPolicy securityPolicy;
sl@0
   947
	CreateTestSecurityPolicy(securityPolicy);
sl@0
   948
	for(TInt i=0;i<(TInt)(sizeof(TheOomTestType)/sizeof(TheOomTestType[0]));++i)
sl@0
   949
		{
sl@0
   950
		RSqlDatabase::Delete(aDbFileName);
sl@0
   951
		RSqlDatabase db;
sl@0
   952
		TInt err = aDbType == ESecureDb ? db.Create(aDbFileName, securityPolicy) : db.Create(aDbFileName);
sl@0
   953
		TEST2(err, KErrNone);
sl@0
   954
		TRAP(err, (*aBlobPrepareFuncPtrL)(db));
sl@0
   955
		TEST2(err, KErrNone);
sl@0
   956
		_LIT(KAttachDbName, "AttachDb");
sl@0
   957
		if(aAttachDb)
sl@0
   958
			{
sl@0
   959
			err = db.Attach(aDbFileName, KAttachDbName);
sl@0
   960
			TEST2(err, KErrNone);
sl@0
   961
			}
sl@0
   962
sl@0
   963
		err = KErrNoMemory;
sl@0
   964
		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KBlobOomTestAllocLimitServer : KBlobOomTestAllocLimitClient;
sl@0
   965
		TInt allocationNo = 0;
sl@0
   966
		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
sl@0
   967
		while(allocationNo < KMaxAllocation)
sl@0
   968
			{
sl@0
   969
			MarkHandles();
sl@0
   970
			MarkAllocatedCells();
sl@0
   971
sl@0
   972
			__UHEAP_MARK;
sl@0
   973
sl@0
   974
			SetHeapFailure(TheOomTestType[i], ++allocationNo);
sl@0
   975
			if(aAttachDb)
sl@0
   976
				{
sl@0
   977
				TRAP(err, (*aBlobTestFuncPtrL)(db, KAttachDbName));
sl@0
   978
				}
sl@0
   979
			else
sl@0
   980
				{
sl@0
   981
				TRAP(err, (*aBlobTestFuncPtrL)(db, KNullDesC));
sl@0
   982
				}
sl@0
   983
sl@0
   984
			ResetHeapFailure(TheOomTestType[i]);
sl@0
   985
sl@0
   986
			if(err != KErrNoMemory)
sl@0
   987
				{
sl@0
   988
				if(err != KErrNone)
sl@0
   989
					{
sl@0
   990
					TPtrC errmsg = db.LastErrorMessage();
sl@0
   991
					if(errmsg.Length() > 0)
sl@0
   992
						{
sl@0
   993
						TheTest.Printf(_L("\r\n@@@ error %d, error message: %S\r\n"), err, &errmsg);	
sl@0
   994
						}
sl@0
   995
					}
sl@0
   996
				TEST2(err, KErrNone);
sl@0
   997
				}
sl@0
   998
			else
sl@0
   999
				{
sl@0
  1000
				failingAllocationNo = allocationNo;
sl@0
  1001
				}				
sl@0
  1002
sl@0
  1003
			__UHEAP_MARKEND;
sl@0
  1004
sl@0
  1005
			CheckAllocatedCells();
sl@0
  1006
			CheckHandles();
sl@0
  1007
			}
sl@0
  1008
		TEST2(err, KErrNone);
sl@0
  1009
sl@0
  1010
		if(aAttachDb)
sl@0
  1011
			{
sl@0
  1012
			(void)db.Detach(KAttachDbName);
sl@0
  1013
			}
sl@0
  1014
sl@0
  1015
		db.Close();
sl@0
  1016
		err = RSqlDatabase::Delete(aDbFileName);
sl@0
  1017
		TEST2(err, KErrNone);
sl@0
  1018
		PrintEndOfOomTest(TheOomTestType[i], failingAllocationNo);
sl@0
  1019
		}
sl@0
  1020
	securityPolicy.Close();
sl@0
  1021
	}
sl@0
  1022
sl@0
  1023
void ScalarFullSelectInt_8L(RSqlDatabase& aDb)
sl@0
  1024
	{
sl@0
  1025
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1026
	TInt val = query.SelectIntL(_L8("SELECT F1 FROM A WHERE F3 < 0"));
sl@0
  1027
	TEST2(val, 2);
sl@0
  1028
	}
sl@0
  1029
sl@0
  1030
void ScalarFullSelectInt64_8L(RSqlDatabase& aDb)
sl@0
  1031
	{
sl@0
  1032
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1033
	TInt64 val = query.SelectInt64L(_L8("SELECT F2 FROM A WHERE F1 = 1"));
sl@0
  1034
	TEST2(val, 10000000000LL);
sl@0
  1035
	}
sl@0
  1036
sl@0
  1037
void ScalarFullSelectReal_8L(RSqlDatabase& aDb)
sl@0
  1038
	{
sl@0
  1039
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1040
	TReal val = query.SelectRealL(_L8("SELECT F3 FROM A WHERE F1 = 1"));
sl@0
  1041
	TEST(val > 2.0 && val < 3.0);
sl@0
  1042
	}
sl@0
  1043
sl@0
  1044
void ScalarFullSelectText_8L(RSqlDatabase& aDb)
sl@0
  1045
	{
sl@0
  1046
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1047
	TBuf<20> buf;
sl@0
  1048
	TInt err = query.SelectTextL(_L8("SELECT F4 FROM A WHERE F1 = 1"), buf);
sl@0
  1049
	TEST2(err, KErrNone);
sl@0
  1050
	_LIT(KText, "NAME1234567890");
sl@0
  1051
	TEST(buf == KText);
sl@0
  1052
	}
sl@0
  1053
sl@0
  1054
void ScalarFullSelectBinary_8L(RSqlDatabase& aDb)
sl@0
  1055
	{
sl@0
  1056
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1057
	TBuf8<20> buf;
sl@0
  1058
	TInt err = query.SelectBinaryL(_L8("SELECT F5 FROM A WHERE F1 = 1"), buf);
sl@0
  1059
	TEST2(err, KErrNone);
sl@0
  1060
	TEST(buf.Length() == 0);
sl@0
  1061
	}
sl@0
  1062
sl@0
  1063
void ScalarFullSelectInt_16L(RSqlDatabase& aDb)
sl@0
  1064
	{
sl@0
  1065
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1066
	TInt val = query.SelectIntL(_L16("SELECT F1 FROM A WHERE F3 < 0"));
sl@0
  1067
	TEST2(val, 2);
sl@0
  1068
	}
sl@0
  1069
sl@0
  1070
void ScalarFullSelectInt64_16L(RSqlDatabase& aDb)
sl@0
  1071
	{
sl@0
  1072
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1073
	TInt64 val = query.SelectInt64L(_L16("SELECT F2 FROM A WHERE F1 = 1"));
sl@0
  1074
	TEST2(val, 10000000000LL);
sl@0
  1075
	}
sl@0
  1076
sl@0
  1077
void ScalarFullSelectReal_16L(RSqlDatabase& aDb)
sl@0
  1078
	{
sl@0
  1079
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1080
	TReal val = query.SelectRealL(_L16("SELECT F3 FROM A WHERE F1 = 1"));
sl@0
  1081
	TEST(val > 2.0 && val < 3.0);
sl@0
  1082
	}
sl@0
  1083
sl@0
  1084
void ScalarFullSelectText_16L(RSqlDatabase& aDb)
sl@0
  1085
	{
sl@0
  1086
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1087
	TBuf<20> buf;
sl@0
  1088
	TInt err = query.SelectTextL(_L16("SELECT F4 FROM A WHERE F1 = 1"), buf);
sl@0
  1089
	TEST2(err, KErrNone);
sl@0
  1090
	_LIT(KText, "NAME1234567890");
sl@0
  1091
	TEST(buf == KText);
sl@0
  1092
	}
sl@0
  1093
sl@0
  1094
void ScalarFullSelectBinary_16L(RSqlDatabase& aDb)
sl@0
  1095
	{
sl@0
  1096
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1097
	TBuf8<20> buf;
sl@0
  1098
	TInt err = query.SelectBinaryL(_L16("SELECT F5 FROM A WHERE F1 = 1"), buf);
sl@0
  1099
	TEST2(err, KErrNone);
sl@0
  1100
	TEST(buf.Length() == 0);
sl@0
  1101
	}
sl@0
  1102
sl@0
  1103
void ScalarFullSelectText2_8L(RSqlDatabase& aDb)
sl@0
  1104
	{
sl@0
  1105
	TSqlScalarFullSelectQuery query(aDb);
sl@0
  1106
	HBufC* buf = HBufC::NewLC(8);
sl@0
  1107
	TPtr name = buf->Des();
sl@0
  1108
	TInt rc = query.SelectTextL(_L8("SELECT F4 FROM A WHERE F1 = 1"), name);
sl@0
  1109
	TEST(rc >= 0); //the function may return only non-negative values
sl@0
  1110
	if(rc > 0)
sl@0
  1111
		{
sl@0
  1112
		buf = buf->ReAllocL(rc);
sl@0
  1113
		CleanupStack::Pop();
sl@0
  1114
		CleanupStack::PushL(buf);
sl@0
  1115
		name.Set(buf->Des());
sl@0
  1116
		rc = query.SelectTextL(_L8("SELECT F4 FROM A WHERE F1 = 1"), name);
sl@0
  1117
		TEST(rc == 0);
sl@0
  1118
		_LIT(KText, "NAME1234567890");
sl@0
  1119
		TEST(name == KText);
sl@0
  1120
		}
sl@0
  1121
	CleanupStack::PopAndDestroy(buf);
sl@0
  1122
	}
sl@0
  1123
sl@0
  1124
/**
sl@0
  1125
@SYMTestCaseID			SYSLIB-SQL-CT-1811
sl@0
  1126
@SYMTestCaseDesc		TSqlScalarFullSelectQuery functions OOM test
sl@0
  1127
						Precondition: the database exists.
sl@0
  1128
						The test simulates OOM failures while calling TSqlScalarFullSelectQuery functions
sl@0
  1129
						and checks that there are no memory and resource leaks.
sl@0
  1130
@SYMTestPriority		High
sl@0
  1131
@SYMTestActions			TSqlScalarFullSelectQuery methods OOM tests
sl@0
  1132
@SYMTestExpectedResults Test must not fail
sl@0
  1133
@SYMREQ					REQ5792
sl@0
  1134
                        REQ5793
sl@0
  1135
*/
sl@0
  1136
void DoFullSelectOomTest(TScalarFullSelectFuncPtrL aTestFunctionPtrL)
sl@0
  1137
	{
sl@0
  1138
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1811 TSqlScalarFullSelectQuery - OOM test"));
sl@0
  1139
	//Create test database
sl@0
  1140
	RSqlDatabase db;
sl@0
  1141
	TInt err = db.Create(KTestDb);
sl@0
  1142
	TEST2(err, KErrNone);
sl@0
  1143
	err = db.Exec(_L("CREATE TABLE A(F1 INTEGER, F2 INTEGER, F3 FLOAT, F4 TEXT, F5 BLOB)"));
sl@0
  1144
	TEST(err >= 0);
sl@0
  1145
	err = db.Exec(_L("INSERT INTO A(F1, F2, F3, F4, F5) VALUES(1, 10000000000, 2.54, 'NAME1234567890', NULL)"));
sl@0
  1146
	TEST2(err, 1);
sl@0
  1147
	err = db.Exec(_L("INSERT INTO A(F1, F2, F3, F4) VALUES(2, 200, -1.11, 'ADDRESS')"));
sl@0
  1148
	TEST2(err, 1);
sl@0
  1149
	db.Close();
sl@0
  1150
	//OOM test loop
sl@0
  1151
	for(TInt i=0;i<(TInt)(sizeof(TheOomTestType)/sizeof(TheOomTestType[0]));++i)
sl@0
  1152
		{
sl@0
  1153
		err = KErrNoMemory;
sl@0
  1154
		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
sl@0
  1155
		TInt allocationNo = 0;
sl@0
  1156
		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
sl@0
  1157
		while(allocationNo < KMaxAllocation)
sl@0
  1158
			{
sl@0
  1159
			MarkHandles();
sl@0
  1160
			MarkAllocatedCells();
sl@0
  1161
sl@0
  1162
			__UHEAP_MARK;
sl@0
  1163
sl@0
  1164
			if(TheOomTestType[i] == EServerSideTest)
sl@0
  1165
				{//We will delay the heap failure simulation, until the database is opened
sl@0
  1166
				SetDbHeapFailure(TheOomTestType[i], ++allocationNo, ETrue);
sl@0
  1167
				}
sl@0
  1168
sl@0
  1169
			err = db.Open(KTestDb);
sl@0
  1170
			TEST2(err, KErrNone);
sl@0
  1171
sl@0
  1172
			if(TheOomTestType[i] == EClientSideTest)
sl@0
  1173
				{
sl@0
  1174
				SetDbHeapFailure(TheOomTestType[i], ++allocationNo);
sl@0
  1175
				}
sl@0
  1176
sl@0
  1177
			TRAP(err, (*aTestFunctionPtrL)(db));
sl@0
  1178
			db.Close();
sl@0
  1179
			if(err != KErrNoMemory)
sl@0
  1180
				{
sl@0
  1181
				TEST2(err, KErrNone);
sl@0
  1182
				}
sl@0
  1183
			else
sl@0
  1184
				{
sl@0
  1185
				failingAllocationNo = allocationNo;	
sl@0
  1186
				}
sl@0
  1187
sl@0
  1188
			ResetDbHeapFailure(TheOomTestType[i]);
sl@0
  1189
sl@0
  1190
			__UHEAP_MARKEND;
sl@0
  1191
sl@0
  1192
			CheckAllocatedCells();
sl@0
  1193
			CheckHandles();
sl@0
  1194
			}
sl@0
  1195
		TEST2(err, KErrNone);
sl@0
  1196
		PrintEndOfOomTest(TheOomTestType[i], failingAllocationNo);
sl@0
  1197
		}
sl@0
  1198
	//Delete the database file
sl@0
  1199
	RSqlDatabase::Delete(KTestDb);
sl@0
  1200
	}
sl@0
  1201
sl@0
  1202
//RSqlStatement OOM tests
sl@0
  1203
void StmtOomTestsL()
sl@0
  1204
	{
sl@0
  1205
	const TInt KTestCnt = 2;
sl@0
  1206
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1207
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1208
sl@0
  1209
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1210
		{
sl@0
  1211
		TheTest.Printf(_L("===RSqlStatement::Prepare(), 8-bit SQL\r\n"));
sl@0
  1212
		DoStmtPrepareOomTestL(&PrepareStmt8L, dbFileName[i], dbType[i]);
sl@0
  1213
sl@0
  1214
		TheTest.Printf(_L("===RSqlStatement::PrepareL(), 8-bit SQL\r\n"));
sl@0
  1215
		DoStmtPrepareOomTestL(&PrepareStmt8_2L, dbFileName[i], dbType[i]);
sl@0
  1216
sl@0
  1217
		TheTest.Printf(_L("===RSqlStatement::Prepare(), 16-bit SQL\r\n"));
sl@0
  1218
		DoStmtPrepareOomTestL(&PrepareStmt16L, dbFileName[i], dbType[i]);
sl@0
  1219
sl@0
  1220
		TheTest.Printf(_L("===RSqlStatement::PrepareL(), 16-bit SQL\r\n"));
sl@0
  1221
		DoStmtPrepareOomTestL(&PrepareStmt16_2L, dbFileName[i], dbType[i]);
sl@0
  1222
sl@0
  1223
		TheTest.Printf(_L("===RSqlStatement::Reset(), 8-bit SQL\r\n"));
sl@0
  1224
		DoStmtOomTestL(&PrepareStmt8L, &ResetStmtL, dbFileName[i], dbType[i]);
sl@0
  1225
sl@0
  1226
		TheTest.Printf(_L("===RSqlStatement::Reset(), 16-bit SQL\r\n"));
sl@0
  1227
		DoStmtOomTestL(&PrepareStmt16L, &ResetStmtL, dbFileName[i], dbType[i]);
sl@0
  1228
sl@0
  1229
		TheTest.Printf(_L("===RSqlStatement::Exec(), 8-bit SQL\r\n"));
sl@0
  1230
		DoStmtOomTestL(&PrepareInsertStmt8L, &ExecStmtL, dbFileName[i], dbType[i]);
sl@0
  1231
sl@0
  1232
		TheTest.Printf(_L("===RSqlStatement::Exec(), 16-bit SQL\r\n"));
sl@0
  1233
		DoStmtOomTestL(&PrepareInsertStmt16L, &ExecStmtL, dbFileName[i], dbType[i]);
sl@0
  1234
sl@0
  1235
		TheTest.Printf(_L("===RSqlStatement::Next(), 8-bit SQL\r\n"));
sl@0
  1236
		DoStmtOomTestL(&PrepareStmt8L, &NextStmtL, dbFileName[i], dbType[i]);
sl@0
  1237
sl@0
  1238
		TheTest.Printf(_L("===RSqlStatement::Next(), 16-bit SQL\r\n"));
sl@0
  1239
		DoStmtOomTestL(&PrepareStmt16L, &NextStmtL, dbFileName[i], dbType[i]);
sl@0
  1240
sl@0
  1241
		TheTest.Printf(_L("===RSqlStatement::ParameterIndex(), 8-bit SQL\r\n"));
sl@0
  1242
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtParameterIndexL, dbFileName[i], dbType[i]);
sl@0
  1243
sl@0
  1244
		TheTest.Printf(_L("===RSqlStatement::ParameterIndex(), 16-bit SQL\r\n"));
sl@0
  1245
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtParameterIndexL, dbFileName[i], dbType[i]);
sl@0
  1246
sl@0
  1247
		TheTest.Printf(_L("===RSqlStatement::ParameterName(), 8-bit SQL\r\n"));
sl@0
  1248
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtParameterNameL, dbFileName[i], dbType[i]);
sl@0
  1249
sl@0
  1250
		TheTest.Printf(_L("===RSqlStatement::ParameterName(), 16-bit SQL\r\n"));
sl@0
  1251
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtParameterNameL, dbFileName[i], dbType[i]);
sl@0
  1252
sl@0
  1253
		TheTest.Printf(_L("===RSqlStatement::ParamName(), 8-bit SQL\r\n"));
sl@0
  1254
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtParamNameL, dbFileName[i], dbType[i]);
sl@0
  1255
sl@0
  1256
		TheTest.Printf(_L("===RSqlStatement::ParamName(), 16-bit SQL\r\n"));
sl@0
  1257
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtParamNameL, dbFileName[i], dbType[i]);
sl@0
  1258
sl@0
  1259
		TheTest.Printf(_L("===RSqlStatement::ColumnIndex(), 8-bit SQL\r\n"));
sl@0
  1260
		DoStmtOomTestL(&PrepareStmt8L, &StmtColumnIndexL, dbFileName[i], dbType[i]);
sl@0
  1261
sl@0
  1262
		TheTest.Printf(_L("===RSqlStatement::ColumnIndex(), 16-bit SQL\r\n"));
sl@0
  1263
		DoStmtOomTestL(&PrepareStmt16L, &StmtColumnIndexL, dbFileName[i], dbType[i]);
sl@0
  1264
sl@0
  1265
		TheTest.Printf(_L("===RSqlStatement::ColumnType(), 8-bit SQL\r\n"));
sl@0
  1266
		DoStmtOomTestL(&PrepareMoveStmt8L, &StmtColumnTypeL, dbFileName[i], dbType[i]);
sl@0
  1267
sl@0
  1268
		TheTest.Printf(_L("===RSqlStatement::ColumnType(), 16-bit SQL\r\n"));
sl@0
  1269
		DoStmtOomTestL(&PrepareMoveStmt16L, &StmtColumnTypeL, dbFileName[i], dbType[i]);
sl@0
  1270
sl@0
  1271
		TheTest.Printf(_L("===RSqlStatement::ColumnSize(), 8-bit SQL\r\n"));
sl@0
  1272
		DoStmtOomTestL(&PrepareMoveStmt8L, &StmtColumnSizeL, dbFileName[i], dbType[i]);
sl@0
  1273
sl@0
  1274
		TheTest.Printf(_L("===RSqlStatement::ColumnSize(), 16-bit SQL\r\n"));
sl@0
  1275
		DoStmtOomTestL(&PrepareMoveStmt16L, &StmtColumnSizeL, dbFileName[i], dbType[i]);
sl@0
  1276
sl@0
  1277
		TheTest.Printf(_L("===RSqlStatement::ColumnName(), 8-bit SQL\r\n"));
sl@0
  1278
		DoStmtOomTestL(&PrepareMoveStmt8L, &StmtColumnNameL, dbFileName[i], dbType[i]);
sl@0
  1279
sl@0
  1280
		TheTest.Printf(_L("===RSqlStatement::ColumnName(), 16-bit SQL\r\n"));
sl@0
  1281
		DoStmtOomTestL(&PrepareMoveStmt16L, &StmtColumnNameL, dbFileName[i], dbType[i]);
sl@0
  1282
sl@0
  1283
		TheTest.Printf(_L("===RSqlStatement::BindNull(), 8-bit SQL\r\n"));
sl@0
  1284
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindNullL, dbFileName[i], dbType[i]);
sl@0
  1285
sl@0
  1286
		TheTest.Printf(_L("===RSqlStatement::BindNull(), 16-bit SQL\r\n"));
sl@0
  1287
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindNullL, dbFileName[i], dbType[i]);
sl@0
  1288
sl@0
  1289
		TheTest.Printf(_L("===RSqlStatement::BindInt(), 8-bit SQL\r\n"));
sl@0
  1290
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindIntL, dbFileName[i], dbType[i]);
sl@0
  1291
sl@0
  1292
		TheTest.Printf(_L("===RSqlStatement::BindInt(), 16-bit SQL\r\n"));
sl@0
  1293
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindIntL, dbFileName[i], dbType[i]);
sl@0
  1294
sl@0
  1295
		TheTest.Printf(_L("===RSqlStatement::BindInt64(), 8-bit SQL\r\n"));
sl@0
  1296
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindInt64L, dbFileName[i], dbType[i]);
sl@0
  1297
sl@0
  1298
		TheTest.Printf(_L("===RSqlStatement::BindInt64(), 16-bit SQL\r\n"));
sl@0
  1299
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindInt64L, dbFileName[i], dbType[i]);
sl@0
  1300
sl@0
  1301
		TheTest.Printf(_L("===RSqlStatement::BindReal(), 8-bit SQL\r\n"));
sl@0
  1302
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindRealL, dbFileName[i], dbType[i]);
sl@0
  1303
sl@0
  1304
		TheTest.Printf(_L("===RSqlStatement::BindReal(), 16-bit SQL\r\n"));
sl@0
  1305
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindRealL, dbFileName[i], dbType[i]);
sl@0
  1306
sl@0
  1307
		TheTest.Printf(_L("===RSqlStatement::BindText(), 8-bit SQL\r\n"));
sl@0
  1308
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindTextL, dbFileName[i], dbType[i]);
sl@0
  1309
sl@0
  1310
		TheTest.Printf(_L("===RSqlStatement::BindText(), 16-bit SQL\r\n"));
sl@0
  1311
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindTextL, dbFileName[i], dbType[i]);
sl@0
  1312
sl@0
  1313
		TheTest.Printf(_L("===RSqlStatement::BindBinary(), 8-bit SQL\r\n"));
sl@0
  1314
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindBinaryL, dbFileName[i], dbType[i]);
sl@0
  1315
sl@0
  1316
		TheTest.Printf(_L("===RSqlStatement::BindBinary(), 16-bit SQL\r\n"));
sl@0
  1317
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindBinaryL, dbFileName[i], dbType[i]);
sl@0
  1318
sl@0
  1319
		TheTest.Printf(_L("===RSqlStatement::BindZeroBlob(), 8-bit SQL\r\n"));
sl@0
  1320
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtBindZeroBlobL, dbFileName[i], dbType[i]);
sl@0
  1321
sl@0
  1322
		TheTest.Printf(_L("===RSqlStatement::BindZeroBlob(), 16-bit SQL\r\n"));
sl@0
  1323
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtBindZeroBlobL, dbFileName[i], dbType[i]);
sl@0
  1324
sl@0
  1325
		TheTest.Printf(_L("===RSqlStatement::IsNull(), 8-bit SQL\r\n"));
sl@0
  1326
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtIsNullColumnL, dbFileName[i], dbType[i]);
sl@0
  1327
sl@0
  1328
		TheTest.Printf(_L("===RSqlStatement::IsNull(), 16-bit SQL\r\n"));
sl@0
  1329
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtIsNullColumnL, dbFileName[i], dbType[i]);
sl@0
  1330
sl@0
  1331
		TheTest.Printf(_L("===RSqlStatement::ColumnInt(), 8-bit SQL\r\n"));
sl@0
  1332
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnIntL, dbFileName[i], dbType[i]);
sl@0
  1333
sl@0
  1334
		TheTest.Printf(_L("===RSqlStatement::ColumnInt(), 16-bit SQL\r\n"));
sl@0
  1335
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnIntL, dbFileName[i], dbType[i]);
sl@0
  1336
sl@0
  1337
		TheTest.Printf(_L("===RSqlStatement::ColumnInt64(), 8-bit SQL\r\n"));
sl@0
  1338
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnInt64L, dbFileName[i], dbType[i]);
sl@0
  1339
sl@0
  1340
		TheTest.Printf(_L("===RSqlStatement::ColumnInt64(), 16-bit SQL\r\n"));
sl@0
  1341
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnInt64L, dbFileName[i], dbType[i]);
sl@0
  1342
sl@0
  1343
		TheTest.Printf(_L("===RSqlStatement::ColumnReal(), 8-bit SQL\r\n"));
sl@0
  1344
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnRealL, dbFileName[i], dbType[i]);
sl@0
  1345
sl@0
  1346
		TheTest.Printf(_L("===RSqlStatement::ColumnReal(), 16-bit SQL\r\n"));
sl@0
  1347
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnRealL, dbFileName[i], dbType[i]);
sl@0
  1348
sl@0
  1349
		TheTest.Printf(_L("===RSqlStatement::ColumnTextL(), 8-bit SQL\r\n"));
sl@0
  1350
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnText1L, dbFileName[i], dbType[i]);
sl@0
  1351
sl@0
  1352
		TheTest.Printf(_L("===RSqlStatement::ColumnTextL(), 16-bit SQL\r\n"));
sl@0
  1353
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnText1L, dbFileName[i], dbType[i]);
sl@0
  1354
sl@0
  1355
		TheTest.Printf(_L("===RSqlStatement::ColumnText()-1, 8-bit SQL\r\n"));
sl@0
  1356
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnText2L, dbFileName[i], dbType[i]);
sl@0
  1357
sl@0
  1358
		TheTest.Printf(_L("===RSqlStatement::ColumnText()-1, 16-bit SQL\r\n"));
sl@0
  1359
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnText2L, dbFileName[i], dbType[i]);
sl@0
  1360
sl@0
  1361
		TheTest.Printf(_L("===RSqlStatement::ColumnText()-2, 8-bit SQL\r\n"));
sl@0
  1362
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnText3L, dbFileName[i], dbType[i]);
sl@0
  1363
sl@0
  1364
		TheTest.Printf(_L("===RSqlStatement::ColumnText()-2, 16-bit SQL\r\n"));
sl@0
  1365
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnText3L, dbFileName[i], dbType[i]);
sl@0
  1366
sl@0
  1367
		TheTest.Printf(_L("===RSqlStatement::ColumnBinaryL(), 8-bit SQL\r\n"));
sl@0
  1368
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnBinary1L, dbFileName[i], dbType[i]);
sl@0
  1369
sl@0
  1370
		TheTest.Printf(_L("===RSqlStatement::ColumnBinaryL(), 16-bit SQL\r\n"));
sl@0
  1371
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnBinary1L, dbFileName[i], dbType[i]);
sl@0
  1372
sl@0
  1373
		TheTest.Printf(_L("===RSqlStatement::ColumnBinary()-1, 8-bit SQL\r\n"));
sl@0
  1374
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnBinary2L, dbFileName[i], dbType[i]);
sl@0
  1375
sl@0
  1376
		TheTest.Printf(_L("===RSqlStatement::ColumnBinary()-1, 16-bit SQL\r\n"));
sl@0
  1377
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnBinary2L, dbFileName[i], dbType[i]);
sl@0
  1378
sl@0
  1379
		TheTest.Printf(_L("===RSqlStatement::ColumnBinary()-2, 8-bit SQL\r\n"));
sl@0
  1380
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnBinary3L, dbFileName[i], dbType[i]);
sl@0
  1381
sl@0
  1382
		TheTest.Printf(_L("===RSqlStatement::ColumnBinary()-2, 16-bit SQL\r\n"));
sl@0
  1383
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnBinary3L, dbFileName[i], dbType[i]);
sl@0
  1384
sl@0
  1385
		TheTest.Printf(_L("===RSqlStatement::ColumnCount(), 8-bit SQL\r\n"));
sl@0
  1386
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnCount, dbFileName[i], dbType[i]);
sl@0
  1387
sl@0
  1388
		TheTest.Printf(_L("===RSqlStatement::ColumnCount(), 16-bit SQL\r\n"));
sl@0
  1389
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnCount, dbFileName[i], dbType[i]);
sl@0
  1390
sl@0
  1391
		TheTest.Printf(_L("===RSqlStatement::DeclaredColumnType(), 8-bit SQL\r\n"));
sl@0
  1392
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtDeclaredColumnTypeL, dbFileName[i], dbType[i]);
sl@0
  1393
sl@0
  1394
		TheTest.Printf(_L("===RSqlStatement::DeclaredColumnType(), 16-bit SQL\r\n"));
sl@0
  1395
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtDeclaredColumnTypeL, dbFileName[i], dbType[i]);
sl@0
  1396
		}
sl@0
  1397
	}
sl@0
  1398
sl@0
  1399
//RSqlStatement - negative OOM tests
sl@0
  1400
void StmtOomNegativeTestsL()
sl@0
  1401
	{
sl@0
  1402
	const TInt KTestCnt = 2;
sl@0
  1403
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1404
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1405
sl@0
  1406
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1407
		{
sl@0
  1408
		TheTest.Printf(_L("===RSqlStatement::Prepare(), 8-bit SQL\r\n"));
sl@0
  1409
		DoStmtPrepareOomTestL(&PrepareBadStmt8L, dbFileName[i], dbType[i], KSqlErrGeneral);
sl@0
  1410
sl@0
  1411
		TheTest.Printf(_L("===RSqlStatement::Prepare(), 16-bit SQL\r\n"));
sl@0
  1412
		DoStmtPrepareOomTestL(&PrepareBadStmt16L, dbFileName[i], dbType[i], KSqlErrGeneral);
sl@0
  1413
		}
sl@0
  1414
	}
sl@0
  1415
sl@0
  1416
//RSqlColumnReadStream OOM tests
sl@0
  1417
void ColumnReadStreamOomTestsL()
sl@0
  1418
	{
sl@0
  1419
	const TInt KTestCnt = 2;
sl@0
  1420
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1421
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1422
sl@0
  1423
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1424
		{
sl@0
  1425
		TheTest.Printf(_L("===RSqlColumnReadStream::ColumnBinary(), 8-bit SQL\r\n"));
sl@0
  1426
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnBinaryStreamL, dbFileName[i], dbType[i]);
sl@0
  1427
sl@0
  1428
		TheTest.Printf(_L("===RSqlColumnReadStream::ColumnBinary(), 16-bit SQL\r\n"));
sl@0
  1429
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnBinaryStreamL, dbFileName[i], dbType[i]);
sl@0
  1430
sl@0
  1431
		TheTest.Printf(_L("===RSqlColumnReadStream::ColumnText(), 8-bit SQL\r\n"));
sl@0
  1432
		DoStmtOomTestL(&ExecInsertNextStmt8L, &StmtColumnTextStreamL, dbFileName[i], dbType[i]);
sl@0
  1433
sl@0
  1434
		TheTest.Printf(_L("===RSqlColumnReadStream::ColumnText(), 16-bit SQL\r\n"));
sl@0
  1435
		DoStmtOomTestL(&ExecInsertNextStmt16L, &StmtColumnTextStreamL, dbFileName[i], dbType[i]);
sl@0
  1436
		}
sl@0
  1437
	}
sl@0
  1438
sl@0
  1439
//RSqlParamWriteStream OOM tests
sl@0
  1440
void ParamWriteStreamOomTestsL()
sl@0
  1441
	{
sl@0
  1442
	const TInt KTestCnt = 2;
sl@0
  1443
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1444
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1445
sl@0
  1446
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1447
		{
sl@0
  1448
		TheTest.Printf(_L("===RSqlParamWriteStream::BindBinary(), 8-bit SQL\r\n"));
sl@0
  1449
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtParamBinaryStreamL, dbFileName[i], dbType[i]);
sl@0
  1450
sl@0
  1451
		TheTest.Printf(_L("===RSqlParamWriteStream::BindBinary(), 16-bit SQL\r\n"));
sl@0
  1452
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtParamBinaryStreamL, dbFileName[i], dbType[i]);
sl@0
  1453
sl@0
  1454
		TheTest.Printf(_L("===RSqlParamWriteStream::BindText(), 8-bit SQL\r\n"));
sl@0
  1455
		DoStmtOomTestL(&PrepareInsertPrmStmt8L, &StmtParamTextStreamL, dbFileName[i], dbType[i]);
sl@0
  1456
sl@0
  1457
		TheTest.Printf(_L("===RSqlParamWriteStream::BindText(), 16-bit SQL\r\n"));
sl@0
  1458
		DoStmtOomTestL(&PrepareInsertPrmStmt16L, &StmtParamTextStreamL, dbFileName[i], dbType[i]);
sl@0
  1459
		}
sl@0
  1460
	}
sl@0
  1461
sl@0
  1462
//TSqlScalarFullSelectQuery OOM tests
sl@0
  1463
void ScalarFullSelectQueryOomTestsL()
sl@0
  1464
	{
sl@0
  1465
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectIntL(), 8-bit SQL\r\n"));
sl@0
  1466
	DoFullSelectOomTest(&ScalarFullSelectInt_8L);
sl@0
  1467
sl@0
  1468
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectInt64L(), 8-bit SQL\r\n"));
sl@0
  1469
	DoFullSelectOomTest(&ScalarFullSelectInt64_8L);
sl@0
  1470
sl@0
  1471
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectRealL(), 8-bit SQL\r\n"));
sl@0
  1472
	DoFullSelectOomTest(&ScalarFullSelectReal_8L);
sl@0
  1473
sl@0
  1474
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectTextL(), 8-bit SQL\r\n"));
sl@0
  1475
	DoFullSelectOomTest(&ScalarFullSelectText_8L);
sl@0
  1476
sl@0
  1477
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectBinaryL(), 8-bit SQL\r\n"));
sl@0
  1478
	DoFullSelectOomTest(&ScalarFullSelectBinary_8L);
sl@0
  1479
sl@0
  1480
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectIntL(), 16-bit SQL\r\n"));
sl@0
  1481
	DoFullSelectOomTest(&ScalarFullSelectInt_16L);
sl@0
  1482
sl@0
  1483
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectInt64L(), 16-bit SQL\r\n"));
sl@0
  1484
	DoFullSelectOomTest(&ScalarFullSelectInt64_16L);
sl@0
  1485
sl@0
  1486
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectRealL(), 16-bit SQL\r\n"));
sl@0
  1487
	DoFullSelectOomTest(&ScalarFullSelectReal_16L);
sl@0
  1488
sl@0
  1489
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectTextL(), 16-bit SQL\r\n"));
sl@0
  1490
	DoFullSelectOomTest(&ScalarFullSelectText_16L);
sl@0
  1491
sl@0
  1492
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectBinaryL(), 16-bit SQL\r\n"));
sl@0
  1493
	DoFullSelectOomTest(&ScalarFullSelectBinary_16L);
sl@0
  1494
sl@0
  1495
	TheTest.Printf(_L("===TSqlScalarFullSelectQuery::SelectTextL(), 8-bit SQL, small buffer\r\n"));
sl@0
  1496
	DoFullSelectOomTest(&ScalarFullSelectText2_8L);
sl@0
  1497
	}
sl@0
  1498
sl@0
  1499
void BlobReadStreamOomTestsL()
sl@0
  1500
	{
sl@0
  1501
	const TInt KTestCnt = 2;
sl@0
  1502
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1503
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1504
sl@0
  1505
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1506
		{
sl@0
  1507
		TheTest.Printf(_L("===RSqlBlobReadStream::OpenL()/RSqlBlobReadStream::ReadL()\r\n"));
sl@0
  1508
		DoBlobOomTestL(&ExecInsertBlobL, &BlobReadStreamOpenL, dbFileName[i], dbType[i]);
sl@0
  1509
sl@0
  1510
		TheTest.Printf(_L("===RSqlBlobReadStream::OpenL()/RSqlBlobReadStream::ReadL() + attached database\r\n"));
sl@0
  1511
		DoBlobOomTestL(&ExecInsertBlobL, &BlobReadStreamOpenL, dbFileName[i], dbType[i], ETrue);
sl@0
  1512
sl@0
  1513
		TheTest.Printf(_L("===RSqlBlobReadStream::OpenL()/RSqlBlobReadStream::SizeL()\r\n"));
sl@0
  1514
		DoBlobOomTestL(&ExecInsertBlobL, &BlobReadStreamSizeL, dbFileName[i], dbType[i]);
sl@0
  1515
sl@0
  1516
		TheTest.Printf(_L("===RSqlBlobReadStream::OpenL()/RSqlBlobReadStream::SizeL() + attached database\r\n"));
sl@0
  1517
		DoBlobOomTestL(&ExecInsertBlobL, &BlobReadStreamSizeL, dbFileName[i], dbType[i], ETrue);
sl@0
  1518
		}
sl@0
  1519
	}
sl@0
  1520
sl@0
  1521
void BlobWriteStreamOomTestsL()
sl@0
  1522
	{
sl@0
  1523
	const TInt KTestCnt = 2;
sl@0
  1524
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1525
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1526
sl@0
  1527
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1528
		{
sl@0
  1529
		TheTest.Printf(_L("===RSqlBlobWriteStream::OpenL()/RSqlBlobWriteStream::WriteL()\r\n"));
sl@0
  1530
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWriteStreamOpenL, dbFileName[i], dbType[i]);
sl@0
  1531
sl@0
  1532
		TheTest.Printf(_L("===RSqlBlobWriteStream::OpenL()/RSqlBlobWriteStream::WriteL() + attached database\r\n"));
sl@0
  1533
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWriteStreamOpenL, dbFileName[i], dbType[i], ETrue);
sl@0
  1534
sl@0
  1535
		TheTest.Printf(_L("===RSqlBlobWriteStream::OpenL()/RSqlBlobWriteStream::SizeL()\r\n"));
sl@0
  1536
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWriteStreamSizeL, dbFileName[i], dbType[i]);
sl@0
  1537
sl@0
  1538
		TheTest.Printf(_L("===RSqlBlobWriteStream::OpenL()/RSqlBlobWriteStream::SizeL() + attached database\r\n"));
sl@0
  1539
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWriteStreamSizeL, dbFileName[i], dbType[i], ETrue);
sl@0
  1540
		}
sl@0
  1541
	}
sl@0
  1542
	
sl@0
  1543
void BlobWholeOomTestsL()
sl@0
  1544
	{
sl@0
  1545
	const TInt KTestCnt = 2;
sl@0
  1546
	const TPtrC dbFileName[KTestCnt] = {KTestDb(), 	KSecureTestDb()};
sl@0
  1547
	TDbType dbType[KTestCnt] = {ENonSecureDb, ESecureDb};
sl@0
  1548
sl@0
  1549
	for(TInt i=0;i<KTestCnt;++i)
sl@0
  1550
		{
sl@0
  1551
		TheTest.Printf(_L("===TSqlBlob::GetLC()\r\n"));
sl@0
  1552
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWholeGet1L, dbFileName[i], dbType[i]);
sl@0
  1553
sl@0
  1554
		TheTest.Printf(_L("===TSqlBlob::Get()\r\n"));
sl@0
  1555
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWholeGet2L, dbFileName[i], dbType[i]);
sl@0
  1556
sl@0
  1557
		TheTest.Printf(_L("===TSqlBlob::SetL()\r\n"));
sl@0
  1558
		DoBlobOomTestL(&ExecInsertBlobL, &BlobWholeSetL, dbFileName[i], dbType[i]);
sl@0
  1559
		}
sl@0
  1560
	}
sl@0
  1561
sl@0
  1562
void DoTestsL()
sl@0
  1563
	{
sl@0
  1564
	TheTest.Start(_L("SQL OOM tests - 2"));
sl@0
  1565
	
sl@0
  1566
	StmtOomTestsL();
sl@0
  1567
sl@0
  1568
	StmtOomNegativeTestsL();
sl@0
  1569
sl@0
  1570
	ColumnReadStreamOomTestsL();
sl@0
  1571
sl@0
  1572
	ParamWriteStreamOomTestsL();
sl@0
  1573
sl@0
  1574
	ScalarFullSelectQueryOomTestsL();
sl@0
  1575
sl@0
  1576
	BlobReadStreamOomTestsL();
sl@0
  1577
sl@0
  1578
	BlobWriteStreamOomTestsL();
sl@0
  1579
	
sl@0
  1580
	BlobWholeOomTestsL();
sl@0
  1581
	}
sl@0
  1582
sl@0
  1583
TInt E32Main()
sl@0
  1584
	{
sl@0
  1585
	TheTest.Title();
sl@0
  1586
sl@0
  1587
	CTrapCleanup* tc = CTrapCleanup::New();
sl@0
  1588
sl@0
  1589
	__UHEAP_MARK;
sl@0
  1590
sl@0
  1591
	CreateTestDir();
sl@0
  1592
	DeleteTestFiles();
sl@0
  1593
sl@0
  1594
	TRAPD(err, DoTestsL());
sl@0
  1595
	DeleteTestFiles();
sl@0
  1596
	TEST2(err, KErrNone);
sl@0
  1597
sl@0
  1598
	__UHEAP_MARKEND;
sl@0
  1599
sl@0
  1600
	TheTest.End();
sl@0
  1601
	TheTest.Close();
sl@0
  1602
sl@0
  1603
	delete tc;
sl@0
  1604
sl@0
  1605
	User::Heap().Check();
sl@0
  1606
	return KErrNone;
sl@0
  1607
	}