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

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

Overview
Comment:More work on tests. Rename the new environment variable.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f6f755c1ee428a0848527a2a2e18c536493db07f
User & Date: mistachkin 2020-03-05 00:36:25
References
2020-04-03
18:22
Partial cherrypick of [f6f755c1ee4]. check-in: 3399978fe6 user: mistachkin tags: branch-1.0.112
Context
2020-04-03
18:22
Partial cherrypick of [f6f755c1ee4]. check-in: 3399978fe6 user: mistachkin tags: branch-1.0.112
2020-03-10
03:44
Add preliminary support for the .NET Framework 4.8. check-in: d6b5423937 user: mistachkin tags: trunk
2020-03-05
00:36
More work on tests. Rename the new environment variable. check-in: f6f755c1ee user: mistachkin tags: trunk
2020-03-04
03:31
Fix typos in comments. check-in: 4194e07323 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Doc/Extra/Provider/environment.html.

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
          <td>This environment variable is normally set by the operating
          system itself and should reflect the native processor architecture
          of the current process (e.g. a 32-bit x86 application running on a
          64-bit x64 operating system should have the value &quot;x86&quot;).
          </td>
        </tr>
        <tr valign="top">
          <td>SQLite_EncryptPage1</td>
          <td>If this environment variable is set [to anything], page #1 of
          database files encrypted using the (unsupported) legacy CryptoAPI
          codec will be encrypted.  This was the default behavior prior to
          release 1.0.113.0; however, it is now disabled (by default) as it
          can cause corruption and/or other malfunctions in some circumstances.
          Please do not use this environment variable unless it is absolutely
          necessary for your specific use case.</td>







|







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
          <td>This environment variable is normally set by the operating
          system itself and should reflect the native processor architecture
          of the current process (e.g. a 32-bit x86 application running on a
          64-bit x64 operating system should have the value &quot;x86&quot;).
          </td>
        </tr>
        <tr valign="top">
          <td>SQLite_LegacyEncryptPage1</td>
          <td>If this environment variable is set [to anything], page #1 of
          database files encrypted using the (unsupported) legacy CryptoAPI
          codec will be encrypted.  This was the default behavior prior to
          release 1.0.113.0; however, it is now disabled (by default) as it
          can cause corruption and/or other malfunctions in some circumstances.
          Please do not use this environment variable unless it is absolutely
          necessary for your specific use case.</td>

Changes to SQLite.Interop/src/win/crypt.c.

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  DWORD dwPageSize;
  LPVOID pvTemp = NULL;

  if (g_bEncryptPage1 == CRYPT_PAGE1_UNKNOWN)
  {
    WCHAR aBuf[2];
    memset(aBuf, 0, sizeof(aBuf));
    if ((GetEnvironmentVariableW(L"SQLite_EncryptPage1", aBuf, sizeof(aBuf)) != 0)
     || (GetLastError() != ERROR_ENVVAR_NOT_FOUND))
    {
      g_bEncryptPage1 = CRYPT_PAGE1_ENABLED;
    } else {
      g_bEncryptPage1 = CRYPT_PAGE1_DISABLED;
    }
  }







|







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  DWORD dwPageSize;
  LPVOID pvTemp = NULL;

  if (g_bEncryptPage1 == CRYPT_PAGE1_UNKNOWN)
  {
    WCHAR aBuf[2];
    memset(aBuf, 0, sizeof(aBuf));
    if ((GetEnvironmentVariableW(L"SQLite_LegacyEncryptPage1", aBuf, sizeof(aBuf)) != 0)
     || (GetLastError() != ERROR_ENVVAR_NOT_FOUND))
    {
      g_bEncryptPage1 = CRYPT_PAGE1_ENABLED;
    } else {
      g_bEncryptPage1 = CRYPT_PAGE1_DISABLED;
    }
  }

Changes to System.Data.SQLite/Configurations/System.Data.SQLite.dll.config.

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
              CryptoAPI codec will be encrypted.  This was the default
              behavior prior to release 1.0.113.0; however, it is now
              disabled (by default) as it can cause corruption and/or other
              malfunctions in some circumstances.  Please do not use this
              environment variable unless it is absolutely necessary for your
              specific use case.

        NOTE: Since this environment variable is read from the native interop
              assembly, it cannot be set via this configuration file.  It can
              only be set within the process environment.
    -->
    <!--
    <add key="SQLite_EncryptPage1" value="1" />
    -->

    <!--
        NOTE: If this environment variable is set [to anything], all calls to
              prepare a SQL query will be logged, regardless of the flags for
              the associated connection.
    -->







|
|
|


|







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
              CryptoAPI codec will be encrypted.  This was the default
              behavior prior to release 1.0.113.0; however, it is now
              disabled (by default) as it can cause corruption and/or other
              malfunctions in some circumstances.  Please do not use this
              environment variable unless it is absolutely necessary for your
              specific use case.

        NOTE: Since this environment variable is (only) read from the native
              interop assembly, it cannot be set via this configuration file.
              It can only be set within the process environment.
    -->
    <!--
    <add key="SQLite_LegacyEncryptPage1" value="1" />
    -->

    <!--
        NOTE: If this environment variable is set [to anything], all calls to
              prepare a SQL query will be logged, regardless of the flags for
              the associated connection.
    -->

Changes to Tests/basic.eagle.

2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
....
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
....
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [haveConstraint System.Data.SQLite.SEE] || [string equal \
      [readDbFileHeader [file join [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![info exists env(SQLite_EncryptPage1)]
  }]

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain error result db fileName
................................................................................

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [haveConstraint System.Data.SQLite.SEE] || [string equal \
      [readDbFileHeader [file join [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![info exists env(SQLite_EncryptPage1)]
  }]

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain error result db fileName
................................................................................

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [haveConstraint System.Data.SQLite.SEE] || [string equal \
      [readDbFileHeader [file join [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![info exists env(SQLite_EncryptPage1)]
  }]

  set result
} -cleanup {
  unset -nocomplain connection

  cleanupDb $fileName; # NOTE: After object disposal.







|
|
|







 







|
|
|







 







|
|
|







2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
....
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
....
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [string equal [readDbFileHeader [file join \
      [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![page1MustBeEncrypted]
  }]

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain error result db fileName
................................................................................

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [string equal [readDbFileHeader [file join \
      [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![page1MustBeEncrypted]
  }]

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain error result db fileName
................................................................................

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [string equal [readDbFileHeader [file join \
      [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![page1MustBeEncrypted]
  }]

  set result
} -cleanup {
  unset -nocomplain connection

  cleanupDb $fileName; # NOTE: After object disposal.

Changes to Tests/tkt-1c456ae75f.eagle.

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [haveConstraint System.Data.SQLite.SEE] || [string equal \
      [readDbFileHeader [file join [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![info exists env(SQLite_EncryptPage1)]
  }]

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain error result db fileName
................................................................................

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [haveConstraint System.Data.SQLite.SEE] || [string equal \
      [readDbFileHeader [file join [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![info exists env(SQLite_EncryptPage1)]
  }]

  set result
} -cleanup {
  unset -nocomplain connection

  cleanupDb $fileName; # NOTE: After object disposal.







|
|
|







 







|
|
|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [string equal [readDbFileHeader [file join \
      [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![page1MustBeEncrypted]
  }]

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain error result db fileName
................................................................................

  lappend result [catch {sql execute -execute scalar $db \
      "SELECT COUNT(*) FROM t1;"} error] $error

  cleanupDb $fileName db true false false

  lappend result [expr {
      [string equal [readDbFileHeader [file join \
      [getDatabaseDirectory] $fileName]] \
      [getDbFileHeader]] == ![page1MustBeEncrypted]
  }]

  set result
} -cleanup {
  unset -nocomplain connection

  cleanupDb $fileName; # NOTE: After object disposal.

Changes to lib/System.Data.SQLite/common.eagle.

3029
3030
3031
3032
3033
3034
3035












3036
3037
3038
3039
3040
3041
3042
      set channel [open $fileName RDONLY]
      makeBinaryChannel $channel
      set header [getDbFileHeader]
      set result [read $channel [string length $header]]
      close $channel
      return $result
    }












 
    proc setupDb {
            fileName {mode ""} {dateTimeFormat ""} {dateTimeKind ""} {flags ""}
            {extra ""} {qualify true} {delete true} {uri false}
            {temporary true} {varName db} {quiet false} } {
      #
      # NOTE: First, see if our caller has requested an in-memory database.







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







3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
      set channel [open $fileName RDONLY]
      makeBinaryChannel $channel
      set header [getDbFileHeader]
      set result [read $channel [string length $header]]
      close $channel
      return $result
    }
 
    proc page1MustBeEncrypted {} {
      if {[haveConstraint System.Data.SQLite.SEE]} then {
        return true
      }

      if {[info exists ::env(SQLite_LegacyEncryptPage1)]} then {
        return true
      }

      return false
    }
 
    proc setupDb {
            fileName {mode ""} {dateTimeFormat ""} {dateTimeKind ""} {flags ""}
            {extra ""} {qualify true} {delete true} {uri false}
            {temporary true} {varName db} {quiet false} } {
      #
      # NOTE: First, see if our caller has requested an in-memory database.