sl@0: sl@0: // Called by BasicSQL2.script. sl@0: // Tests that a transaction which is not completed is visible to a EReadUncommitted sl@0: // session and simultaneously (so a bit of concurrency), not visible sl@0: // to a EReadSerializable session. sl@0: sl@0: // Set up a new database. sl@0: [Thread1] sl@0: WaitB0=2 sl@0: Delete1=C:\Transaction0.db sl@0: ExpectedError1=KErrNotFound sl@0: Create2=C:\Transaction0.db sl@0: Exec3=Create Table Curtab(f1 int primary key, f2 real, f3 text); sl@0: Prepare4=Insert into Curtab(f1, f2, f3) values(:mary, :mungo, :midge); sl@0: ParameterIndex5=:mary sl@0: ParameterIndex6=:mungo sl@0: ParameterIndex7=:midge sl@0: BindInt8=0,-4853 sl@0: BindReal9=1,6.0827626 sl@0: BindText10=2,Here's some text sl@0: St_Exec11= sl@0: Reset12= sl@0: St_Close13= sl@0: // At this point one record outside of a transaction is present. sl@0: sl@0: NoOperation14= sl@0: Exec15=Begin Transaction; sl@0: Prepare16=Insert into Curtab(f1, f2, f3) values(:mary, :mungo, :midge); sl@0: ParameterIndex17=:mary sl@0: ParameterIndex18=:mungo sl@0: ParameterIndex19=:midge sl@0: BindInt20=0,9876 sl@0: BindReal21=1,7.0710678 sl@0: BindText22=2,Here's yet more text sl@0: St_Exec23= sl@0: Reset24= sl@0: BindInt25=0,1011010 sl@0: BindReal26=1,182282.397 sl@0: BindText27=2,I want chocolate. Now. sl@0: St_Exec28= sl@0: Reset29= sl@0: BindInt30=0,7070707 sl@0: BindReal31=1,-1.60217733e-19 sl@0: BindText32=2,Now I want ice-cream. sl@0: St_Exec33= sl@0: Reset34= sl@0: St_Close35= sl@0: // At this point we've added one row outside of the transaction and 3 more sl@0: // within it. Send a signal to the slave threads which will check for the sl@0: // above content (one is ESerializable, one is EReadUncommitted, so they'll sl@0: // see different content). sl@0: // Wake up 2 threads.. sl@0: SignalA36=2 sl@0: // Wait for two signals to show they've finished.. sl@0: WaitB37=2 sl@0: Exec38=Rollback; sl@0: Close39= sl@0: EndBlock40= sl@0: sl@0: // ESerializable thread. sl@0: [Thread2] sl@0: SignalB0=1 sl@0: // Wait until the db has been setup. sl@0: WaitA1=1 sl@0: Open2=C:\Transaction0.db sl@0: SetIsolationLevel3=ESerializable sl@0: Prepare4=Select * from Curtab; sl@0: ColumnIndex5=f1 sl@0: ColumnIndex6=f2 sl@0: ColumnIndex7=f3 sl@0: Next8= sl@0: ExpectedError8=KSqlErrLocked sl@0: St_Close9= sl@0: Close10= sl@0: SignalB11=1 sl@0: EndBlock12= sl@0: sl@0: [Thread3] sl@0: SignalB0=1 sl@0: // Wait until the db has been setup. sl@0: WaitA1=1 sl@0: Open2=C:\Transaction0.db sl@0: SetIsolationLevel3=EReadUncommitted sl@0: Prepare4=Select * from Curtab; sl@0: ColumnIndex5=f1 sl@0: ColumnIndex6=f2 sl@0: ColumnIndex7=f3 sl@0: Next8=KSqlAtRow sl@0: ColumnInt9=0,-4853 sl@0: ColumnReal10=1,6.0827626 sl@0: ColumnTextL11=2,Here's some text sl@0: Next12=KSqlAtRow sl@0: ColumnInt13=0,9876 sl@0: ColumnReal14=1,7.0710678 sl@0: ColumnTextL15=2,Here's yet more text sl@0: Next16=KSqlAtRow sl@0: ColumnInt17=0,1011010 sl@0: ColumnReal18=1,182282.397 sl@0: ColumnTextL19=2,I want chocolate. Now. sl@0: Next20=KSqlAtRow sl@0: ColumnInt21=0,7070707 sl@0: ColumnReal22=1,-1.60217733e-19 sl@0: ColumnTextL23=2,Now I want ice-cream. sl@0: Next24=KSqlAtEnd sl@0: St_Close25= sl@0: Close26= sl@0: SignalB27=1 sl@0: EndBlock28= sl@0: sl@0: [CheckFollowingRollback] sl@0: Open0=C:\Transaction0.db sl@0: NoOperation1= sl@0: NoOperation2= sl@0: Prepare3=Select * from Curtab; sl@0: ColumnIndex4=f1 sl@0: ColumnIndex5=f2 sl@0: ColumnIndex6=f3 sl@0: Next7=KSqlAtRow sl@0: ColumnInt8=0,-4853 sl@0: ColumnReal9=1,6.0827626 sl@0: ColumnTextL10=2,Here's some text sl@0: Next11=KSqlAtEnd sl@0: St_Close12= sl@0: Close13= sl@0: Delete14=C:\Transaction0.db sl@0: EndBlock15= sl@0: sl@0: sl@0: // Create some cells with text in. Copy these with streams - passing sl@0: // an RSqlColumnReadStream to an RSqlParamWriteStream. sl@0: [CopyCellsWithStreams] sl@0: Delete0=C:\CopyCells.db sl@0: ExpectedError0=KErrNotFound sl@0: Create1=C:\CopyCells.db sl@0: Exec2=Create table Table1(field1 text(50)); sl@0: Exec3=Create table Table2(field1 text(50)); sl@0: sl@0: Exec4=Insert Into Table1(field1) values("We're going to copy this string"); sl@0: Exec5=Insert Into Table1(field1) values("And this one"); sl@0: Exec6=Insert Into Table1(field1) values("In fact, all of them. There's a loop"); sl@0: sl@0: // This is used to select the field we want to copy. sl@0: Prepare7=select field1 from Table1; sl@0: NoOperation8= sl@0: sl@0: // This will copy the first cell into a new one (using a separate sl@0: // RSqlStatement object). The two lines below define values for the separate sl@0: // RSqlStatement to use. sl@0: Function9=CopyCellsUsingStreams sl@0: PrepareStatement=Insert into Table2(field1) values(:mob); sl@0: ParamName=:mob sl@0: sl@0: // Close Prepare6 and read back the content of Table2 to see if the cell sl@0: // copied correctly. sl@0: St_Close10= sl@0: Prepare11=select field1 from Table2; sl@0: Next12=KSqlAtRow sl@0: ColumnIndex13=field1 sl@0: ColumnTextL14=0,We're going to copy this string sl@0: Next15=KSqlAtRow sl@0: ColumnTextL16=0,And this one sl@0: Next17=KSqlAtRow sl@0: ColumnTextL18=0,In fact, all of them. There's a loop sl@0: Next19=KSqlAtEnd sl@0: sl@0: // Shut down our RSqlStatement and RSqlDatabase resources. sl@0: St_Close20= sl@0: Close21= sl@0: Delete22=C:\CopyCells.db sl@0: EndBlock23= sl@0: sl@0: // A separate test, here we bind the content of one file (to an integer sl@0: // field actually, but SQLite doesn't care about that), then we bind the sl@0: // content of another before performing the exec/reset. So which data sl@0: // ends up in the cell? The data from the second bind. sl@0: [DoubleBind] sl@0: Delete0=C:\GenerateErrors2.db sl@0: ExpectedError0=KErrNotFound sl@0: Create1=C:\GenerateErrors2.db sl@0: Exec2=Create Table Table1(Field1 int); sl@0: Prepare3=Insert into Table1(Field1) Values (:Mickey); sl@0: ParameterIndex4=:Mickey sl@0: StreamWriteBindText5=0,Z:\TEF_SQL\TestData\reference1.bin sl@0: StreamWriteBindText6=0,Z:\TEF_SQL\TestData\reference1.txt sl@0: St_Exec7= sl@0: Reset8= sl@0: St_Close9= sl@0: Prepare10=select * from Table1; sl@0: ColumnIndex11=Field1 sl@0: Next12=KSqlAtRow sl@0: ColumnTextL13=0,Z:\TEF_SQL\TestData\reference1.txt sl@0: St_Close14= sl@0: Close15= sl@0: Delete16=C:\GenerateErrors2.db sl@0: EndBlock17=- sl@0: sl@0: sl@0: // Test the 'leaving' version of Create, Prepare and Open, also see what sl@0: // happens if you try creating a database on ROM.. sl@0: [LeaveMethods] sl@0: Delete0=C:\Leave1.db sl@0: ExpectedError0=KErrNotFound sl@0: OpenL1=C:\Leave1.db sl@0: ExpectedError1=KErrNotFound sl@0: CreateL2=C:\Leave1.db sl@0: Exec3=Create table Leavetable(f1 text(50), f2 int, f3 real); sl@0: PrepareL4=Insert into Leavetable values(:wonka, :charlie, :joe); sl@0: ParameterIndex5=:wonka sl@0: ParameterIndex6=:charlie sl@0: ParameterIndex7=:joe sl@0: BindText8=0,Great Glass Elevator sl@0: BindInt9=1,5 sl@0: BindReal10=2,1.23456 sl@0: St_Exec11= sl@0: Reset12= sl@0: BindText13=0,Chocolate Factory sl@0: BindInt14=1,54 sl@0: BindReal15=2,9.87654 sl@0: St_Exec16= sl@0: Reset17= sl@0: St_Close18= sl@0: PrepareL19=select * from Leavetable; sl@0: NoOperation20= sl@0: Next21=KSqlAtRow sl@0: ColumnIndex22=f1 sl@0: ColumnIndex23=f2 sl@0: ColumnIndex24=f3 sl@0: ColumnTextL25=0,Great Glass Elevator sl@0: ColumnInt26=1,5 sl@0: ColumnReal27=2,1.23456 sl@0: Next28=KSqlAtRow sl@0: ColumnTextL29=0,Chocolate Factory sl@0: ColumnInt30=1,54 sl@0: ColumnReal31=2,9.87654 sl@0: Next32=KSqlAtEnd sl@0: St_Close33= sl@0: sl@0: Close34= sl@0: CreateL35=C:\Leave1.db sl@0: ExpectedError35=KErrAlreadyExists sl@0: Delete36=C:\Leave1.db sl@0: CreateL37=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: ExpectedError37=KErrAlreadyExists sl@0: CreateL38=Z:\TEF_SQL\TestData\DoesntExist.db sl@0: ExpectedError38=KErrAccessDenied sl@0: EndBlock39= sl@0: sl@0: // Create (and implicitly open) a database, then another, then another, etc. sl@0: // This actually isn't supposed to generate errors. sl@0: // This leaks memory, normally the programmer would be expected to close sl@0: // each of the databases before opening another, but we're explicitly sl@0: // checking that successive Opens/Creates give no error. sl@0: [MultipleCreateOpen] sl@0: Delete0=C:\MCO1.db sl@0: ExpectedError0=KErrNotFound sl@0: Delete1=C:\MCO2.db sl@0: ExpectedError1=KErrNotFound sl@0: Delete2=C:\MCO3.db sl@0: ExpectedError2=KErrNotFound sl@0: Delete3=C:\MCO4.db sl@0: ExpectedError3=KErrNotFound sl@0: Delete4=C:\MCO5.db sl@0: ExpectedError4=KErrNotFound sl@0: sl@0: CreateL5=C:\MCO1.db sl@0: Create6=C:\MCO2.db sl@0: OpenL7=Z:\TEF_SQL\TestData\test1.db sl@0: CreateL8=C:\MCO3.db sl@0: Create9=C:\MCO4.db sl@0: CreateL10=C:\MCO5.db sl@0: sl@0: Delete11=C:\MCO1.db sl@0: ExpectedError11=KErrInUse sl@0: Delete12=C:\MCO2.db sl@0: ExpectedError12=KErrInUse sl@0: Delete13=C:\MCO3.db sl@0: ExpectedError13=KErrInUse sl@0: Delete14=C:\MCO4.db sl@0: ExpectedError14=KErrInUse sl@0: Delete15=C:\MCO5.db sl@0: ExpectedError15=KErrInUse sl@0: Close16= sl@0: Delete17=C:\MCO5.db sl@0: sl@0: Open18=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: OpenL19=Z:\TEF_SQL\TestData\test1.db sl@0: Open20=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: NoOperation21=10000000 sl@0: sl@0: EndBlock22= sl@0: sl@0: [ExtraBindTest] sl@0: WaitB0=1 sl@0: SignalA1=1 sl@0: // First set up a table. sl@0: Delete2=C:\ExtraBindTest.db sl@0: ExpectedError2=KErrNotFound sl@0: Create3=C:\ExtraBindTest.db sl@0: Exec4=Create table Sometable(Someint int, Somereal real, Sometext text); sl@0: Prepare5=Insert into Sometable(Someint, Somereal, Sometext) values (:FInt, :FReal, :FText); sl@0: Function6=WriteBigTable sl@0: LowCount=105 sl@0: HighCount=119 sl@0: CountStep=3 sl@0: Multiplier=0.0 sl@0: Text=Here's some rather pointless text sl@0: EventuallyExpectedError=KErrNone sl@0: St_Close7= sl@0: // Now try a non-trivial select. Ok then, fairly trivial, ;-) sl@0: Prepare8=Select * from Sometable where Someint > :Brian; sl@0: ParameterIndex9=:Brian sl@0: BindInt10=0,112 sl@0: Next11=KSqlAtRow sl@0: ColumnIndex12=Someint sl@0: ColumnIndex13=Somereal sl@0: ColumnIndex14=Sometext sl@0: ColumnInt15=0,114 sl@0: ColumnReal16=1,0.0 sl@0: ColumnTextL17=2,Here's some rather pointless text sl@0: Next18=KSqlAtRow sl@0: ColumnInt19=0,117 sl@0: ColumnReal20=1,0.0 sl@0: ColumnTextL21=2,Here's some rather pointless text sl@0: Next22=KSqlAtEnd sl@0: St_Close23= sl@0: Close24= sl@0: Delete25=C:\ExtraBindTest.db sl@0: EndBlock26= sl@0: sl@0: [ExtraBindTest2] sl@0: SignalB0=1 sl@0: WaitA1=1 sl@0: Delete2=C:\ExtraBindTest2.db sl@0: ExpectedError2=KErrNotFound sl@0: Create3=C:\ExtraBindTest2.db sl@0: Exec4=Create table Sometable(Someint int, Somereal real, Sometext text); sl@0: Prepare5=Insert into Sometable(Sometext) values (:FText); sl@0: ParameterIndex6=:FText sl@0: NewBlock7=WriteInts20 sl@0: St_Exec8= sl@0: Reset9= sl@0: NewBlock10=WriteInts21 sl@0: St_Exec11= sl@0: Reset12= sl@0: NewBlock13=WriteInts22 sl@0: St_Exec14= sl@0: Reset15= sl@0: NewBlock16=WriteInts400 sl@0: St_Exec17= sl@0: Reset18= sl@0: St_Close19= sl@0: Prepare20=Select * from Sometable; sl@0: ColumnIndex21=Sometext sl@0: Next22=KSqlAtRow sl@0: ColumnSize23=0,80 sl@0: Next24=KSqlAtRow sl@0: ColumnSize25=0,84 sl@0: Next26=KSqlAtRow sl@0: ColumnSize27=0,88 sl@0: Next28=KSqlAtRow sl@0: ColumnSize29=0,1600 sl@0: Next30=KSqlAtEnd sl@0: // MUST close the Statement or confusion ensues!! sl@0: St_Close31== sl@0: Prepare32=Select Sometext from Sometable where Sometext=:Block sl@0: ParameterIndex33=:Block sl@0: // We're trying to recover one of the blocks. This function does a bind.. sl@0: NewBlock34=WriteInts21 sl@0: Next35=KSqlAtRow sl@0: ColumnIndex36=Sometext sl@0: ColumnSize37=0,84 sl@0: Next38=KSqlAtEnd sl@0: St_Close39= sl@0: Close40= sl@0: Delete41=C:\ExtraBindTest2.db sl@0: EndBlock42= sl@0: sl@0: [WriteInts20] sl@0: Function0=WriteIntsToStream sl@0: Count=20 sl@0: EndBlock1= sl@0: [WriteInts21] sl@0: Function0=WriteIntsToStream sl@0: Count=21 sl@0: EndBlock1= sl@0: [WriteInts22] sl@0: Function0=WriteIntsToStream sl@0: Count=22 sl@0: EndBlock1= sl@0: [WriteInts400] sl@0: Function0=WriteIntsToStream sl@0: Count=400 sl@0: EndBlock1=