System.Data.SQLite
Check-in [27785d64aa]
Not logged in

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

Overview
Comment:Cleanup and robustify tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | customDataTypes
Files: files | file ages | folders
SHA1: 27785d64aa1cc2a9e035cca60f9c81db61e296a5
User & Date: mistachkin 2016-06-20 20:22:43
Context
2016-06-20
20:30
Reorganize the new connection flags. check-in: d1e833bf59 user: mistachkin tags: customDataTypes
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
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Tests/types.eagle.

    19     19   runSQLiteTestPrologue
    20     20   
    21     21   ###############################################################################
    22     22   
    23     23   proc bindValueCallback1 {
    24     24           convert command flags parameter typeName index userData
    25     25           completeVarName } {
    26         -
    27     26     lappend ::log(bind) [list convert [isObjectHandle $convert]]
    28     27     lappend ::log(bind) [list command [isObjectHandle $command]]
    29     28     lappend ::log(bind) [list flags [getStringFromObjectHandle $flags]]
    30     29     lappend ::log(bind) [list parameter [isObjectHandle $parameter]]
    31     30     lappend ::log(bind) [list typeName [getStringFromObjectHandle $typeName]]
    32     31     lappend ::log(bind) [list index [getStringFromObjectHandle $index]]
    33     32     lappend ::log(bind) [list userData [getStringFromObjectHandle $userData]]
    34     33   
    35     34     if {[getStringFromObjectHandle $userData] == 3} then {
           35  +    upvar 1 $completeVarName complete; unset complete
    36     36       error "parameter binding canceled"
    37     37     }
    38     38   
    39     39     if {[getStringFromObjectHandle $userData] == 2} then {
    40     40       $parameter DbType String
    41     41       $parameter Value custom
    42     42     }
................................................................................
    43     43   
    44     44     if {[getStringFromObjectHandle $userData] == 1} then {
    45     45       upvar 1 $completeVarName complete
    46     46       set complete [object invoke -create System.Boolean Parse True]
    47     47     }
    48     48   }
    49     49   
           50  +###############################################################################
           51  +
    50     52   proc readValueCallback1 {
    51     53           convert dataReader flags eventArgs typeName index userData
    52     54           completeVarName } {
    53         -
    54     55     lappend ::log(read) [list convert [isObjectHandle $convert]]
    55     56     lappend ::log(read) [list dataReader [isObjectHandle $dataReader]]
    56     57     lappend ::log(read) [list flags [getStringFromObjectHandle $flags]]
    57     58     lappend ::log(read) [list eventArgs [isObjectHandle $eventArgs]]
    58     59     lappend ::log(read) [list typeName [getStringFromObjectHandle $typeName]]
    59     60     lappend ::log(read) [list index [getStringFromObjectHandle $index]]
    60     61     lappend ::log(read) [list userData [getStringFromObjectHandle $userData]]
    61     62   
    62     63     if {[getStringFromObjectHandle $userData] == 3} then {
           64  +    upvar 1 $completeVarName complete; unset complete
    63     65       error "reading of value canceled"
    64     66     }
    65     67   
    66     68     if {[getStringFromObjectHandle $userData] == 1} then {
    67     69       upvar 1 $completeVarName complete
    68     70       set complete [object invoke -create System.Boolean Parse True]
    69     71     }
................................................................................
   101    103     unset -nocomplain typeCallbacks
   102    104     unset -nocomplain result connection db fileName
   103    105   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   104    106   System.Data.SQLite} -result {0 True True 1 True True}}
   105    107   
   106    108   ###############################################################################
   107    109   
   108         -set readArguments [list \
          110  +set readArgs [list \
   109    111       convert dataReader flags eventArgs typeName index userData \
   110    112       completeVarName]
   111    113   
   112         -set readMappings [list \
   113         -    [list Boolean   GetBoolean   false  BooleanValue   true   0 \
   114         -        {False False True False False False False False}] \
   115         -    [list Byte      GetByte      false  ByteValue      true   0 \
   116         -        {0 0 1 0 0 0 0 0}] \
   117         -    [list Byte      GetBytes     true   BytesValue     false  0 \
   118         -        {0 1 48 1 49 3 {49 46 50} 5 {116 104 114 101 101} 1 4 27\
   119         -        {50 48 49 54 45 48 54 45 49 57 32 49 57 58 53 48 58 48 52\
   120         -        46 49 50 51 52 53 54 55} 36 {55 52 102 49 102 52 48 50 45\
   121         -        100 100 101 102 45 52 48 50 55 45 97 55 56 102 45 51 56 52\
   122         -        55 102 97 57 55 98 56 51 48}}] \
   123         -    [list Char      GetChar      false  CharValue      true   0 \
   124         -        "<NUL> <NUL> \x01 <NUL> <NUL> <NUL> <NUL> <NUL>"] \
   125         -    [list Char      GetChars     true   CharsValue     false  0 \
   126         -        "0 1 0 1 1 3 {1 . 2} 1 t 1 \x04 1 2 1 7"] \
   127         -    [list DateTime  GetDateTime  false  DateTimeValue  true   0 \
   128         -        {{0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
          114  +set params [list \
          115  +    [list Boolean    GetBoolean    false   BooleanValue    true    0] \
          116  +    [list Byte       GetByte       false   ByteValue       true    0] \
          117  +    [list Byte       GetBytes      true    BytesValue      false   0] \
          118  +    [list Char       GetChar       false   CharValue       true    0] \
          119  +    [list Char       GetChars      true    CharsValue      false   0] \
          120  +    [list DateTime   GetDateTime   false   DateTimeValue   true    0] \
          121  +    [list Decimal    GetDecimal    false   DecimalValue    true    0] \
          122  +    [list Double     GetDouble     false   DoubleValue     true    0] \
          123  +    [list Single     GetFloat      false   FloatValue      true    0] \
          124  +    [list Guid       GetGuid       false   GuidValue       true    \
          125  +        00000000-0000-0000-0000-000000000000] \
          126  +    [list Int16      GetInt16      false   Int16Value      true    0] \
          127  +    [list Int32      GetInt32      false   Int32Value      true    0] \
          128  +    [list Int64      GetInt64      false   Int64Value      true    0] \
          129  +    [list String     GetString     false   StringValue     false   null] \
          130  +    [list Object     GetValue      false   Value           false   null]]
          131  +
          132  +###############################################################################
          133  +
          134  +set expectedResults [list \
          135  +    {False False True False False False False False} \
          136  +    {0 0 1 0 0 0 0 0} \
          137  +    {0 1 48 1 49 3 {49 46 50} 5 {116 104 114\
          138  +        101 101} 1 4 27 {50 48 49 54 45 48 54\
          139  +        45 49 57 32 49 57 58 53 48 58 48 52 46\
          140  +        49 50 51 52 53 54 55} 36 {55 52 102 49\
          141  +        102 52 48 50 45 100 100 101 102 45 52\
          142  +        48 50 55 45 97 55 56 102 45 51 56 52 55\
          143  +        102 97 57 55 98 56 51 48}} \
          144  +    "<NUL> <NUL> \x01 <NUL> <NUL> <NUL> <NUL> <NUL>" \
          145  +    "0 1 0 1 1 3 {1 . 2} 1 t 1 \x04 1 2 1 7" \
          146  +    {{0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
   129    147           {0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
   130    148           {0001-01-01 00:00:00Z} {0001-01-01 00:00:00Z}\
   131         -        {2016-06-19 19:50:04.1234567Z} {0001-01-01 00:00:00Z}}] \
   132         -    [list Decimal   GetDecimal   false  DecimalValue   true   0 \
   133         -        {0 0 1 1.2 0 0 0 0}] \
   134         -    [list Double    GetDouble    false  DoubleValue    true   0 \
   135         -        {0 0 1 1.2 0 0 0 0}] \
   136         -    [list Single    GetFloat     false  FloatValue     true   0 \
   137         -        {0 0 1 1.2 0 0 0 0}] \
   138         -    [list Guid      GetGuid      false  GuidValue      true   [guid null] \
   139         -        {00000000-0000-0000-0000-000000000000\
          149  +        {2016-06-19 19:50:04.1234567Z} {0001-01-01\
          150  +        00:00:00Z}} \
          151  +    {0 0 1 1.2 0 0 0 0} \
          152  +    {0 0 1 1.2 0 0 0 0} \
          153  +    {0 0 1 1.2 0 0 0 0} \
          154  +    {00000000-0000-0000-0000-000000000000\
   140    155           00000000-0000-0000-0000-000000000000\
   141    156           00000000-0000-0000-0000-000000000000\
   142    157           00000000-0000-0000-0000-000000000000\
   143    158           00000000-0000-0000-0000-000000000000\
   144    159           00060504-0000-0000-0000-000000000000\
   145    160           00000000-0000-0000-0000-000000000000\
   146         -        74f1f402-ddef-4027-a78f-3847fa97b830}] \
   147         -    [list Int16     GetInt16     false  Int16Value     true   0 \
   148         -        {0 0 1 0 0 0 0 0}] \
   149         -    [list Int32     GetInt32     false  Int32Value     true   0 \
   150         -        {0 0 1 0 0 0 0 0}] \
   151         -    [list Int64     GetInt64     false  Int64Value     true   0 \
   152         -        {0 0 1 0 0 0 0 0}] \
   153         -    [list String    GetString    false  StringValue    false  null \
   154         -        "<NUL> <NUL> <NUL> <NUL> three \x04\x05\x06 {2016-06-19 19:50:04.1234567}\
   155         -        74f1f402-ddef-4027-a78f-3847fa97b830"] \
   156         -    [list Object    GetValue     false  Value          false  null \
   157         -        "{} 0 1 1.2 three {4 5 6} {2016-06-19 19:50:04.1234567}\
   158         -        74f1f402-ddef-4027-a78f-3847fa97b830"]]
          161  +        74f1f402-ddef-4027-a78f-3847fa97b830} \
          162  +    {0 0 1 0 0 0 0 0} \
          163  +    {0 0 1 0 0 0 0 0} \
          164  +    {0 0 1 0 0 0 0 0} \
          165  +    "<NUL> <NUL> <NUL> <NUL> three \x04\x05\x06\
          166  +        {2016-06-19 19:50:04.1234567}\
          167  +        74f1f402-ddef-4027-a78f-3847fa97b830" \
          168  +    {{} 0 1 1.2 three {4 5 6} {2016-06-19\
          169  +        19:50:04.1234567}\
          170  +        74f1f402-ddef-4027-a78f-3847fa97b830}]
   159    171   
   160    172   ###############################################################################
   161    173   
   162    174   set savedDateTimeFormat [object invoke Interpreter.GetActive DateTimeFormat]
   163    175   if {![isObjectHandle $savedDateTimeFormat]} then {set savedDateTimeFormat null}
   164    176   object invoke Interpreter.GetActive DateTimeFormat [getDateTimeFormat]
   165    177   
   166    178   ###############################################################################
   167    179   
   168         -for {set i 0} {$i < [llength $readMappings]} {incr i} {
          180  +for {set i 0} {$i < [llength $params]} {incr i} {
   169    181     foreach {
   170         -    typeName methodName isArray propertyName
   171         -    isRequired value expectedResult
   172         -  } [lindex $readMappings $i] break
          182  +    typeName methodName isArray propertyName isRequired value
          183  +  } [lindex $params $i] break
   173    184   
   174         -  proc readValueCallback2 $readArguments [subst {
          185  +  set expectedResult [lindex $expectedResults $i]
          186  +
          187  +  #############################################################################
          188  +
          189  +  proc readValueCallback2 $readArgs [subst {
   175    190       if {$isArray} then {
   176    191         if {\[catch {
   177         -        set keyValue \[\$dataReader GetInt64 0\]
          192  +        set dataOffset \[\$eventArgs ArrayEventArgs.DataOffset\]
   178    193   
   179         -set dataOffset \[\$eventArgs ArrayEventArgs.DataOffset\]
   180         -set buffer \[\$eventArgs -create [appendArgs ArrayEventArgs. $typeName Buffer]\]
   181         -set bufferOffset \[\$eventArgs ArrayEventArgs.BufferOffset\]
   182         -set length \[\$eventArgs ArrayEventArgs.Length\]
   183         -set readValue \[\$dataReader \[\$eventArgs MethodName\] \$index \$dataOffset \$buffer \$bufferOffset \$length\]
          194  +        set buffer \[\$eventArgs -create [appendArgs ArrayEventArgs. \
          195  +            $typeName Buffer]\]
          196  +
          197  +        set bufferOffset \[\$eventArgs ArrayEventArgs.BufferOffset\]
          198  +        set length \[\$eventArgs ArrayEventArgs.Length\]
          199  +
          200  +        set readValue \[\$dataReader \[\$eventArgs MethodName\] \
          201  +            \$index \$dataOffset \$buffer \$bufferOffset \$length\]
   184    202   
   185    203           \$eventArgs \[appendArgs Value. $propertyName\] \$readValue
   186    204         } error\]} then {
   187         -
   188         -
   189         -
   190         -          set readValue \[\$dataReader -tostring GetValue \$index\]
   191         -
   192         -
          205  +        set readValue \[\$dataReader -tostring GetValue \$index\]
   193    206   
   194    207           if {"$typeName" eq "Char"} then {
   195    208             set string \[object create -alias String \$readValue\]
   196         -
   197         -
   198    209             set buffer \[\$string -create -alias ToCharArray]
   199         -
   200         -
   201    210           } else {
   202         -          set buffer \[object invoke -create -alias System.Text.Encoding.UTF8 GetBytes \$readValue\]
          211  +          set buffer \[object invoke -create -alias \
          212  +              System.Text.Encoding.UTF8 GetBytes \$readValue\]
   203    213           }
   204    214   
   205         -        \$eventArgs ArrayEventArgs.Length \[\$buffer Length\]
   206         -
   207    215           \$eventArgs \[appendArgs Value. $propertyName\] \$buffer
   208         -
          216  +        \$eventArgs ArrayEventArgs.Length \[\$buffer Length\]
   209    217         } else {
          218  +        set buffer \[\$eventArgs -create [appendArgs ArrayEventArgs. \
          219  +            $typeName Buffer]\]
   210    220   
   211         -        set buffer \[\$eventArgs -create [appendArgs ArrayEventArgs. $typeName Buffer]\]
   212    221           \$eventArgs \[appendArgs Value. $propertyName\] \$buffer
   213         -
   214         -
   215         -
   216    222         }
   217    223       } else {
   218    224         if {\[catch {
   219         -        set keyValue \[\$dataReader GetInt64 0\]
   220    225           set readValue \[\$dataReader \[\$eventArgs MethodName\] \$index\]
   221    226   
   222    227           if {"$typeName" eq "Char"} then {
   223    228             set readValue \[object invoke -create Char Parse \$readValue\]
   224    229           }
   225    230   
   226    231           \$eventArgs \[appendArgs Value. $propertyName\] \$readValue
   227    232         } error\]} then {
   228         -
   229    233           \$eventArgs \[appendArgs Value. $propertyName\] {$value}
   230    234         }
   231    235       }
          236  +
   232    237       upvar 1 \$completeVarName complete
   233    238       set complete \[object invoke -create System.Boolean Parse True\]
   234    239     }]
   235    240   
   236         -  runTest {test [appendArgs types-2. $i] [appendArgs $methodName " callback"] -setup [subst -nocommands {
          241  +  #############################################################################
          242  +
          243  +  runTest {test [appendArgs types-2. $i] [appendArgs $methodName " callback"] \
          244  +      -setup [subst -nocommands {
   237    245       set typeName {$typeName}
   238    246       set methodName {$methodName}
   239    247       set isArray {$isArray}
   240    248   
   241         -    setupDb [set fileName [appendArgs types-2. $i .db]] "" "" "" UseConnectionReadValueCallbacks
          249  +    setupDb [set fileName [appendArgs types-2. $i .db]] "" "" "" \
          250  +        UseConnectionReadValueCallbacks
   242    251     }] -body {
   243    252       sql execute $db {
   244    253         CREATE TABLE t1(x INTEGER, y SPECIAL);
   245    254         INSERT INTO t1 (x, y) VALUES(1, NULL);
   246    255         INSERT INTO t1 (x, y) VALUES(2, 0);
   247    256         INSERT INTO t1 (x, y) VALUES(3, 1);
   248    257         INSERT INTO t1 (x, y) VALUES(4, 1.2);
   249    258         INSERT INTO t1 (x, y) VALUES(5, 'three');
   250    259         INSERT INTO t1 (x, y) VALUES(6, X'040506');
   251    260         INSERT INTO t1 (x, y) VALUES(7, '2016-06-19 19:50:04.1234567');
   252    261         INSERT INTO t1 (x, y) VALUES(8, '74f1f402-ddef-4027-a78f-3847fa97b830');
   253    262       }
   254    263   
          264  +    set callback {-callbackflags +Default readValueCallback2}
   255    265       set connection [getDbConnection]
   256    266   
   257    267       set result [list]
   258    268   
   259    269       set typeCallbacks [object invoke -marshalflags +DynamicCallback \
   260         -        System.Data.SQLite.SQLiteTypeCallbacks Create null \
   261         -        {-callbackflags +Default readValueCallback2} null null]
          270  +        System.Data.SQLite.SQLiteTypeCallbacks Create null $callback \
          271  +        null null]
   262    272   
   263    273       $connection SetTypeCallbacks SPECIAL $typeCallbacks
   264    274   
   265    275       set dataReader [sql execute -execute reader -format datareader \
   266         -        -alias $db "SELECT x, y FROM t1 ORDER BY x;"]
          276  +        -alias $db "SELECT y FROM t1 ORDER BY x;"]
   267    277   
   268    278       while {[$dataReader Read]} {
   269    279         if {$isArray} then {
   270         -        set buffer [object invoke -create Array CreateInstance $typeName 100]
          280  +        set buffer [object invoke \
          281  +            -create Array CreateInstance $typeName 100]
   271    282   
   272    283           if {[catch {
   273         -          $dataReader $methodName 1 0 $buffer 0 1
          284  +          $dataReader $methodName 0 0 $buffer 0 1
   274    285           } value] == 0} then {
   275    286             lappend result $value
   276    287   
   277    288             if {$value > 0} then {
   278    289               set list [object create -alias StringList $buffer]
   279    290   
   280         -            lappend result [object invoke StringList GetRange $list 0 [expr {$value - 1}] false]
          291  +            lappend result [object invoke StringList GetRange \
          292  +                $list 0 [expr {$value - 1}] false]
   281    293             }
   282    294           } else {
   283         -          lappend result [list array_error $::errorCode]
          295  +          lappend result [list error(array) $::errorCode]
   284    296           }
   285    297         } else {
   286    298           if {[catch {
   287         -          $dataReader $methodName 1
          299  +          $dataReader $methodName 0
   288    300           } value] == 0} then {
   289         -
   290    301             if {$value eq "\x00"} then {
   291    302               lappend result <NUL>
   292    303             } else {
   293    304               lappend result [getStringFromObjectHandle $value]
   294    305             }
   295         -
   296    306           } else {
   297         -          lappend result [list value_error $::errorCode]
          307  +          lappend result [list error(value) $::errorCode]
   298    308           }
   299    309         }
   300    310       }
   301    311   
   302    312       set result
   303    313     } -cleanup {
          314  +    catch {object removecallback $callback}
          315  +
   304    316       unset -nocomplain dataReader
   305    317       freeDbConnection
   306    318   
   307    319       cleanupDb $fileName
   308    320   
   309         -    unset -nocomplain buffer typeCallbacks isArray methodName typeName
   310         -    unset -nocomplain value result connection db fileName
          321  +    unset -nocomplain buffer typeCallbacks callback value list
          322  +    unset -nocomplain result connection db fileName
          323  +    unset -nocomplain typeName methodName isArray
   311    324     } -constraints {eagle command.object monoBug28 command.sql compile.DATA\
   312    325   SQLite System.Data.SQLite} -result $expectedResult}
   313    326   
   314    327     rename readValueCallback2 ""
   315    328   }
   316    329   
   317    330   ###############################################################################
   318    331   
   319    332   object invoke Interpreter.GetActive DateTimeFormat $savedDateTimeFormat
   320    333   unset -nocomplain savedDateTimeFormat
   321    334   
   322    335   ###############################################################################
   323    336   
   324         -unset -nocomplain i readArguments readMappings typeName methodName isArray \
   325         -    propertyName isRequired value expectedResult
          337  +unset -nocomplain i readArgs params typeName methodName isArray propertyName \
          338  +    isRequired expectedResults expectedResult
   326    339   
   327    340   ###############################################################################
   328    341   
   329    342   runTest {test types-3.1 {bind callback (incomplete)} -setup {
   330    343     unset -nocomplain log
   331    344   
   332    345     setupDb [set fileName types-3.1.db] "" "" "" \
   333    346         "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
   334    347   } -body {
   335    348     sql execute $db {
   336    349       CREATE TABLE t1(x SPECIAL);
   337    350     }
   338    351   
          352  +  set callback {-callbackflags +Default bindValueCallback1}
   339    353     set connection [getDbConnection]
   340    354   
   341    355     set typeCallbacks [object invoke -marshalflags +DynamicCallback \
   342         -      System.Data.SQLite.SQLiteTypeCallbacks Create \
   343         -      {-callbackflags +Default bindValueCallback1} null 0 null]
          356  +      System.Data.SQLite.SQLiteTypeCallbacks Create $callback null \
          357  +      0 null]
   344    358   
   345    359     $connection SetTypeCallbacks SPECIAL $typeCallbacks
   346    360   
   347    361     sql execute $db {
   348    362       INSERT INTO t1 (x) VALUES(?);
   349    363     } [list Special Int64 1234]
   350    364   
   351         -  list [expr {
          365  +  set result [list]
          366  +
          367  +  lappend result [expr {
   352    368       [info exists log(bind)] ? $log(bind) : "<MISSING>"
   353         -  }] [sql execute -execute reader -format list $db \
          369  +  }]
          370  +
          371  +  lappend result [sql execute -execute reader -format list $db \
   354    372         "SELECT * FROM t1 ORDER BY x;"]
          373  +
          374  +  set result
   355    375   } -cleanup {
          376  +  catch {object removecallback $callback}
          377  +
   356    378     freeDbConnection
   357    379   
   358    380     cleanupDb $fileName
   359    381   
   360         -  unset -nocomplain typeCallbacks
   361         -  unset -nocomplain log connection db fileName
          382  +  unset -nocomplain result typeCallbacks callback log connection db fileName
   362    383   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   363    384   System.Data.SQLite} -result {{{convert true} {command true} {flags\
   364    385   {UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
   365    386   true} {typeName Special} {index 1} {userData 0}} 1234}}
   366    387   
   367    388   ###############################################################################
   368    389   
................................................................................
   372    393     setupDb [set fileName types-3.2.db] "" "" "" \
   373    394         "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
   374    395   } -body {
   375    396     sql execute $db {
   376    397       CREATE TABLE t1(x SPECIAL);
   377    398     }
   378    399   
          400  +  set callback {-callbackflags +Default bindValueCallback1}
   379    401     set connection [getDbConnection]
   380    402   
   381    403     set typeCallbacks [object invoke -marshalflags +DynamicCallback \
   382         -      System.Data.SQLite.SQLiteTypeCallbacks Create \
   383         -      {-callbackflags +Default bindValueCallback1} null 1 null]
          404  +      System.Data.SQLite.SQLiteTypeCallbacks Create $callback null \
          405  +      1 null]
   384    406   
   385    407     $connection SetTypeCallbacks SPECIAL $typeCallbacks
   386    408   
   387    409     sql execute $db {
   388    410       INSERT INTO t1 (x) VALUES(?);
   389    411     } [list Special Int64 5678]
   390    412   
   391         -  list [expr {
          413  +  set result [list]
          414  +
          415  +  lappend result [expr {
   392    416       [info exists log(bind)] ? $log(bind) : "<MISSING>"
   393         -  }] [sql execute -execute reader -format list $db \
          417  +  }]
          418  +
          419  +  lappend result [sql execute -execute reader -format list $db \
   394    420         "SELECT * FROM t1 ORDER BY x;"]
          421  +
          422  +  set result
   395    423   } -cleanup {
          424  +  catch {object removecallback $callback}
          425  +
   396    426     freeDbConnection
   397    427   
   398    428     cleanupDb $fileName
   399    429   
   400         -  unset -nocomplain typeCallbacks
   401         -  unset -nocomplain log connection db fileName
          430  +  unset -nocomplain result typeCallbacks callback log connection db fileName
   402    431   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   403    432   System.Data.SQLite} -result {{{convert true} {command true} {flags\
   404    433   {UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
   405    434   true} {typeName Special} {index 1} {userData 1}} {}}}
   406    435   
   407    436   ###############################################################################
   408    437   
................................................................................
   412    441     setupDb [set fileName types-3.3.db] "" "" "" \
   413    442         "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
   414    443   } -body {
   415    444     sql execute $db {
   416    445       CREATE TABLE t1(x SPECIAL);
   417    446     }
   418    447   
          448  +  set callback {-callbackflags +Default bindValueCallback1}
   419    449     set connection [getDbConnection]
   420    450   
   421    451     set typeCallbacks [object invoke -marshalflags +DynamicCallback \
   422         -      System.Data.SQLite.SQLiteTypeCallbacks Create \
   423         -      {-callbackflags +Default bindValueCallback1} null 2 null]
          452  +      System.Data.SQLite.SQLiteTypeCallbacks Create $callback null \
          453  +      2 null]
   424    454   
   425    455     $connection SetTypeCallbacks SPECIAL $typeCallbacks
   426    456   
   427    457     sql execute $db {
   428    458       INSERT INTO t1 (x) VALUES(?);
   429    459     } [list Special Int64 9999]
   430    460   
   431         -  list [expr {
          461  +  set result [list]
          462  +
          463  +  lappend result [expr {
   432    464       [info exists log(bind)] ? $log(bind) : "<MISSING>"
   433         -  }] [sql execute -execute reader -format list $db \
          465  +  }]
          466  +
          467  +  lappend result [sql execute -execute reader -format list $db \
   434    468         "SELECT * FROM t1 ORDER BY x;"]
          469  +
          470  +  set result
   435    471   } -cleanup {
          472  +  catch {object removecallback $callback}
          473  +
   436    474     freeDbConnection
   437    475   
   438    476     cleanupDb $fileName
   439    477   
   440         -  unset -nocomplain typeCallbacks
   441         -  unset -nocomplain log connection db fileName
          478  +  unset -nocomplain result typeCallbacks callback log connection db fileName
   442    479   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   443    480   System.Data.SQLite} -result {{{convert true} {command true} {flags\
   444    481   {UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
   445    482   true} {typeName Special} {index 1} {userData 2}} custom}}
   446    483   
   447    484   ###############################################################################
   448    485   
   449    486   runTest {test types-4.1 {read callback (exception)} -setup {
   450    487     unset -nocomplain log
   451    488   
   452         -  setupDb [set fileName types-4.1.db] "" "" "" UseConnectionReadValueCallbacks
          489  +  setupDb [set fileName types-4.1.db] "" "" "" \
          490  +      UseConnectionReadValueCallbacks
   453    491   } -body {
   454    492     sql execute $db {
   455    493       CREATE TABLE t1(x SPECIAL);
   456    494       INSERT INTO t1 (x) VALUES(8888);
   457    495     }
   458    496   
          497  +  set callback {-callbackflags {+Default ThrowOnError} readValueCallback1}
   459    498     set connection [getDbConnection]
   460    499   
   461    500     set typeCallbacks [object invoke -marshalflags +DynamicCallback \
   462         -      System.Data.SQLite.SQLiteTypeCallbacks Create null \
   463         -      {-callbackflags "+Default ThrowOnError" readValueCallback1} \
          501  +      System.Data.SQLite.SQLiteTypeCallbacks Create null $callback \
   464    502         null 3]
   465    503   
   466    504     $connection SetTypeCallbacks SPECIAL $typeCallbacks
   467    505   
   468         -  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 {
   469         -    [info exists log(read)] ? $log(read) : "<MISSING>"
   470         -  }]
          506  +  set result [list]
          507  +
          508  +  lappend result [catch {
          509  +    sql execute -execute reader -format list $db {SELECT * FROM t1 ORDER BY x;}
          510  +  } error]
          511  +
          512  +  lappend result [extractSystemDataSQLiteExceptionMessage $error]
          513  +
          514  +  lappend result [catch {
          515  +    sql execute -execute scalar $db {SELECT COUNT(*) FROM t1;}
          516  +  } error]
          517  +
          518  +  lappend result [extractSystemDataSQLiteExceptionMessage $error]
          519  +  lappend result [expr {[info exists log(read)] ? $log(read) : "<MISSING>"}]
          520  +
          521  +  set result
   471    522   } -cleanup {
          523  +  catch {object removecallback $callback}
          524  +
   472    525     freeDbConnection
   473    526   
   474    527     cleanupDb $fileName
   475    528   
   476         -  unset -nocomplain typeCallbacks
   477         -  unset -nocomplain log connection db fileName
          529  +  unset -nocomplain error result typeCallbacks callback log connection db \
          530  +      fileName
   478    531   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   479    532   System.Data.SQLite} -result {1 {reading of value canceled} 0 1 {{convert true}\
   480    533   {dataReader true} {flags UseConnectionReadValueCallbacks} {eventArgs true}\
   481    534   {typeName SPECIAL} {index 0} {userData 3}}}}
   482    535   
   483    536   ###############################################################################
   484    537   
................................................................................
   488    541     setupDb [set fileName types-5.1.db] "" "" "" \
   489    542         "UseConnectionBindValueCallbacks UseParameterNameForTypeName"
   490    543   } -body {
   491    544     sql execute $db {
   492    545       CREATE TABLE t1(x SPECIAL);
   493    546     }
   494    547   
          548  +  set callback {-callbackflags {+Default ThrowOnError} bindValueCallback1}
   495    549     set connection [getDbConnection]
   496    550   
   497    551     set typeCallbacks [object invoke -marshalflags +DynamicCallback \
   498         -      System.Data.SQLite.SQLiteTypeCallbacks Create \
   499         -      {-callbackflags "+Default ThrowOnError" bindValueCallback1} \
   500         -      null 3 null]
          552  +      System.Data.SQLite.SQLiteTypeCallbacks Create $callback null \
          553  +      3 null]
   501    554   
   502    555     $connection SetTypeCallbacks SPECIAL $typeCallbacks
   503    556   
   504    557     catch {
   505    558       sql execute $db {
   506    559         INSERT INTO t1 (x) VALUES(?);
   507    560       } [list Special Int64 4321]
   508    561     }
   509    562   
   510         -  list [expr {
          563  +  set result [list]
          564  +
          565  +  lappend result [expr {
   511    566       [info exists log(bind)] ? $log(bind) : "<MISSING>"
   512         -  }] [sql execute -execute reader -format list $db \
          567  +  }]
          568  +
          569  +  lappend result [sql execute -execute reader -format list $db \
   513    570         "SELECT * FROM t1 ORDER BY x;"]
          571  +
          572  +  set result
   514    573   } -cleanup {
          574  +  catch {object removecallback $callback}
          575  +
   515    576     freeDbConnection
   516    577   
   517    578     cleanupDb $fileName
   518    579   
   519         -  unset -nocomplain typeCallbacks
   520         -  unset -nocomplain log connection db fileName
          580  +  unset -nocomplain result typeCallbacks callback log connection db fileName
   521    581   } -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
   522    582   System.Data.SQLite} -result {{{convert true} {command true} {flags\
   523    583   {UseConnectionBindValueCallbacks, UseParameterNameForTypeName}} {parameter\
   524    584   true} {typeName Special} {index 1} {userData 3}} {}}}
          585  +
          586  +###############################################################################
          587  +
          588  +catch {eval object dispose [info objects System#Boolean#*]}
   525    589   
   526    590   ###############################################################################
   527    591   
   528    592   rename readValueCallback1 ""
   529    593   rename bindValueCallback1 ""
   530    594   
   531    595   ###############################################################################
   532    596   
   533    597   runSQLiteTestEpilogue
   534    598   runTestEpilogue