System.Data.SQLite

Check-in [550a609491]
Login

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

Overview
Comment:Make the (new) SetConfigurationOption tests more robust and get them passing again.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 550a609491610bff6c9a0c2322a62b557f65e618
User & Date: mistachkin 2018-02-26 21:31:22.709
Context
2018-02-26
22:08
Update SQLite core library to the 3.22.0 release in preparation for the 1.0.108.0 release. check-in: 8b068e1af8 user: mistachkin tags: trunk
21:31
Make the (new) SetConfigurationOption tests more robust and get them passing again. check-in: 550a609491 user: mistachkin tags: trunk
20:23
The SetConfigurationOption method needs to throw an exception when the core library result code indicates an error. check-in: ca6b82074a user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Tests/basic.eagle.
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
file} Notice_Recover_Rollback {notification message ==> notification message}\
Warning_AutoIndex {warning message ==> warning message} 999 {unknown error ==>\
unknown error}}}

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

runTest {test data-1.95 {SetConfigurationOption method} -setup {
  setupDb [set fileName data-1.95.db]
} -body {
  set dbConfigs [list]

  lappend dbConfigs SQLITE_DBCONFIG_NONE; # nil
  lappend dbConfigs SQLITE_DBCONFIG_MAINDBNAME; # char*
  lappend dbConfigs SQLITE_DBCONFIG_LOOKASIDE; # void* int int








|







4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
file} Notice_Recover_Rollback {notification message ==> notification message}\
Warning_AutoIndex {warning message ==> warning message} 999 {unknown error ==>\
unknown error}}}

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

runTest {test data-1.95 {SetConfigurationOption method} -setup {
  setupDb [set fileName data-1.95.db] "" "" "" NoExtensionFunctions
} -body {
  set dbConfigs [list]

  lappend dbConfigs SQLITE_DBCONFIG_NONE; # nil
  lappend dbConfigs SQLITE_DBCONFIG_MAINDBNAME; # char*
  lappend dbConfigs SQLITE_DBCONFIG_LOOKASIDE; # void* int int

4956
4957
4958
4959
4960
4961
4962


4963
4964

4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
        set value [object create String test]
      }
      SQLITE_DBCONFIG_LOOKASIDE {
        if {[info exists ptr]} then {
          error "pointer value should not exist yet"
        }



        set ptr [object invoke -create -flags +NonPublic \
            System.Data.SQLite.SQLiteMemory Allocate 20000]


        set ints(0) [object invoke -create Int32 Parse 10000]
        set ints(1) [object invoke -create Int32 Parse 2]

        set value [object create -alias Object\[\] 3]

        $value SetValue $ptr 0
        $value SetValue $ints(0) 1
        $value SetValue $ints(1) 2
      }







>
>
|
|
>

|
|







4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
        set value [object create String test]
      }
      SQLITE_DBCONFIG_LOOKASIDE {
        if {[info exists ptr]} then {
          error "pointer value should not exist yet"
        }

        set size 100; set count 100

        set ptr [object invoke -create \
            System.Runtime.InteropServices.Marshal \
            AllocCoTaskMem [expr {$size * $count}]]

        set ints(0) [object invoke -create Int32 Parse $size]
        set ints(1) [object invoke -create Int32 Parse $count]

        set value [object create -alias Object\[\] 3]

        $value SetValue $ptr 0
        $value SetValue $ints(0) 1
        $value SetValue $ints(1) 2
      }
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031

  lappend result [$connection -flags +NonPublic \
      _sql.GetStatusParameter SQLITE_DBSTATUS_LOOKASIDE_USED \
      false current(0) highwater(0)]

  lappend result $current(0) $highwater(0)

  sql execute $db {
    CREATE TABLE t1(x);
    INSERT INTO t1 (x) VALUES(RANDOMBLOB(1024));
  }

  set current(1) 0; set highwater(1) 0

  lappend result [$connection -flags +NonPublic \
      _sql.GetStatusParameter SQLITE_DBSTATUS_LOOKASIDE_USED \
      false current(1) highwater(1)]

  lappend result $current(1) $highwater(1)

  lappend result [expr {$current(1) == $current(0)}]
  lappend result [expr {$highwater(1) > $highwater(0)}]
} -cleanup {
  cleanupDb $fileName

  freeDbConnection

  if {[info exists ptr]} then {
    object invoke -flags +NonPublic \
        System.Data.SQLite.SQLiteMemory Free $ptr
  }

  unset -nocomplain current highwater ints ptr value
  unset -nocomplain result dbConfig dbConfigs
  unset -nocomplain connection db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -match regexp -result {^\{\} \{\} \{\} \{\} \{\} \{\} \{\}\
\{\} \{\} \{\} Ok \d+ \d+ Ok \d+ \d+ True True$}}

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

reportSQLiteResources $test_channel

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







|
<
<
<









|
|






|
|


|




|










4987
4988
4989
4990
4991
4992
4993
4994



4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031

  lappend result [$connection -flags +NonPublic \
      _sql.GetStatusParameter SQLITE_DBSTATUS_LOOKASIDE_USED \
      false current(0) highwater(0)]

  lappend result $current(0) $highwater(0)

  sql execute $db {CREATE TABLE t1(x);}; # use some lookaside memory?




  set current(1) 0; set highwater(1) 0

  lappend result [$connection -flags +NonPublic \
      _sql.GetStatusParameter SQLITE_DBSTATUS_LOOKASIDE_USED \
      false current(1) highwater(1)]

  lappend result $current(1) $highwater(1)

  lappend result [expr {$highwater(1) > 0}]
  lappend result [expr {$highwater(1) >= $current(1)}]
} -cleanup {
  cleanupDb $fileName

  freeDbConnection

  if {[info exists ptr]} then {
    object invoke System.Runtime.InteropServices.Marshal \
        FreeCoTaskMem $ptr
  }

  unset -nocomplain current highwater ints count size ptr value
  unset -nocomplain result dbConfig dbConfigs
  unset -nocomplain connection db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite} -match regexp -result {^\{\} \{\} \{\} \{\} \{\} \{\} \{\}\
\{\} \{\} \{\} Ok 0 0 Ok \d+ \d+ True True$}}

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

reportSQLiteResources $test_channel

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue
Changes to lib/System.Data.SQLite/common.eagle.
4114
4115
4116
4117
4118
4119
4120


















































4121
4122
4123
4124
4125
4126
4127
        if {!$quiet} then {
          tputs $channel [appendArgs $memory \n]
        }
      }

      return $result
    }



















































    proc checkForSQLiteDirectories { channel {reset false} } {
      #
      # NOTE: Check if the sqlite3_win32_set_directory function is available.
      #
      tputs $channel \
          "---- checking for function sqlite3_win32_set_directory... "







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







4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
        if {!$quiet} then {
          tputs $channel [appendArgs $memory \n]
        }
      }

      return $result
    }

    proc resetSQLiteDirectories { channel native } {
      #
      # NOTE: Attempt to use the native API (via the managed assembly)?
      #
      if {$native} then {
        #
        # NOTE: Now make sure the database and temporary directories are
        #       reset their default values, which should be null for both.
        #       Since the sqlite3_win32_set_directory function is available,
        #       use it.
        #
        for {set index 1} {$index < 3} {incr index} {
          if {[catch {
            object invoke -flags +NonPublic \
                System.Data.SQLite.UnsafeNativeMethods \
                sqlite3_win32_set_directory $index null
          } result] == 0} then {
            tputs $channel [appendArgs \
                "---- call sqlite3_win32_set_directory(" $index \
                ", null)... ok: " $result \n]
          } else {
            tputs $channel [appendArgs \
                "---- call sqlite3_win32_set_directory(" $index \
                ", null)... error: " \n\t $result \n]
          }
        }
      } else {
        #
        # NOTE: Now make sure the database and temporary directories are
        #       reset their default values, which should be null for both.
        #       Since the sqlite3_win32_set_directory function does not
        #       appear to be available, use the associated PRAGMA commands
        #       instead.
        #
        foreach directory [list data_store_directory temp_store_directory] {
          set sql [appendArgs "PRAGMA " $directory " = \"\";"]

          if {[catch {executeSql $sql} result] == 0} then {
            tputs $channel [appendArgs \
                "---- execute PRAGMA " $directory "... ok: \"" \
                $result \"\n]
          } else {
            tputs $channel [appendArgs \
                "---- execute PRAGMA " $directory "... error: " \
                \n\t $result \n]
          }
        }
      }
    }

    proc checkForSQLiteDirectories { channel {reset false} } {
      #
      # NOTE: Check if the sqlite3_win32_set_directory function is available.
      #
      tputs $channel \
          "---- checking for function sqlite3_win32_set_directory... "
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212

        tputs $channel yes\n

        #
        # NOTE: Does our caller want to reset the directories?
        #
        if {$reset} then {
          #
          # NOTE: Now make sure the database and temporary directories are
          #       reset their default values, which should be null for both.
          #       Since the sqlite3_win32_set_directory function is available,
          #       use it.
          #
          for {set index 1} {$index < 3} {incr index} {
            if {[catch {
              object invoke -flags +NonPublic \
                  System.Data.SQLite.UnsafeNativeMethods \
                  sqlite3_win32_set_directory $index null
            } result] == 0} then {
              tputs $channel [appendArgs \
                  "---- call sqlite3_win32_set_directory(" $index \
                  ", null)... ok: " $result \n]
            } else {
              tputs $channel [appendArgs \
                  "---- call sqlite3_win32_set_directory(" $index \
                  ", null)... error: " \n\t $result \n]
            }
          }
        }
      } else {
        tputs $channel no\n

        #
        # NOTE: Does our caller want to reset the directories?  This can only
        #       be performed if SQLite is loaded and ready for use by the test
        #       suite.
        #
        if {$reset && [isSQLiteReady]} then {
          #
          # NOTE: Now make sure the database and temporary directories are
          #       reset their default values, which should be null for both.
          #       Since the sqlite3_win32_set_directory function does not
          #       appear to be available, use the associated PRAGMA commands
          #       instead.
          #
          foreach directory [list data_store_directory temp_store_directory] {
            set sql [appendArgs "PRAGMA " $directory " = \"\";"]

            if {[catch {executeSql $sql} result] == 0} then {
              tputs $channel [appendArgs \
                  "---- execute PRAGMA " $directory "... ok: \"" \
                  $result \"\n]
            } else {
              tputs $channel [appendArgs \
                  "---- execute PRAGMA " $directory "... error: " \
                  \n\t $result \n]
            }
          }
        }
      }

      #
      # NOTE: Finally, show the current value of the database and temporary
      #       directories.  This can only be performed if SQLite is loaded
      #       and ready for use by the test suite.







<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<










<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<







4198
4199
4200
4201
4202
4203
4204












4205








4206
4207
4208
4209
4210
4211
4212
4213
4214
4215











4216








4217
4218
4219
4220
4221
4222
4223

        tputs $channel yes\n

        #
        # NOTE: Does our caller want to reset the directories?
        #
        if {$reset} then {












          resetSQLiteDirectories $channel true








        }
      } else {
        tputs $channel no\n

        #
        # NOTE: Does our caller want to reset the directories?  This can only
        #       be performed if SQLite is loaded and ready for use by the test
        #       suite.
        #
        if {$reset && [isSQLiteReady]} then {











          resetSQLiteDirectories $channel false








        }
      }

      #
      # NOTE: Finally, show the current value of the database and temporary
      #       directories.  This can only be performed if SQLite is loaded
      #       and ready for use by the test suite.