System.Data.SQLite
Check-in [a07ba949c9]
Not logged in

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

Overview
Comment:Add draft tests for parameter binding and data reader callbacks. Still needs cleanup.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | customDataTypes
Files: files | file ages | folders
SHA1: a07ba949c911564afbf2aef3cfedef5269679ae0
User & Date: mistachkin 2016-06-20 04:52:22
Context
2016-06-20
20:22
Cleanup and robustify tests. check-in: 27785d64aa user: mistachkin tags: customDataTypes
04:52
Add draft tests for parameter binding and data reader callbacks. Still needs cleanup. check-in: a07ba949c9 user: mistachkin tags: customDataTypes
04:51
When looking up type callbacks, permit the parameter name to be used if the appropriate connection flag is set. check-in: e268cdb240 user: mistachkin tags: customDataTypes
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Setup/data/verify.lst.

846
847
848
849
850
851
852

853
854
855
856
857
858
859
  Tests/tkt-e1b2e0f769.eagle
  Tests/tkt-e30b820248.eagle
  Tests/tkt-e47b3d8346.eagle
  Tests/tkt-ef2216192d.eagle
  Tests/tkt-f2c47a01eb.eagle
  Tests/tkt-f8dbab8baf.eagle
  Tests/tkt-fe50b8c2e8.eagle

  Tests/version.eagle
  Tests/vtab.eagle
  tools/
  tools/install/
  tools/install/Installer.2005.csproj
  tools/install/Installer.2008.csproj
  tools/install/Installer.2010.csproj







>







846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
  Tests/tkt-e1b2e0f769.eagle
  Tests/tkt-e30b820248.eagle
  Tests/tkt-e47b3d8346.eagle
  Tests/tkt-ef2216192d.eagle
  Tests/tkt-f2c47a01eb.eagle
  Tests/tkt-f8dbab8baf.eagle
  Tests/tkt-fe50b8c2e8.eagle
  Tests/types.eagle
  Tests/version.eagle
  Tests/vtab.eagle
  tools/
  tools/install/
  tools/install/Installer.2005.csproj
  tools/install/Installer.2008.csproj
  tools/install/Installer.2010.csproj

Added Tests/types.eagle.













































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
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
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
530
531
532
533
534
###############################################################################
#
# types.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

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

package require System.Data.SQLite.Test
runSQLiteTestPrologue

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

proc bindValueCallback1 {
        convert command flags parameter typeName index userData
        completeVarName } {

  lappend ::log(bind) [list convert [isObjectHandle $convert]]
  lappend ::log(bind) [list command [isObjectHandle $command]]
  lappend ::log(bind) [list flags [getStringFromObjectHandle $flags]]
  lappend ::log(bind) [list parameter [isObjectHandle $parameter]]
  lappend ::log(bind) [list typeName [getStringFromObjectHandle $typeName]]
  lappend ::log(bind) [list index [getStringFromObjectHandle $index]]
  lappend ::log(bind) [list userData [getStringFromObjectHandle $userData]]

  if {[getStringFromObjectHandle $userData] == 3} then {
    error "parameter binding canceled"
  }

  if {[getStringFromObjectHandle $userData] == 2} then {
    $parameter DbType String
    $parameter Value custom
  }

  if {[getStringFromObjectHandle $userData] == 1} then {
    upvar 1 $completeVarName complete
    set complete [object invoke -create System.Boolean Parse True]
  }
}

proc readValueCallback1 {
        convert dataReader flags eventArgs typeName index userData
        completeVarName } {

  lappend ::log(read) [list convert [isObjectHandle $convert]]
  lappend ::log(read) [list dataReader [isObjectHandle $dataReader]]
  lappend ::log(read) [list flags [getStringFromObjectHandle $flags]]
  lappend ::log(read) [list eventArgs [isObjectHandle $eventArgs]]
  lappend ::log(read) [list typeName [getStringFromObjectHandle $typeName]]
  lappend ::log(read) [list index [getStringFromObjectHandle $index]]
  lappend ::log(read) [list userData [getStringFromObjectHandle $userData]]

  if {[getStringFromObjectHandle $userData] == 3} then {
    error "reading of value canceled"
  }

  if {[getStringFromObjectHandle $userData] == 1} then {
    upvar 1 $completeVarName complete
    set complete [object invoke -create System.Boolean Parse True]
  }
}

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

runTest {test types-1.1 {type callbacks management} -setup {
  setupDb [set fileName types-1.1.db]
} -body {
  set connection [getDbConnection]

  set result [list]

  lappend result [$connection ClearTypeCallbacks]

  set typeCallbacks(1) [object invoke \
      System.Data.SQLite.SQLiteTypeCallbacks Create \
      null null null null]

  set typeCallbacks(2) null

  lappend result [$connection SetTypeCallbacks TEST $typeCallbacks(1)]
  lappend result [$connection TryGetTypeCallbacks TEST typeCallbacks(2)]
  lappend result [$connection ClearTypeCallbacks]
  lappend result [$connection SetTypeCallbacks TEST $typeCallbacks(1)]
  lappend result [expr {$typeCallbacks(1) eq $typeCallbacks(2)}]

  set result
} -cleanup {
  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain typeCallbacks
  unset -nocomplain result connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {0 True True 1 True True}}

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

set readArguments [list \
    convert dataReader flags eventArgs typeName index userData \
    completeVarName]

set readMappings [list \
    [list Boolean   GetBoolean   false  BooleanValue   true   0 \
        {False False True False False False False False}] \
    [list Byte      GetByte      false  ByteValue      true   0 \
        {0 0 1 0 0 0 0 0}] \
    [list Byte      GetBytes     true   BytesValue     false  0 \
        {0 1 48 1 49 3 {49 46 50} 5 {116 104 114 101 101} 1 4 27\
        {50 48 49 54 45 48 54 45 49 57 32 49 57 58 53 48 58 48 52\
        46 49 50 51 52 53 54 55} 36 {55 52 102 49 102 52 48 50 45\
        100 100 101 102 45 52 48 50 55 45 97 55 56 102 45 51 56 52\
        55 102 97 57 55 98 56 51 48}}] \
    [list Char      GetChar      false  CharValue      true   0 \
        "<NUL> <NUL> \x01 <NUL> <NUL> <NUL> <NUL> <NUL>"] \
    [list Char      GetChars     true   CharsValue     false  0 \
        "0 1 0 1 1 3 {1 . 2} 1 t 1 \x04 1 2 1 7"] \
    [list DateTime  GetDateTime  false  DateTimeValue  true   0 \
        {{0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
        {0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
        {0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
        {2016-06-19 19:50:04.1234567Z} {0001-01-01 00:00:00Z}}] \
    [list Decimal   GetDecimal   false  DecimalValue   true   0 \
        {0 0 1 1.2 0 0 0 0}] \
    [list Double    GetDouble    false  DoubleValue    true   0 \
        {0 0 1 1.2 0 0 0 0}] \
    [list Single    GetFloat     false  FloatValue     true   0 \
        {0 0 1 1.2 0 0 0 0}] \
    [list Guid      GetGuid      false  GuidValue      true   [guid null] \
        {00000000-0000-0000-0000-000000000000\
        00000000-0000-0000-0000-000000000000\
        00000000-0000-0000-0000-000000000000\
        00000000-0000-0000-0000-000000000000\
        00000000-0000-0000-0000-000000000000\
        00060504-0000-0000-0000-000000000000\
        00000000-0000-0000-0000-000000000000\
        74f1f402-ddef-4027-a78f-3847fa97b830}] \
    [list Int16     GetInt16     false  Int16Value     true   0 \
        {0 0 1 0 0 0 0 0}] \
    [list Int32     GetInt32     false  Int32Value     true   0 \
        {0 0 1 0 0 0 0 0}] \
    [list Int64     GetInt64     false  Int64Value     true   0 \
        {0 0 1 0 0 0 0 0}] \
    [list String    GetString    false  StringValue    false  null \
        "<NUL> <NUL> <NUL> <NUL> three \x04\x05\x06 {2016-06-19 19:50:04.1234567}\
        74f1f402-ddef-4027-a78f-3847fa97b830"] \
    [list Object    GetValue     false  Value          false  null \
        "{} 0 1 1.2 three {4 5 6} {2016-06-19 19:50:04.1234567}\
        74f1f402-ddef-4027-a78f-3847fa97b830"]]

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

set savedDateTimeFormat [object invoke Interpreter.GetActive DateTimeFormat]
if {![isObjectHandle $savedDateTimeFormat]} then {set savedDateTimeFormat null}
object invoke Interpreter.GetActive DateTimeFormat [getDateTimeFormat]

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

for {set i 0} {$i < [llength $readMappings]} {incr i} {
  foreach {
    typeName methodName isArray propertyName
    isRequired value expectedResult
  } [lindex $readMappings $i] break

  proc readValueCallback2 $readArguments [subst {
    if {$isArray} then {
      if {\[catch {
        set keyValue \[\$dataReader GetInt64 0\]

set dataOffset \[\$eventArgs ArrayEventArgs.DataOffset\]
set buffer \[\$eventArgs -create [appendArgs ArrayEventArgs. $typeName Buffer]\]
set bufferOffset \[\$eventArgs ArrayEventArgs.BufferOffset\]
set length \[\$eventArgs ArrayEventArgs.Length\]
set readValue \[\$dataReader \[\$eventArgs MethodName\] \$index \$dataOffset \$buffer \$bufferOffset \$length\]

        \$eventArgs \[appendArgs Value. $propertyName\] \$readValue
      } error\]} then {



          set readValue \[\$dataReader -tostring GetValue \$index\]



        if {"$typeName" eq "Char"} then {
          set string \[object create -alias String \$readValue\]


          set buffer \[\$string -create -alias ToCharArray]


        } else {
          set buffer \[object invoke -create -alias System.Text.Encoding.UTF8 GetBytes \$readValue\]
        }

        \$eventArgs ArrayEventArgs.Length \[\$buffer Length\]

        \$eventArgs \[appendArgs Value. $propertyName\] \$buffer

      } else {

        set buffer \[\$eventArgs -create [appendArgs ArrayEventArgs. $typeName Buffer]\]
        \$eventArgs \[appendArgs Value. $propertyName\] \$buffer



      }
    } else {
      if {\[catch {
        set keyValue \[\$dataReader GetInt64 0\]
        set readValue \[\$dataReader \[\$eventArgs MethodName\] \$index\]

        if {"$typeName" eq "Char"} then {
          set readValue \[object invoke -create Char Parse \$readValue\]
        }

        \$eventArgs \[appendArgs Value. $propertyName\] \$readValue
      } error\]} then {

        \$eventArgs \[appendArgs Value. $propertyName\] {$value}
      }
    }
    upvar 1 \$completeVarName complete
    set complete \[object invoke -create System.Boolean Parse True\]
  }]

  runTest {test [appendArgs types-2. $i] [appendArgs $methodName " callback"] -setup [subst -nocommands {
    set typeName {$typeName}
    set methodName {$methodName}
    set isArray {$isArray}

    setupDb [set fileName [appendArgs types-2. $i .db]] "" "" "" UseConnectionReadValueCallbacks
  }] -body {
    sql execute $db {
      CREATE TABLE t1(x INTEGER, y SPECIAL);
      INSERT INTO t1 (x, y) VALUES(1, NULL);
      INSERT INTO t1 (x, y) VALUES(2, 0);
      INSERT INTO t1 (x, y) VALUES(3, 1);
      INSERT INTO t1 (x, y) VALUES(4, 1.2);
      INSERT INTO t1 (x, y) VALUES(5, 'three');
      INSERT INTO t1 (x, y) VALUES(6, X'040506');
      INSERT INTO t1 (x, y) VALUES(7, '2016-06-19 19:50:04.1234567');
      INSERT INTO t1 (x, y) VALUES(8, '74f1f402-ddef-4027-a78f-3847fa97b830');
    }

    set connection [getDbConnection]

    set result [list]

    set typeCallbacks [object invoke -marshalflags +DynamicCallback \
        System.Data.SQLite.SQLiteTypeCallbacks Create null \
        {-callbackflags +Default readValueCallback2} null null]

    $connection SetTypeCallbacks SPECIAL $typeCallbacks

    set dataReader [sql execute -execute reader -format datareader \
        -alias $db "SELECT x, y FROM t1 ORDER BY x;"]

    while {[$dataReader Read]} {
      if {$isArray} then {
        set buffer [object invoke -create Array CreateInstance $typeName 100]

        if {[catch {
          $dataReader $methodName 1 0 $buffer 0 1
        } value] == 0} then {
          lappend result $value

          if {$value > 0} then {
            set list [object create -alias StringList $buffer]

            lappend result [object invoke StringList GetRange $list 0 [expr {$value - 1}] false]
          }
        } else {
          lappend result [list array_error $::errorCode]
        }
      } else {
        if {[catch {
          $dataReader $methodName 1
        } value] == 0} then {

          if {$value eq "\x00"} then {
            lappend result <NUL>
          } else {
            lappend result [getStringFromObjectHandle $value]
          }

        } else {
          lappend result [list value_error $::errorCode]
        }
      }
    }

    set result
  } -cleanup {
    unset -nocomplain dataReader
    freeDbConnection

    cleanupDb $fileName

    unset -nocomplain buffer typeCallbacks isArray methodName typeName
    unset -nocomplain value result connection db fileName
  } -constraints {eagle command.object monoBug28 command.sql compile.DATA\
SQLite System.Data.SQLite} -result $expectedResult}

  rename readValueCallback2 ""
}

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

object invoke Interpreter.GetActive DateTimeFormat $savedDateTimeFormat
unset -nocomplain savedDateTimeFormat

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

unset -nocomplain i readArguments readMappings typeName methodName isArray \
    propertyName isRequired value expectedResult

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

runTest {test types-3.1 {bind callback (incomplete)} -setup {
  unset -nocomplain log

  setupDb [set fileName types-3.1.db] "" "" "" \
      "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
} -body {
  sql execute $db {
    CREATE TABLE t1(x SPECIAL);
  }

  set connection [getDbConnection]

  set typeCallbacks [object invoke -marshalflags +DynamicCallback \
      System.Data.SQLite.SQLiteTypeCallbacks Create \
      {-callbackflags +Default bindValueCallback1} null 0 null]

  $connection SetTypeCallbacks SPECIAL $typeCallbacks

  sql execute $db {
    INSERT INTO t1 (x) VALUES(?);
  } [list Special Int64 1234]

  list [expr {
    [info exists log(bind)] ? $log(bind) : "<MISSING>"
  }] [sql execute -execute reader -format list $db \
      "SELECT * FROM t1 ORDER BY x;"]
} -cleanup {
  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain typeCallbacks
  unset -nocomplain log connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{{convert true} {command true} {flags\
{UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
true} {typeName Special} {index 1} {userData 0}} 1234}}

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

runTest {test types-3.2 {bind callback (complete)} -setup {
  unset -nocomplain log

  setupDb [set fileName types-3.2.db] "" "" "" \
      "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
} -body {
  sql execute $db {
    CREATE TABLE t1(x SPECIAL);
  }

  set connection [getDbConnection]

  set typeCallbacks [object invoke -marshalflags +DynamicCallback \
      System.Data.SQLite.SQLiteTypeCallbacks Create \
      {-callbackflags +Default bindValueCallback1} null 1 null]

  $connection SetTypeCallbacks SPECIAL $typeCallbacks

  sql execute $db {
    INSERT INTO t1 (x) VALUES(?);
  } [list Special Int64 5678]

  list [expr {
    [info exists log(bind)] ? $log(bind) : "<MISSING>"
  }] [sql execute -execute reader -format list $db \
      "SELECT * FROM t1 ORDER BY x;"]
} -cleanup {
  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain typeCallbacks
  unset -nocomplain log connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{{convert true} {command true} {flags\
{UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
true} {typeName Special} {index 1} {userData 1}} {}}}

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

runTest {test types-3.3 {bind callback (modify/incomplete)} -setup {
  unset -nocomplain log

  setupDb [set fileName types-3.3.db] "" "" "" \
      "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
} -body {
  sql execute $db {
    CREATE TABLE t1(x SPECIAL);
  }

  set connection [getDbConnection]

  set typeCallbacks [object invoke -marshalflags +DynamicCallback \
      System.Data.SQLite.SQLiteTypeCallbacks Create \
      {-callbackflags +Default bindValueCallback1} null 2 null]

  $connection SetTypeCallbacks SPECIAL $typeCallbacks

  sql execute $db {
    INSERT INTO t1 (x) VALUES(?);
  } [list Special Int64 9999]

  list [expr {
    [info exists log(bind)] ? $log(bind) : "<MISSING>"
  }] [sql execute -execute reader -format list $db \
      "SELECT * FROM t1 ORDER BY x;"]
} -cleanup {
  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain typeCallbacks
  unset -nocomplain log connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{{convert true} {command true} {flags\
{UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
true} {typeName Special} {index 1} {userData 2}} custom}}

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

runTest {test types-4.1 {read callback (exception)} -setup {
  unset -nocomplain log

  setupDb [set fileName types-4.1.db] "" "" "" UseConnectionReadValueCallbacks
} -body {
  sql execute $db {
    CREATE TABLE t1(x SPECIAL);
    INSERT INTO t1 (x) VALUES(8888);
  }

  set connection [getDbConnection]

  set typeCallbacks [object invoke -marshalflags +DynamicCallback \
      System.Data.SQLite.SQLiteTypeCallbacks Create null \
      {-callbackflags "+Default ThrowOnError" readValueCallback1} \
      null 3]

  $connection SetTypeCallbacks SPECIAL $typeCallbacks

  list [catch {sql execute -execute reader -format list $db {SELECT * FROM t1 ORDER BY x;}} error] [extractSystemDataSQLiteExceptionMessage $error] [catch {sql execute -execute scalar $db {SELECT COUNT(*) FROM t1;}} error] [extractSystemDataSQLiteExceptionMessage $error] [expr {
    [info exists log(read)] ? $log(read) : "<MISSING>"
  }]
} -cleanup {
  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain typeCallbacks
  unset -nocomplain log connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {1 {reading of value canceled} 0 1 {{convert true}\
{dataReader true} {flags UseConnectionReadValueCallbacks} {eventArgs true}\
{typeName SPECIAL} {index 0} {userData 3}}}}

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

runTest {test types-5.1 {bind callback (exception)} -setup {
  unset -nocomplain log

  setupDb [set fileName types-5.1.db] "" "" "" \
      "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
} -body {
  sql execute $db {
    CREATE TABLE t1(x SPECIAL);
  }

  set connection [getDbConnection]

  set typeCallbacks [object invoke -marshalflags +DynamicCallback \
      System.Data.SQLite.SQLiteTypeCallbacks Create \
      {-callbackflags "+Default ThrowOnError" bindValueCallback1} \
      null 3 null]

  $connection SetTypeCallbacks SPECIAL $typeCallbacks

  catch {
    sql execute $db {
      INSERT INTO t1 (x) VALUES(?);
    } [list Special Int64 4321]
  }

  list [expr {
    [info exists log(bind)] ? $log(bind) : "<MISSING>"
  }] [sql execute -execute reader -format list $db \
      "SELECT * FROM t1 ORDER BY x;"]
} -cleanup {
  freeDbConnection

  cleanupDb $fileName

  unset -nocomplain typeCallbacks
  unset -nocomplain log connection db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -result {{{convert true} {command true} {flags\
{UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
true} {typeName Special} {index 1} {userData 3}} {}}}

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

rename readValueCallback1 ""
rename bindValueCallback1 ""

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

runSQLiteTestEpilogue
runTestEpilogue