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