
// Called by BasicSQL2.script.
// Tests that  a transaction which is not completed   is visible to a EReadUncommitted
// session and simultaneously (so a bit of concurrency), not visible
// to a EReadSerializable session.

// Set up a new database.
[Thread1]
WaitB0=2
Delete1=C:\Transaction0.db
ExpectedError1=KErrNotFound
Create2=C:\Transaction0.db
Exec3=Create Table Curtab(f1 int primary key, f2 real, f3 text);
Prepare4=Insert into Curtab(f1, f2, f3) values(:mary, :mungo, :midge);
ParameterIndex5=:mary
ParameterIndex6=:mungo
ParameterIndex7=:midge
BindInt8=0,-4853
BindReal9=1,6.0827626
BindText10=2,Here's some text
St_Exec11=
Reset12=
St_Close13=
// At this point one record outside of a transaction is present.

NoOperation14=
Exec15=Begin Transaction;
Prepare16=Insert into Curtab(f1, f2, f3) values(:mary, :mungo, :midge);
ParameterIndex17=:mary
ParameterIndex18=:mungo
ParameterIndex19=:midge
BindInt20=0,9876
BindReal21=1,7.0710678
BindText22=2,Here's yet more text
St_Exec23=
Reset24=
BindInt25=0,1011010
BindReal26=1,182282.397
BindText27=2,I want chocolate. Now.
St_Exec28=
Reset29=
BindInt30=0,7070707
BindReal31=1,-1.60217733e-19
BindText32=2,Now I want ice-cream.
St_Exec33=
Reset34=
St_Close35=
// At this point we've added one row outside of the transaction and 3 more
// within it. Send a signal to the slave threads which will check for the
// above content (one is ESerializable, one is EReadUncommitted, so they'll
// see different content).
// Wake up 2 threads..
SignalA36=2
// Wait for two signals to show they've finished..
WaitB37=2
Exec38=Rollback;
Close39=
EndBlock40=

// ESerializable thread.
[Thread2]
SignalB0=1
// Wait until the db has been setup.
WaitA1=1
Open2=C:\Transaction0.db
SetIsolationLevel3=ESerializable
Prepare4=Select * from Curtab;
ColumnIndex5=f1
ColumnIndex6=f2
ColumnIndex7=f3
Next8=
ExpectedError8=KSqlErrLocked
St_Close9=
Close10=
SignalB11=1
EndBlock12=

[Thread3]
SignalB0=1
// Wait until the db has been setup.
WaitA1=1
Open2=C:\Transaction0.db
SetIsolationLevel3=EReadUncommitted
Prepare4=Select * from Curtab;
ColumnIndex5=f1
ColumnIndex6=f2
ColumnIndex7=f3
Next8=KSqlAtRow
ColumnInt9=0,-4853
ColumnReal10=1,6.0827626
ColumnTextL11=2,Here's some text
Next12=KSqlAtRow
ColumnInt13=0,9876
ColumnReal14=1,7.0710678
ColumnTextL15=2,Here's yet more text
Next16=KSqlAtRow
ColumnInt17=0,1011010
ColumnReal18=1,182282.397
ColumnTextL19=2,I want chocolate. Now.
Next20=KSqlAtRow
ColumnInt21=0,7070707
ColumnReal22=1,-1.60217733e-19
ColumnTextL23=2,Now I want ice-cream.
Next24=KSqlAtEnd
St_Close25=
Close26=
SignalB27=1
EndBlock28=

[CheckFollowingRollback]
Open0=C:\Transaction0.db
NoOperation1=
NoOperation2=
Prepare3=Select * from Curtab;
ColumnIndex4=f1
ColumnIndex5=f2
ColumnIndex6=f3
Next7=KSqlAtRow
ColumnInt8=0,-4853
ColumnReal9=1,6.0827626
ColumnTextL10=2,Here's some text
Next11=KSqlAtEnd
St_Close12=
Close13=
Delete14=C:\Transaction0.db
EndBlock15=


// Create some cells with text in. Copy these with streams - passing
// an RSqlColumnReadStream to an RSqlParamWriteStream.
[CopyCellsWithStreams]
Delete0=C:\CopyCells.db
ExpectedError0=KErrNotFound
Create1=C:\CopyCells.db
Exec2=Create table Table1(field1 text(50));
Exec3=Create table Table2(field1 text(50));

Exec4=Insert Into Table1(field1) values("We're going to copy this string");
Exec5=Insert Into Table1(field1) values("And this one");
Exec6=Insert Into Table1(field1) values("In fact, all of them. There's a loop");

// This is used to select the field we want to copy.
Prepare7=select field1 from Table1;
NoOperation8=

// This will copy the first cell into a new one (using a separate
// RSqlStatement object). The two lines below define values for the separate
// RSqlStatement to use.
Function9=CopyCellsUsingStreams
PrepareStatement=Insert into Table2(field1) values(:mob);
ParamName=:mob

// Close Prepare6 and read back the content of Table2 to see if the cell
// copied correctly.
St_Close10=
Prepare11=select field1 from Table2;
Next12=KSqlAtRow
ColumnIndex13=field1
ColumnTextL14=0,We're going to copy this string
Next15=KSqlAtRow
ColumnTextL16=0,And this one
Next17=KSqlAtRow
ColumnTextL18=0,In fact, all of them. There's a loop
Next19=KSqlAtEnd

// Shut down our RSqlStatement and RSqlDatabase resources.
St_Close20=
Close21=
Delete22=C:\CopyCells.db
EndBlock23=

// A separate test, here we bind the content of one file (to an integer
// field actually, but SQLite doesn't care about that), then we bind the
// content of another before performing the exec/reset. So which data
// ends up in the cell? The data from the second bind.
[DoubleBind]
Delete0=C:\GenerateErrors2.db
ExpectedError0=KErrNotFound
Create1=C:\GenerateErrors2.db
Exec2=Create Table Table1(Field1 int);
Prepare3=Insert into Table1(Field1) Values (:Mickey);
ParameterIndex4=:Mickey
StreamWriteBindText5=0,Z:\TEF_SQL\TestData\reference1.bin
StreamWriteBindText6=0,Z:\TEF_SQL\TestData\reference1.txt
St_Exec7=
Reset8=
St_Close9=
Prepare10=select * from Table1;
ColumnIndex11=Field1
Next12=KSqlAtRow
ColumnTextL13=0,Z:\TEF_SQL\TestData\reference1.txt
St_Close14=
Close15=
Delete16=C:\GenerateErrors2.db
EndBlock17=-


// Test the 'leaving' version of Create, Prepare and Open, also see what
// happens if you try creating a database on ROM..
[LeaveMethods]
Delete0=C:\Leave1.db
ExpectedError0=KErrNotFound
OpenL1=C:\Leave1.db
ExpectedError1=KErrNotFound
CreateL2=C:\Leave1.db
Exec3=Create table Leavetable(f1 text(50), f2 int, f3 real);
PrepareL4=Insert into Leavetable values(:wonka, :charlie, :joe);
ParameterIndex5=:wonka
ParameterIndex6=:charlie
ParameterIndex7=:joe
BindText8=0,Great Glass Elevator
BindInt9=1,5
BindReal10=2,1.23456
St_Exec11=
Reset12=
BindText13=0,Chocolate Factory
BindInt14=1,54
BindReal15=2,9.87654
St_Exec16=
Reset17=
St_Close18=
PrepareL19=select * from Leavetable;
NoOperation20=
Next21=KSqlAtRow
ColumnIndex22=f1
ColumnIndex23=f2
ColumnIndex24=f3
ColumnTextL25=0,Great Glass Elevator
ColumnInt26=1,5
ColumnReal27=2,1.23456
Next28=KSqlAtRow
ColumnTextL29=0,Chocolate Factory
ColumnInt30=1,54
ColumnReal31=2,9.87654
Next32=KSqlAtEnd
St_Close33=

Close34=
CreateL35=C:\Leave1.db
ExpectedError35=KErrAlreadyExists
Delete36=C:\Leave1.db
CreateL37=Z:\TEF_SQL\TestData\ReadOnly.db
ExpectedError37=KErrAlreadyExists
CreateL38=Z:\TEF_SQL\TestData\DoesntExist.db
ExpectedError38=KErrAccessDenied
EndBlock39=

// Create (and implicitly open) a database, then another, then another, etc.
// This actually isn't supposed to generate errors.
// This leaks memory, normally the programmer would be expected to close
// each of the databases before opening another, but we're explicitly
// checking that successive Opens/Creates give no error.
[MultipleCreateOpen]
Delete0=C:\MCO1.db
ExpectedError0=KErrNotFound
Delete1=C:\MCO2.db
ExpectedError1=KErrNotFound
Delete2=C:\MCO3.db
ExpectedError2=KErrNotFound
Delete3=C:\MCO4.db
ExpectedError3=KErrNotFound
Delete4=C:\MCO5.db
ExpectedError4=KErrNotFound

CreateL5=C:\MCO1.db
Create6=C:\MCO2.db
OpenL7=Z:\TEF_SQL\TestData\test1.db
CreateL8=C:\MCO3.db
Create9=C:\MCO4.db
CreateL10=C:\MCO5.db

Delete11=C:\MCO1.db
ExpectedError11=KErrInUse
Delete12=C:\MCO2.db
ExpectedError12=KErrInUse
Delete13=C:\MCO3.db
ExpectedError13=KErrInUse
Delete14=C:\MCO4.db
ExpectedError14=KErrInUse
Delete15=C:\MCO5.db
ExpectedError15=KErrInUse
Close16=
Delete17=C:\MCO5.db

Open18=Z:\TEF_SQL\TestData\ReadOnly.db
OpenL19=Z:\TEF_SQL\TestData\test1.db
Open20=Z:\TEF_SQL\TestData\ReadOnly.db
NoOperation21=10000000

EndBlock22=

[ExtraBindTest]
WaitB0=1
SignalA1=1
// First set up a table.
Delete2=C:\ExtraBindTest.db
ExpectedError2=KErrNotFound
Create3=C:\ExtraBindTest.db
Exec4=Create table Sometable(Someint int, Somereal real, Sometext text);
Prepare5=Insert into Sometable(Someint, Somereal, Sometext) values (:FInt, :FReal, :FText);
Function6=WriteBigTable
LowCount=105
HighCount=119
CountStep=3
Multiplier=0.0
Text=Here's some rather pointless text
EventuallyExpectedError=KErrNone
St_Close7=
// Now try a non-trivial select. Ok then, fairly trivial, ;-)
Prepare8=Select * from Sometable where Someint > :Brian;
ParameterIndex9=:Brian
BindInt10=0,112
Next11=KSqlAtRow
ColumnIndex12=Someint
ColumnIndex13=Somereal
ColumnIndex14=Sometext
ColumnInt15=0,114
ColumnReal16=1,0.0
ColumnTextL17=2,Here's some rather pointless text
Next18=KSqlAtRow
ColumnInt19=0,117
ColumnReal20=1,0.0
ColumnTextL21=2,Here's some rather pointless text
Next22=KSqlAtEnd
St_Close23=
Close24=
Delete25=C:\ExtraBindTest.db
EndBlock26=

[ExtraBindTest2]
SignalB0=1
WaitA1=1
Delete2=C:\ExtraBindTest2.db
ExpectedError2=KErrNotFound
Create3=C:\ExtraBindTest2.db
Exec4=Create table Sometable(Someint int, Somereal real, Sometext text);
Prepare5=Insert into Sometable(Sometext) values (:FText);
ParameterIndex6=:FText
NewBlock7=WriteInts20
St_Exec8=
Reset9=
NewBlock10=WriteInts21
St_Exec11=
Reset12=
NewBlock13=WriteInts22
St_Exec14=
Reset15=
NewBlock16=WriteInts400
St_Exec17=
Reset18=
St_Close19=
Prepare20=Select * from Sometable;
ColumnIndex21=Sometext
Next22=KSqlAtRow
ColumnSize23=0,80
Next24=KSqlAtRow
ColumnSize25=0,84
Next26=KSqlAtRow
ColumnSize27=0,88
Next28=KSqlAtRow
ColumnSize29=0,1600
Next30=KSqlAtEnd
// MUST close the Statement or confusion ensues!!
St_Close31==
Prepare32=Select Sometext from Sometable where Sometext=:Block
ParameterIndex33=:Block
// We're trying to recover one of the blocks. This function does a bind..
NewBlock34=WriteInts21
Next35=KSqlAtRow
ColumnIndex36=Sometext
ColumnSize37=0,84
Next38=KSqlAtEnd
St_Close39=
Close40=
Delete41=C:\ExtraBindTest2.db
EndBlock42=

[WriteInts20]
Function0=WriteIntsToStream
Count=20
EndBlock1=
[WriteInts21]
Function0=WriteIntsToStream
Count=21
EndBlock1=
[WriteInts22]
Function0=WriteIntsToStream
Count=22
EndBlock1=
[WriteInts400]
Function0=WriteIntsToStream
Count=400
EndBlock1=
