System.Data.SQLite
Check-in [676a8c8e5d]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add two tests that use three nested transactions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-1f7bfff467
Files: files | file ages | folders
SHA1:676a8c8e5db19fd4f0849017ecc520e213e9377d
User & Date: mistachkin 2016-11-01 21:21:18
Context
2016-11-04
00:21
Merge updates from trunk. check-in: d2fb66aefb user: mistachkin tags: tkt-1f7bfff467
2016-11-01
21:21
Add two tests that use three nested transactions. check-in: 676a8c8e5d user: mistachkin tags: tkt-1f7bfff467
2016-10-31
14:17
Stop using the transaction nesting level to build SAVEPOINT names. check-in: 6660801c43 user: mistachkin tags: tkt-1f7bfff467
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Tests/tkt-1f7bfff467.eagle.

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
229
230
231
232
233
234
235
236
237
238




































































































































































































239
240
              "Data Source=${dataSource};[getFlagsProperty]"))
          {
            connection.Open();

            using (SQLiteTransaction transaction1 =
                connection.BeginTransaction())
            {
              using (SQLiteCommand command1 = new SQLiteCommand("${sql(1)}",
                  connection))
              {
                command1.Transaction = transaction1;
                command1.ExecuteNonQuery();
              }

              using (SQLiteTransaction transaction2 =
                  connection.BeginTransaction())
              {
                using (SQLiteCommand command2 = new SQLiteCommand("${sql(2)}",
                    connection))
                {
                  command2.Transaction = transaction2;
                  command2.ExecuteNonQuery();

                  transaction1.Commit();
                }
              }
................................................................................
              "Data Source=${dataSource};[getFlagsProperty]"))
          {
            connection.Open();

            using (SQLiteTransaction transaction1 =
                connection.BeginTransaction())
            {
              using (SQLiteCommand command1 = new SQLiteCommand("${sql(1)}",
                  connection))
              {
                command1.Transaction = transaction1;
                command1.ExecuteNonQuery();
              }

              using (SQLiteTransaction transaction2 =
                  connection.BeginTransaction())
              {
                using (SQLiteCommand command2 = new SQLiteCommand("${sql(2)}",
                    connection))
                {
                  command2.Transaction = transaction2;
                  command2.ExecuteNonQuery();

                  transaction1.Rollback();
                }
              }
................................................................................
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result results errors code sql dataSource id db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} 1$}}

###############################################################################





































































































































































































runSQLiteTestEpilogue
runTestEpilogue







|
|








|
|







 







|
|








|
|







 










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
              "Data Source=${dataSource};[getFlagsProperty]"))
          {
            connection.Open();

            using (SQLiteTransaction transaction1 =
                connection.BeginTransaction())
            {
              using (SQLiteCommand command1 = new SQLiteCommand(
                  "${sql(1)}", connection))
              {
                command1.Transaction = transaction1;
                command1.ExecuteNonQuery();
              }

              using (SQLiteTransaction transaction2 =
                  connection.BeginTransaction())
              {
                using (SQLiteCommand command2 = new SQLiteCommand(
                    "${sql(2)}", connection))
                {
                  command2.Transaction = transaction2;
                  command2.ExecuteNonQuery();

                  transaction1.Commit();
                }
              }
................................................................................
              "Data Source=${dataSource};[getFlagsProperty]"))
          {
            connection.Open();

            using (SQLiteTransaction transaction1 =
                connection.BeginTransaction())
            {
              using (SQLiteCommand command1 = new SQLiteCommand(
                  "${sql(1)}", connection))
              {
                command1.Transaction = transaction1;
                command1.ExecuteNonQuery();
              }

              using (SQLiteTransaction transaction2 =
                  connection.BeginTransaction())
              {
                using (SQLiteCommand command2 = new SQLiteCommand(
                    "${sql(2)}", connection))
                {
                  command2.Transaction = transaction2;
                  command2.ExecuteNonQuery();

                  transaction1.Rollback();
                }
              }
................................................................................
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result results errors code sql dataSource id db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} 1$}}

###############################################################################

runTest {test tkt-1f7bfff467-1.4 {commit middle transaction} -setup {
  setupDb [set fileName tkt-1f7bfff467-1.4.db]
} -body {
  sql execute $db {
    CREATE TABLE t1(x);
    INSERT INTO t1(x) VALUES(1);
  }

  set sql(1) { \
    INSERT INTO t1(x) VALUES(2); \
  }

  set sql(2) { \
    INSERT INTO t1(x) VALUES(3); \
  }

  set sql(3) { \
    INSERT INTO t1(x) VALUES(4); \
  }

  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getDatabaseDirectory] $fileName]

  unset -nocomplain results errors

  set code [compileCSharpWith [subst {
    using System.Data.SQLite;

    namespace _Dynamic${id}
    {
      public static class Test${id}
      {
        public static void Main()
        {
          using (SQLiteConnection connection = new SQLiteConnection(
              "Data Source=${dataSource};[getFlagsProperty]"))
          {
            connection.Open();

            using (SQLiteTransaction transaction1 =
                connection.BeginTransaction())
            {
              using (SQLiteCommand command1 = new SQLiteCommand(
                  "${sql(1)}", connection))
              {
                command1.Transaction = transaction1;
                command1.ExecuteNonQuery();
              }

              using (SQLiteTransaction transaction2 =
                  connection.BeginTransaction())
              {
                using (SQLiteCommand command2 = new SQLiteCommand(
                    "${sql(2)}", connection))
                {
                  command2.Transaction = transaction2;
                  command2.ExecuteNonQuery();
                }

                using (SQLiteTransaction transaction3 =
                    connection.BeginTransaction())
                {
                  using (SQLiteCommand command3 = new SQLiteCommand(
                      "${sql(3)}", connection))
                  {
                    command3.Transaction = transaction3;
                    command3.ExecuteNonQuery();

                    transaction2.Commit();
                  }
                }
              }

              transaction1.Commit();
            }
          }
        }
      }
    }
  }] 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 \
      [sql execute -execute reader -format list $db \
          "SELECT x FROM t1 ORDER BY x;"]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result results errors code sql dataSource id db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} \{1 2 3 4\}$}}

###############################################################################

runTest {test tkt-1f7bfff467-1.5 {rollback middle transaction} -setup {
  setupDb [set fileName tkt-1f7bfff467-1.5.db]
} -body {
  sql execute $db {
    CREATE TABLE t1(x);
    INSERT INTO t1(x) VALUES(1);
  }

  set sql(1) { \
    INSERT INTO t1(x) VALUES(2); \
  }

  set sql(2) { \
    INSERT INTO t1(x) VALUES(3); \
  }

  set sql(3) { \
    INSERT INTO t1(x) VALUES(4); \
  }

  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getDatabaseDirectory] $fileName]

  unset -nocomplain results errors

  set code [compileCSharpWith [subst {
    using System.Data.SQLite;

    namespace _Dynamic${id}
    {
      public static class Test${id}
      {
        public static void Main()
        {
          using (SQLiteConnection connection = new SQLiteConnection(
              "Data Source=${dataSource};[getFlagsProperty]"))
          {
            connection.Open();

            using (SQLiteTransaction transaction1 =
                connection.BeginTransaction())
            {
              using (SQLiteCommand command1 = new SQLiteCommand(
                  "${sql(1)}", connection))
              {
                command1.Transaction = transaction1;
                command1.ExecuteNonQuery();
              }

              using (SQLiteTransaction transaction2 =
                  connection.BeginTransaction())
              {
                using (SQLiteCommand command2 = new SQLiteCommand(
                    "${sql(2)}", connection))
                {
                  command2.Transaction = transaction2;
                  command2.ExecuteNonQuery();
                }

                using (SQLiteTransaction transaction3 =
                    connection.BeginTransaction())
                {
                  using (SQLiteCommand command3 = new SQLiteCommand(
                      "${sql(3)}", connection))
                  {
                    command3.Transaction = transaction3;
                    command3.ExecuteNonQuery();

                    transaction2.Rollback();
                  }
                }
              }

              transaction1.Commit();
            }
          }
        }
      }
    }
  }] 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 \
      [sql execute -execute reader -format list $db \
          "SELECT x FROM t1 ORDER BY x;"]
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result results errors code sql dataSource id db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\} \{1 2\}$}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue