persistentstorage/sql/TEST/t_sqloom2.cpp
branchRCL_3
changeset 11 211563e4b919
parent 0 08ec8eefde2f
child 15 fcc16690f446
equal deleted inserted replaced
10:31a8f755b7fe 11:211563e4b919
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    43 static TUint8 TheBinaryColumnData[MAX(KLongColumnSize, KLongParameterSize) * sizeof(TUint16)];
    43 static TUint8 TheBinaryColumnData[MAX(KLongColumnSize, KLongParameterSize) * sizeof(TUint16)];
    44 
    44 
    45 //"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement)
    45 //"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement)
    46 void PrepareStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    46 void PrepareStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    47 	{
    47 	{
    48 	_LIT8(KSqlString, "SELECT * FROM BBB");
    48 	_LIT8(KSqlString, "SELECT * FROM BBB WHERE Fld1=? AND Fld4<>?");
    49 	TInt err = aStmt.Prepare(aDb, KSqlString);
    49 	TInt err = aStmt.Prepare(aDb, KSqlString);
    50 	User::LeaveIfError(err);
    50 	User::LeaveIfError(err);
    51 	}
    51 	}
    52 
    52 
    53 //"RSqlStatement::PrepareL()" OOM test (8-bit SELECT SQL statement)
    53 //"RSqlStatement::PrepareL()" OOM test (8-bit SELECT SQL statement)
    54 void PrepareStmt8_2L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    54 void PrepareStmt8_2L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    55 	{
    55 	{
    56 	_LIT8(KSqlString, "SELECT * FROM BBB");
    56 	_LIT8(KSqlString, "SELECT * FROM BBB WHERE Fld1=? AND Fld4<>?");
    57 	aStmt.PrepareL(aDb, KSqlString);
    57 	aStmt.PrepareL(aDb, KSqlString);
    58 	}
    58 	}
    59 
    59 
    60 //"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement), syntax error
    60 //"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement), syntax error
    61 void PrepareBadStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    61 void PrepareBadStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    62 	{
    62 	{
    63 	_LIT8(KSqlString, "SELECT123 * FROM BBB");
    63 	_LIT8(KSqlString, "SELECT123 * FROM BBB WHERE Fld1=? AND Fld4<>?");
    64 	TInt err = aStmt.Prepare(aDb, KSqlString);
    64 	TInt err = aStmt.Prepare(aDb, KSqlString);
    65 	User::LeaveIfError(err);
    65 	User::LeaveIfError(err);
    66 	}
    66 	}
    67 
    67 
    68 //"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement, move next)
    68 //"RSqlStatement::Prepare()" OOM test (8-bit SELECT SQL statement, move next)
    69 void PrepareMoveStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    69 void PrepareMoveStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    70 	{
    70 	{
    71 	_LIT8(KSqlString, "SELECT * FROM BBB");
    71 	_LIT8(KSqlString, "SELECT * FROM BBB WHERE Fld1=? AND Fld4<>?");
    72 	TInt err = aStmt.Prepare(aDb, KSqlString);
    72 	TInt err = aStmt.Prepare(aDb, KSqlString);
    73 	if(err == KErrNone)
    73     User::LeaveIfError(err);
    74 		{
    74     err = aStmt.BindInt(0, 1);
    75 		err = aStmt.Next();
    75     User::LeaveIfError(err);
    76 		if(err == KSqlAtRow)
    76     err = aStmt.BindText(1, _L("data244weewfn43wr83224iu23ewkjfbrektug4i433b3k45b"));
    77 			{
    77     User::LeaveIfError(err);
    78 			err = KErrNone;
    78     err = aStmt.Next();
    79 			}
    79     if(err == KSqlAtRow)
    80 		}
    80         {
       
    81         err = KErrNone;
       
    82         }
    81 	User::LeaveIfError(err);
    83 	User::LeaveIfError(err);
    82 	}
    84 	}
    83 
    85 
    84 //"RSqlStatement::Prepare()" OOM test (8-bit INSERT SQL statement)
    86 //"RSqlStatement::Prepare()" OOM test (8-bit INSERT SQL statement)
    85 void PrepareInsertStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
    87 void PrepareInsertStmt8L(RSqlDatabase& aDb, RSqlStatement& aStmt)
   259 		dummyStmt.Close();
   261 		dummyStmt.Close();
   260 
   262 
   261 		err = KErrNoMemory;
   263 		err = KErrNoMemory;
   262 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
   264 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
   263 		TInt allocationNo = 0;
   265 		TInt allocationNo = 0;
   264 		TInt failingAllocationNo = 0;
   266 		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
   265 		while(allocationNo < KMaxAllocation)
   267 		while(allocationNo < KMaxAllocation)
   266 			{
   268 			{
   267 			MarkHandles();
   269 			MarkHandles();
   268 			MarkAllocatedCells();
   270 			MarkAllocatedCells();
   269 
   271 
   724 		TEST(err >= 0);
   726 		TEST(err >= 0);
   725 
   727 
   726 		err = KErrNoMemory;
   728 		err = KErrNoMemory;
   727 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
   729 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
   728 		TInt allocationNo = 0;
   730 		TInt allocationNo = 0;
   729 		TInt failingAllocationNo = 0;
   731 		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
   730 		while(allocationNo < KMaxAllocation)
   732 		while(allocationNo < KMaxAllocation)
   731 			{
   733 			{
   732 			MarkHandles();
   734 			MarkHandles();
   733 			MarkAllocatedCells();
   735 			MarkAllocatedCells();
   734 
   736 
   959 			}
   961 			}
   960 
   962 
   961 		err = KErrNoMemory;
   963 		err = KErrNoMemory;
   962 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KBlobOomTestAllocLimitServer : KBlobOomTestAllocLimitClient;
   964 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KBlobOomTestAllocLimitServer : KBlobOomTestAllocLimitClient;
   963 		TInt allocationNo = 0;
   965 		TInt allocationNo = 0;
   964 		TInt failingAllocationNo = 0;
   966 		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
   965 		while(allocationNo < KMaxAllocation)
   967 		while(allocationNo < KMaxAllocation)
   966 			{
   968 			{
   967 			MarkHandles();
   969 			MarkHandles();
   968 			MarkAllocatedCells();
   970 			MarkAllocatedCells();
   969 
   971 
  1149 	for(TInt i=0;i<(TInt)(sizeof(TheOomTestType)/sizeof(TheOomTestType[0]));++i)
  1151 	for(TInt i=0;i<(TInt)(sizeof(TheOomTestType)/sizeof(TheOomTestType[0]));++i)
  1150 		{
  1152 		{
  1151 		err = KErrNoMemory;
  1153 		err = KErrNoMemory;
  1152 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
  1154 		const TInt KMaxAllocation = TheOomTestType[i] == EServerSideTest ? KStmtOomTestAllocLimitServer : KStmtOomTestAllocLimitClient;
  1153 		TInt allocationNo = 0;
  1155 		TInt allocationNo = 0;
  1154 		TInt failingAllocationNo = 0;
  1156 		TInt failingAllocationNo = 0;//the real exit point of the OOM test. allocationNo is set KMaxAllocation times.
  1155 		while(allocationNo < KMaxAllocation)
  1157 		while(allocationNo < KMaxAllocation)
  1156 			{
  1158 			{
  1157 			MarkHandles();
  1159 			MarkHandles();
  1158 			MarkAllocatedCells();
  1160 			MarkAllocatedCells();
  1159 
  1161