sl@0: sl@0: // Called by BasicSQL2-8S.script. sl@0: // Duplicates BasicSQL2.script/APIBasic2.ini but uses 8-bit methods (Prepare sl@0: // and Exec) and asynchronous methods rather than the usual synchronous sl@0: // UTF-16 methods. sl@0: // 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: EightBit1=True sl@0: Async2=True sl@0: Delete3=C:\Transaction0.db sl@0: ExpectedError3=KErrNotFound sl@0: Create4=C:\Transaction0.db sl@0: Exec5=Create Table Curtab(f1 int primary key, f2 real, f3 text); sl@0: Prepare6=Insert into Curtab(f1, f2, f3) values(:mary, :mungo, :midge); sl@0: ParameterIndex7=:mary sl@0: ParameterIndex8=:mungo sl@0: ParameterIndex9=:midge sl@0: BindInt10=0,-4853 sl@0: BindReal11=1,6.0827626 sl@0: BindText12=2,Here's some text sl@0: St_Exec13= sl@0: Reset14= sl@0: St_Close15= sl@0: // At this point one record outside of a transaction is present. sl@0: sl@0: Exec16=Begin Transaction; sl@0: Prepare17=Insert into Curtab(f1, f2, f3) values(:mary, :mungo, :midge); sl@0: ParameterIndex18=:mary sl@0: ParameterIndex19=:mungo sl@0: ParameterIndex20=:midge sl@0: BindInt21=0,9876 sl@0: BindReal22=1,7.0710678 sl@0: BindText23=2,Here's yet more text sl@0: St_Exec24= sl@0: Reset25= sl@0: BindInt26=0,1011010 sl@0: BindReal27=1,182282.397 sl@0: BindText28=2,I want chocolate. Now. sl@0: St_Exec29= sl@0: Reset30= sl@0: BindInt31=0,7070707 sl@0: BindReal32=1,-1.60217733e-19 sl@0: BindText33=2,Now I want ice-cream. sl@0: St_Exec34= sl@0: Reset35= sl@0: St_Close36= 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: SignalA37=2 sl@0: // Wait for two signals to show they've finished.. sl@0: WaitB38=2 sl@0: Exec39=Rollback; sl@0: Close40= sl@0: EndBlock41= sl@0: sl@0: // ESerializable thread. sl@0: [Thread2] sl@0: SignalB0=1 sl@0: EightBit1=True sl@0: Async2=True sl@0: // Wait until the db has been setup. sl@0: WaitA3=1 sl@0: Open4=C:\Transaction0.db sl@0: SetIsolationLevel5=ESerializable sl@0: Prepare6=Select * from Curtab; sl@0: ColumnIndex7=f1 sl@0: ColumnIndex8=f2 sl@0: ColumnIndex9=f3 sl@0: Next10= sl@0: ExpectedError10=KSqlErrLocked sl@0: St_Close11= sl@0: Close12= sl@0: SignalB13=1 sl@0: EndBlock14= sl@0: sl@0: [Thread3] sl@0: SignalB0=1 sl@0: EightBit1=True sl@0: Async2=True sl@0: // Wait until the db has been setup. sl@0: WaitA3=1 sl@0: Open4=C:\Transaction0.db sl@0: SetIsolationLevel5=EReadUncommitted sl@0: Prepare6=Select * from Curtab; sl@0: ColumnIndex7=f1 sl@0: ColumnIndex8=f2 sl@0: ColumnIndex9=f3 sl@0: Next10=KSqlAtRow sl@0: ColumnInt11=0,-4853 sl@0: ColumnReal12=1,6.0827626 sl@0: ColumnTextL13=2,Here's some text sl@0: Next14=KSqlAtRow sl@0: ColumnInt15=0,9876 sl@0: ColumnReal16=1,7.0710678 sl@0: ColumnTextL17=2,Here's yet more text sl@0: Next18=KSqlAtRow sl@0: ColumnInt19=0,1011010 sl@0: ColumnReal20=1,182282.397 sl@0: ColumnTextL21=2,I want chocolate. Now. sl@0: Next22=KSqlAtRow sl@0: ColumnInt23=0,7070707 sl@0: ColumnReal24=1,-1.60217733e-19 sl@0: ColumnTextL25=2,Now I want ice-cream. sl@0: Next26=KSqlAtEnd sl@0: St_Close27= sl@0: Close28= sl@0: SignalB29=1 sl@0: EndBlock30= sl@0: sl@0: [CheckFollowingRollback] sl@0: EightBit0=True sl@0: Async1=True sl@0: Open2=C:\Transaction0.db 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: EightBit0=True sl@0: Async1=True sl@0: Delete2=C:\CopyCells.db sl@0: ExpectedError2=KErrNotFound sl@0: Create3=C:\CopyCells.db sl@0: Exec4=Create table Table1(field1 text(50)); sl@0: Exec5=Create table Table2(field1 text(50)); sl@0: sl@0: Exec6=Insert Into Table1(field1) values("We're going to copy this string"); sl@0: Exec7=Insert Into Table1(field1) values("And this one"); sl@0: Exec8=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: Prepare9=select field1 from Table1; 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: Function10=CopyCellsUsingStreams sl@0: PrepareStatement=Insert into Table2(field1) values(:mob); sl@0: ParamName=:mob sl@0: sl@0: // Close PrepareX and read back the content of Table2 to see if the cell sl@0: // copied correctly. sl@0: St_Close11= sl@0: Prepare12=select field1 from Table2; sl@0: Next13=KSqlAtRow sl@0: ColumnIndex14=field1 sl@0: ColumnTextL15=0,We're going to copy this string sl@0: Next16=KSqlAtRow sl@0: ColumnTextL17=0,And this one sl@0: Next18=KSqlAtRow sl@0: ColumnTextL19=0,In fact, all of them. There's a loop sl@0: Next20=KSqlAtEnd sl@0: sl@0: // Shut down our RSqlStatement and RSqlDatabase resources. sl@0: St_Close21= sl@0: Close22= sl@0: Delete23=C:\CopyCells.db sl@0: EndBlock24= 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: EightBit0=True sl@0: Async1=True sl@0: Delete2=C:\GenerateErrors2.db sl@0: ExpectedError2=KErrNotFound sl@0: Create3=C:\GenerateErrors2.db sl@0: Exec4=Create Table Table1(Field1 int); sl@0: Prepare5=Insert into Table1(Field1) Values (:Mickey); sl@0: ParameterIndex6=:Mickey sl@0: StreamWriteBindText7=0,Z:\TEF_SQL\TestData\reference1.bin sl@0: StreamWriteBindText8=0,Z:\TEF_SQL\TestData\reference1.txt sl@0: St_Exec9= sl@0: Reset10= sl@0: St_Close11= sl@0: Prepare12=select * from Table1; sl@0: ColumnIndex13=Field1 sl@0: Next14=KSqlAtRow sl@0: ColumnTextL15=0,Z:\TEF_SQL\TestData\reference1.txt sl@0: St_Close16= sl@0: Close17= sl@0: Delete18=C:\GenerateErrors2.db sl@0: EndBlock19= 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: EightBit0=True sl@0: Async1=True sl@0: Delete2=C:\Leave1.db sl@0: ExpectedError2=KErrNotFound sl@0: OpenL3=C:\Leave1.db sl@0: ExpectedError3=KErrNotFound sl@0: CreateL4=C:\Leave1.db sl@0: Exec5=Create table Leavetable(f1 text(50), f2 int, f3 real); sl@0: PrepareL6=Insert into Leavetable values(:wonka, :charlie, :joe); sl@0: ParameterIndex7=:wonka sl@0: ParameterIndex8=:charlie sl@0: ParameterIndex9=:joe sl@0: BindText10=0,Great Glass Elevator sl@0: BindInt11=1,5 sl@0: BindReal12=2,1.23456 sl@0: St_Exec13= sl@0: Reset14= sl@0: BindText15=0,Chocolate Factory sl@0: BindInt16=1,54 sl@0: BindReal17=2,9.87654 sl@0: St_Exec18= sl@0: Reset19= sl@0: St_Close20= sl@0: PrepareL21=select * from Leavetable; sl@0: Next22=KSqlAtRow sl@0: ColumnIndex23=f1 sl@0: ColumnIndex24=f2 sl@0: ColumnIndex25=f3 sl@0: ColumnTextL26=0,Great Glass Elevator sl@0: ColumnInt27=1,5 sl@0: ColumnReal28=2,1.23456 sl@0: Next29=KSqlAtRow sl@0: ColumnTextL30=0,Chocolate Factory sl@0: ColumnInt31=1,54 sl@0: ColumnReal32=2,9.87654 sl@0: Next33=KSqlAtEnd sl@0: St_Close34= sl@0: sl@0: Close35= sl@0: CreateL36=C:\Leave1.db sl@0: ExpectedError36=KErrAlreadyExists sl@0: Delete37=C:\Leave1.db sl@0: CreateL38=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: ExpectedError38=KErrAlreadyExists sl@0: CreateL39=Z:\TEF_SQL\TestData\DoesntExist.db sl@0: ExpectedError39=KErrAccessDenied sl@0: EndBlock40= 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: EightBit0=True sl@0: Async1=True sl@0: Delete2=C:\MCO1.db sl@0: ExpectedError2=KErrNotFound sl@0: Delete3=C:\MCO2.db sl@0: ExpectedError3=KErrNotFound sl@0: Delete4=C:\MCO3.db sl@0: ExpectedError4=KErrNotFound sl@0: Delete5=C:\MCO4.db sl@0: ExpectedError5=KErrNotFound sl@0: Delete6=C:\MCO5.db sl@0: ExpectedError6=KErrNotFound sl@0: sl@0: CreateL7=C:\MCO1.db sl@0: Create8=C:\MCO2.db sl@0: OpenL9=Z:\TEF_SQL\TestData\test1.db sl@0: CreateL10=C:\MCO3.db sl@0: Create11=C:\MCO4.db sl@0: CreateL12=C:\MCO5.db sl@0: sl@0: Delete13=C:\MCO1.db sl@0: ExpectedError13=KErrInUse sl@0: Delete14=C:\MCO2.db sl@0: ExpectedError14=KErrInUse sl@0: Delete15=C:\MCO3.db sl@0: ExpectedError15=KErrInUse sl@0: Delete16=C:\MCO4.db sl@0: ExpectedError16=KErrInUse sl@0: Delete17=C:\MCO5.db sl@0: ExpectedError17=KErrInUse sl@0: Close18= sl@0: Delete19=C:\MCO5.db sl@0: sl@0: Open20=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: OpenL21=Z:\TEF_SQL\TestData\test1.db sl@0: Open22=Z:\TEF_SQL\TestData\ReadOnly.db sl@0: sl@0: EndBlock23= sl@0: sl@0: [ExtraBindTest] sl@0: EightBit0=True sl@0: Async1=True 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: EightBit0=True sl@0: Async1=True 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= sl@0: