System.Data.SQLite

Check-in [70c11fc93f]
Login

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

Overview
Comment:Enhance stress test workload diagnostic messages.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | threadAbortProtect
Files: files | file ages | folders
SHA1: 70c11fc93fae40f7ebd086af693a2179e097dfd3
User & Date: mistachkin 2012-10-12 14:09:14.712
Context
2012-10-12
16:09
Add a LogMessage method overload to the SQLiteConnection class that takes a SQLiteErrorCode. check-in: d874518f31 user: mistachkin tags: threadAbortProtect
14:09
Enhance stress test workload diagnostic messages. check-in: 70c11fc93f user: mistachkin tags: threadAbortProtect
13:40
Logging related enhancements to stress test. check-in: 738abc1a0b user: mistachkin tags: threadAbortProtect
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to Tests/stress.eagle.
150
151
152
153
154
155
156
157

158
159
160
161

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

183
184
185
186

187
188
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

233
234
235
236

237
238
239
240
241
242
243
150
151
152
153
154
155
156

157
158
159
160

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181

182
183
184
185

186
187
188
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231

232
233
234
235

236
237
238
239
240
241
242
243







-
+



-
+




















-
+



-
+




















-
+



-
+




















-
+



-
+







    #
    lappend ::times(1) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 2} {$index <= $count} {incr index} {
          sql execute $db [appendArgs \
              "CREATE TABLE IF NOT EXISTS t" $index "(x PRIMARY KEY, y, z);"]
          showTest 1
          showTest A
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest a
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(2) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #2, DROP TABLE statements.
    #
    lappend ::times(2) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 2} {$index <= $count} {incr index} {
          sql execute $db [appendArgs \
              "DROP TABLE IF EXISTS t" $index \;]
          showTest 2
          showTest B
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest b
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(3) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #3, "small" SELECT statements.
    #
    lappend ::times(3) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute -execute reader $db [appendArgs \
              "SELECT x, y FROM " $table " WHERE z = 'small';"]
          showTest 3
          showTest C
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest c
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(4) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #4, "big" SELECT statements.
    #
    lappend ::times(4) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute -execute reader $db [appendArgs \
              "SELECT x, y FROM " $table " WHERE z = 'big';"]
          showTest 4
          showTest D
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest d
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]
253
254
255
256
257
258
259
260

261
262
263
264

265
266
267
268
269
270
271
253
254
255
256
257
258
259

260
261
262
263

264
265
266
267
268
269
270
271







-
+



-
+







      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db [appendArgs \
              "INSERT INTO " $table "(x, y, z) VALUES('" \
              [format %lX [expr {random()}]] "', '" \
              [base64 encode -- [expr {randstr(10000)}]] \
              "', 'small');"]
          showTest 5
          showTest E
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest e
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]
280
281
282
283
284
285
286
287

288
289
290
291

292
293
294
295
296
297
298
280
281
282
283
284
285
286

287
288
289
290

291
292
293
294
295
296
297
298







-
+



-
+







      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db [appendArgs \
              "INSERT INTO " $table "(x, y, z) VALUES('" \
              [format %lX [expr {random()}]] \
              "', RANDOMBLOB(10000000), 'big');"]
          showTest 6
          showTest F
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest f
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]
306
307
308
309
310
311
312
313

314
315
316
317

318
319
320
321
322
323
324
306
307
308
309
310
311
312

313
314
315
316

317
318
319
320
321
322
323
324







-
+



-
+







    lappend ::times(7) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db [appendArgs "UPDATE " $table \
              " SET y = '" [base64 encode -- [expr {randstr(10000)}]] \
              "' WHERE x LIKE '" [format %X $index] "%' AND z = 'small';"]
          showTest 7
          showTest G
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest g
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]
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









437
438
439
440
441
442
443
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

437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452







-
+



-
+




















-
+



-
+




















-
+



-
+



















-
+



-
+


















+
-
+
+
+
+
+
+
+
+
+







    lappend ::times(8) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db [appendArgs "UPDATE " $table \
              " SET y = RANDOMBLOB(10000000) WHERE x LIKE '" \
              [format %X $index] "%' AND z = 'big';"]
          showTest 8
          showTest H
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest h
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(9) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #9, "small" DELETE statements.
    #
    lappend ::times(9) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db [appendArgs "DELETE FROM " $table \
              " WHERE x LIKE '" [format %X $index] "%' AND z = 'small';"]
          showTest 9
          showTest I
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest i
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(10) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #10, "big" DELETE statements.
    #
    lappend ::times(10) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db [appendArgs "DELETE FROM " $table \
              " WHERE x LIKE '" [format %X $index] "%' AND z = 'big';"]
          showTest A
          showTest J
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest j
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(11) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #11, VACUUM statement.
    #
    lappend ::times(11) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          sql execute $db "VACUUM;"
          showTest B
          showTest K
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest k
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(12) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #12, backup to in-memory database.
    #
    lappend ::times(12) [lindex [time {
      for {set index 1} {$index <= $count} {incr index} {
        if {[string is integer -strict $::compiled(12)]} then {
          set id $::compiled(12); # NOTE: Already compiled.
          if {[catch {
          object invoke _Dynamic${id}.Test${id} BackupAndGetData
            object invoke _Dynamic${id}.Test${id} BackupAndGetData
            showTest L
          } error]} then {
            if {[expectedError $error]} then {
              showTest l
            } else {
              failTest $error
            }
          }
        } else {
          set id [object invoke Interpreter.GetActive NextId]
          set code [compileCSharpWith [subst {
            using System;
            using System.Data.SQLite;
            using System.Text;

469
470
471
472
473
474
475

476









477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495

496









497
498
499
500
501
502
503
478
479
480
481
482
483
484
485

486
487
488
489
490
491
492
493
494
495
496
497
498

499
500
501
502
503
504
505
506
507
508
509
510
511
512
513

514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529







+
-
+
+
+
+
+
+
+
+
+




-














+
-
+
+
+
+
+
+
+
+
+







                  // do nothing.
                }
              }
            }
          }] true true true results errors System.Data.SQLite.dll]
          if {$code eq "Ok"} then {
            set ::compiled(12) $id; # NOTE: Compiled OK.
            if {[catch {
            object invoke _Dynamic${id}.Test${id} BackupAndGetData
              object invoke _Dynamic${id}.Test${id} BackupAndGetData
              showTest L
            } error]} then {
              if {[expectedError $error]} then {
                showTest l
              } else {
                failTest $error
              }
            }
          } else {
            error $errors
          }
        }
        showTest C
      }
    }] 0]
  }]

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

  set workload(13) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #13, backup from an in-memory database.
    #
    lappend ::times(13) [lindex [time {
      for {set index 1} {$index <= $count} {incr index} {
        if {[string is integer -strict $::compiled(13)]} then {
          set id $::compiled(13); # NOTE: Already compiled.
          if {[catch {
          object invoke _Dynamic${id}.Test${id} BackupAndGetData
            object invoke _Dynamic${id}.Test${id} BackupAndGetData
            showTest M
          } error]} then {
            if {[expectedError $error]} then {
              showTest m
            } else {
              failTest $error
            }
          }
        } else {
          set id [object invoke Interpreter.GetActive NextId]
          set code [compileCSharpWith [subst {
            using System;
            using System.Data.SQLite;
            using System.Text;

529
530
531
532
533
534
535

536









537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559

560
561
562
563
564
565
566

567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585

586
587
588
589

590
591
592
593
594
595
596
555
556
557
558
559
560
561
562

563
564
565
566
567
568
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592

593
594
595
596
597
598
599

600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618

619
620
621
622

623
624
625
626
627
628
629
630







+
-
+
+
+
+
+
+
+
+
+




-

















-
+






-
+


















-
+



-
+







                  // do nothing.
                }
              }
            }
          }] true true true results errors System.Data.SQLite.dll]
          if {$code eq "Ok"} then {
            set ::compiled(13) $id; # NOTE: Compiled OK.
            if {[catch {
            object invoke _Dynamic${id}.Test${id} BackupAndGetData
              object invoke _Dynamic${id}.Test${id} BackupAndGetData
              showTest M
            } error]} then {
              if {[expectedError $error]} then {
                showTest m
              } else {
                failTest $error
              }
            }
          } else {
            error $errors
          }
        }
        showTest D
      }
    }] 0]
  }]

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

  set workload(14) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #14, PRAGMA integrity check statement.
    #
    lappend ::times(14) [lindex [time {
      setupDb $dstFileName "" "" "" "" "" true false
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          set result [sql execute -execute scalar $db \
              "PRAGMA integrity_check;"]
          if {$result eq "ok"} then {
            showTest E
            showTest N
          } else {
            error [appendArgs "integrity check failed: " $result]
          }
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest n
        } else {
          failTest $error
        }
      }
      cleanupDb $dstFileName db false true false
    }] 0]
  }]

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

  set workload(15) [list [list srcFileName dstFileName table count] {
    #
    # NOTE: Workload #15, force managed garbage collection
    #
    lappend ::times(15) [lindex [time {
      if {[catch {
        for {set index 1} {$index <= $count} {incr index} {
          collectGarbage $::test_channel
          showTest F
          showTest O
        }
      } error]} then {
        if {[expectedError $error]} then {
          showTest *
          showTest o
        } else {
          failTest $error
        }
      }
    }] 0]
  }]
} -body {