Index: Tests/tkt-56b42d99c1.eagle ================================================================== --- Tests/tkt-56b42d99c1.eagle +++ Tests/tkt-56b42d99c1.eagle @@ -110,36 +110,288 @@ } -body { set id [object invoke Interpreter.GetActive NextId] set dataSource [file join [getDatabaseDirectory] $fileName] unset -nocomplain results errors + + set sql(1) { \ + CREATE TABLE t1(x); \ + INSERT INTO t1 (x) VALUES(1); \ + } + + set sql(2) { \ + SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \ + } + + set code [compileCSharpWith [subst { + using System.Data.SQLite; + using System.Transactions; + + namespace _Dynamic${id} + { + public static class Test${id} + { + public static int Main() + { + TransactionOptions transactionOptions = new TransactionOptions(); + transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted; + + using (TransactionScope transactionScope = new TransactionScope( + TransactionScopeOption.Required, transactionOptions)) + { + using (SQLiteConnection connection1 = new SQLiteConnection( + "Data Source=${dataSource};[getFlagsProperty]")) + { + connection1.Open(); + + using (SQLiteConnection connection2 = new SQLiteConnection( + "Data Source=${dataSource};[getFlagsProperty]")) + { + connection2.Open(); + + using (SQLiteCommand command1 = connection1.CreateCommand()) + { + command1.CommandText = "${sql(1)}"; + command1.ExecuteNonQuery(); + + using (SQLiteCommand command2 = connection2.CreateCommand()) + { + command2.CommandText = "${sql(2)}"; + return (int)(long)command2.ExecuteScalar(); + } + } + } + } + } + } + } + } + }] true true true results errors System.Data.SQLite.dll] + + list $code $results \ + [expr {[info exists errors] ? $errors : ""}] \ + [expr {$code eq "Ok" ? [catch { + object invoke _Dynamic${id}.Test${id} Main + } result] : [set result ""]}] $result +} -cleanup { + cleanupDb $fileName + + unset -nocomplain result results errors code dataSource id db fileName +} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ +System.Data.SQLite compileCSharp} -match regexp -result {^Ok\ +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 0$}} + +############################################################################### + +runTest {test tkt-56b42d99c1-1.3 {enlisted transaction isolation} -setup { + setupDb [set fileName tkt-56b42d99c1-1.3.db] +} -body { + set id [object invoke Interpreter.GetActive NextId] + set dataSource [file join [getDatabaseDirectory] $fileName] + + unset -nocomplain results errors + + set sql(1) { \ + CREATE TABLE t1(x); \ + INSERT INTO t1 (x) VALUES(1); \ + } + + set sql(2) { \ + SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \ + } + + set code [compileCSharpWith [subst { + using System.Data.SQLite; + using System.Transactions; + + namespace _Dynamic${id} + { + public static class Test${id} + { + public static int Main() + { + TransactionOptions transactionOptions = new TransactionOptions(); + transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted; + + using (TransactionScope transactionScope = new TransactionScope( + TransactionScopeOption.Required, transactionOptions)) + { + using (SQLiteConnection connection1 = new SQLiteConnection( + "Data Source=${dataSource};Enlist=False;[getFlagsProperty]")) + { + connection1.Open(); + + using (SQLiteConnection connection2 = new SQLiteConnection( + "Data Source=${dataSource};Enlist=False;[getFlagsProperty]")) + { + connection2.Open(); + + using (SQLiteCommand command1 = connection1.CreateCommand()) + { + command1.CommandText = "${sql(1)}"; + command1.ExecuteNonQuery(); + + using (SQLiteCommand command2 = connection2.CreateCommand()) + { + command2.CommandText = "${sql(2)}"; + return (int)(long)command2.ExecuteScalar(); + } + } + } + } + } + } + } + } + }] true true true results errors System.Data.SQLite.dll] + + list $code $results \ + [expr {[info exists errors] ? $errors : ""}] \ + [expr {$code eq "Ok" ? [catch { + object invoke _Dynamic${id}.Test${id} Main + } result] : [set result ""]}] $result +} -cleanup { + cleanupDb $fileName + + unset -nocomplain result results errors code dataSource id db fileName +} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ +System.Data.SQLite compileCSharp} -match regexp -result {^Ok\ +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 1$}} + +############################################################################### + +runTest {test tkt-56b42d99c1-1.4 {enlisted transaction isolation} -setup { + setupDb [set fileName tkt-56b42d99c1-1.4.db] +} -body { + set id [object invoke Interpreter.GetActive NextId] + set dataSource [file join [getDatabaseDirectory] $fileName] + + unset -nocomplain results errors + + set sql(1) { \ + CREATE TABLE t1(x); \ + INSERT INTO t1 (x) VALUES(1); \ + } + + set sql(2) { \ + SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \ + } + + set code [compileCSharpWith [subst { + using System.Data.SQLite; + using System.Transactions; + + namespace _Dynamic${id} + { + public static class Test${id} + { + public static int Main() + { + TransactionOptions transactionOptions = new TransactionOptions(); + transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted; + + using (TransactionScope transactionScope = new TransactionScope( + TransactionScopeOption.Required, transactionOptions)) + { + using (SQLiteConnection connection1 = new SQLiteConnection( + "Data Source=${dataSource};[getFlagsProperty]")) + { + connection1.Open(); + + using (SQLiteConnection connection2 = new SQLiteConnection( + "Data Source=${dataSource};Enlist=False;[getFlagsProperty]")) + { + connection2.Open(); + + using (SQLiteCommand command1 = connection1.CreateCommand()) + { + command1.CommandText = "${sql(1)}"; + command1.ExecuteNonQuery(); + + using (SQLiteCommand command2 = connection2.CreateCommand()) + { + command2.CommandText = "${sql(2)}"; + return (int)(long)command2.ExecuteScalar(); + } + } + } + } + } + } + } + } + }] true true true results errors System.Data.SQLite.dll] + + list $code $results \ + [expr {[info exists errors] ? $errors : ""}] \ + [expr {$code eq "Ok" ? [catch { + object invoke _Dynamic${id}.Test${id} Main + } result] : [set result ""]}] $result +} -cleanup { + cleanupDb $fileName + + unset -nocomplain result results errors code dataSource id db fileName +} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ +System.Data.SQLite compileCSharp} -match regexp -result {^Ok\ +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 0$}} + +############################################################################### + +runTest {test tkt-56b42d99c1-1.5 {enlisted transaction isolation} -setup { + setupDb [set fileName tkt-56b42d99c1-1.5.db] +} -body { + set id [object invoke Interpreter.GetActive NextId] + set dataSource [file join [getDatabaseDirectory] $fileName] + + unset -nocomplain results errors + + set sql(1) { \ + CREATE TABLE t1(x); \ + INSERT INTO t1 (x) VALUES(1); \ + } + + set sql(2) { \ + SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \ + } set code [compileCSharpWith [subst { using System.Data.SQLite; using System.Transactions; namespace _Dynamic${id} { public static class Test${id} { - public static void Main() + public static int Main() { TransactionOptions transactionOptions = new TransactionOptions(); transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope transactionScope = new TransactionScope( TransactionScopeOption.Required, transactionOptions)) { using (SQLiteConnection connection1 = new SQLiteConnection( - "Data Source=${dataSource};Enlist=True;[getFlagsProperty]")) + "Data Source=${dataSource};Enlist=False;[getFlagsProperty]")) { connection1.Open(); using (SQLiteConnection connection2 = new SQLiteConnection( - "Data Source=${dataSource};Enlist=True;[getFlagsProperty]")) + "Data Source=${dataSource};[getFlagsProperty]")) { connection2.Open(); + + using (SQLiteCommand command1 = connection1.CreateCommand()) + { + command1.CommandText = "${sql(1)}"; + command1.ExecuteNonQuery(); + + using (SQLiteCommand command2 = connection2.CreateCommand()) + { + command2.CommandText = "${sql(2)}"; + return (int)(long)command2.ExecuteScalar(); + } + } } } } } } @@ -155,11 +407,11 @@ cleanupDb $fileName unset -nocomplain result results errors code dataSource id db fileName } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite compileCSharp} -match regexp -result {^Ok\ -System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}} +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 1$}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue