sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_sqlitewsd.h" sl@0: sl@0: void DoInserts(TInt aProcId, TInt aRecId1, TInt aRecId2) sl@0: { sl@0: TEST(TheDb != 0); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: TInt64 seed = now.Int64(); sl@0: sl@0: const TInt KMaxFailingAllocationNo = 20; sl@0: TInt lockcnt = 0; sl@0: sl@0: for(TInt recno=0;recno sql; sl@0: sql.Format(_L8("INSERT INTO A VALUES(%d)"), aRecId1); sl@0: TInt err = sqlite3_exec(TheDb, (const char*)sql.PtrZ(), 0, 0, 0); sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: TEST(err == SQLITE_NOMEM || err == SQLITE_BUSY || err == SQLITE_OK); sl@0: if(err == SQLITE_BUSY) sl@0: { sl@0: ++lockcnt; sl@0: User::After(1); sl@0: continue; sl@0: } sl@0: else if(err == SQLITE_OK) sl@0: { sl@0: ++recno; sl@0: if((recno % 100) == 0) sl@0: { sl@0: RDebug::Print(_L("Process %d: %d records inserted.\r\n"), aProcId, recno); sl@0: } sl@0: continue; sl@0: } sl@0: //Insert record 2 sl@0: sql.Format(_L8("INSERT INTO A VALUES(%d)"), aRecId2); sl@0: err = sqlite3_exec(TheDb, (const char*)sql.PtrZ(), 0, 0, 0); sl@0: TEST(err == SQLITE_BUSY || err == SQLITE_OK); sl@0: if(err == SQLITE_BUSY) sl@0: { sl@0: ++lockcnt; sl@0: User::After(1); sl@0: continue; sl@0: } sl@0: //SQLITE_OK case sl@0: ++recno; sl@0: if((recno % 100) == 0) sl@0: { sl@0: RDebug::Print(_L("Process %d: %d records inserted.\r\n"), aProcId, recno); sl@0: } sl@0: } sl@0: RDebug::Print(_L("Process %d inserted %d records. %d locks occured.\r\n"), aProcId, KTestRecordCnt, lockcnt); sl@0: } sl@0: