SQLite

Check-in [1e6fa95b]
Login

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

Overview
Comment:Do not attempt to run hot journal rollback tests in lock5.test with the "inmemory_journal" permutation, which cannot generate hot journals.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | unix-dotfile-fix
Files: files | file ages | folders
SHA3-256: 1e6fa95b88cace9e6cac476863d57cfd8de483f83c922ff964b77cbaee6e9ae4
User & Date: dan 2024-06-12 11:41:18
Context
2024-06-12
15:29
Omit tests that depend on sqlite3_release_memory() in lock5.test when running the memsubsys1 or memsubsys2 permutations. (Closed-Leaf check-in: 9d63033b user: dan tags: unix-dotfile-fix)
11:41
Do not attempt to run hot journal rollback tests in lock5.test with the "inmemory_journal" permutation, which cannot generate hot journals. (check-in: 1e6fa95b user: dan tags: unix-dotfile-fix)
2024-06-11
20:28
Handle the case where unix-dotfile is used with URI parameter nolock=1. (check-in: 3925a5b9 user: dan tags: unix-dotfile-fix)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/lock5.test.

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

ifcapable lock_proxy_pragmas {
  set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy
}

#####################################################################
reset_db


# 1. Create a large database using the unix-dotfile VFS
# 2. Write a large transaction to the db, so that the cache spills, but do
#    not commit it.
# 3. Make a copy of the database files on disk.
# 4. Try to read from the copy using unix-dotfile VFS. This fails because
#    the dotfile still exists, so SQLite things the database is locked.
# 5. Remove the dotfile.
# 6. Try to read the db again. This time, the old transaction is rolled
#    back and the read permitted.
#
do_test 2.dotfile.1 {
  sqlite3 db test.db -vfs unix-dotfile
  execsql {
    PRAGMA cache_size = 10;
    CREATE TABLE t1(x, y, z);
    CREATE INDEX t1x ON t1(x);
    WITH s(i) AS (
      SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
    )
    INSERT INTO t1 SELECT hex(randomblob(20)), hex(randomblob(500)), i FROM s;
  }
} {}

do_execsql_test 2.dotfile.2 {
  BEGIN;
    UPDATE t1 SET z=z+1, x=hex(randomblob(20));
}

do_test 2.dotfile.3 {
  list                            \
    [file exists test.db]         \
    [file exists test.db-journal] \
    [file exists test.db.lock]
} {1 1 1}

do_test 2.dotfile.4 {
  forcecopy test.db test.db2
  forcecopy test.db-journal test.db2-journal
  file mkdir test.db2.lock

  sqlite3 db2 test.db2 -vfs unix-dotfile
  catchsql {
    SELECT count(*) FROM t1;
  } db2
} {1 {database is locked}}

do_test 2.dotfile.5 {
  file delete test.db2.lock
  execsql {
    PRAGMA integrity_check
  } db2
} {ok}

db2 close

do_test 2.dotfile.6 {
  forcecopy test.db test.db2
  forcecopy test.db-journal test.db2-journal

  sqlite3 db2 file:test.db2?nolock=1 -vfs unix-dotfile -uri 1
  catchsql {
    SELECT count(*) FROM t1;
  } db2
} {0 1000}


finish_test









>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>




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

ifcapable lock_proxy_pragmas {
  set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy
}

#####################################################################
reset_db
if {[permutation]!="inmemory_journal"} {
  
  # 1. Create a large database using the unix-dotfile VFS
  # 2. Write a large transaction to the db, so that the cache spills, but do
  #    not commit it.
  # 3. Make a copy of the database files on disk.
  # 4. Try to read from the copy using unix-dotfile VFS. This fails because
  #    the dotfile still exists, so SQLite things the database is locked.
  # 5. Remove the dotfile.
  # 6. Try to read the db again. This time, the old transaction is rolled
  #    back and the read permitted.
  #
  do_test 2.dotfile.1 {
    sqlite3 db test.db -vfs unix-dotfile
    execsql {
      PRAGMA cache_size = 10;
      CREATE TABLE t1(x, y, z);
      CREATE INDEX t1x ON t1(x);
      WITH s(i) AS (
        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
      )
      INSERT INTO t1 SELECT hex(randomblob(20)), hex(randomblob(500)), i FROM s;
    }
  } {}
  
  do_execsql_test 2.dotfile.2 {
    BEGIN;
      UPDATE t1 SET z=z+1, x=hex(randomblob(20));
  }
  
  do_test 2.dotfile.3 {
    list                            \
      [file exists test.db]         \
      [file exists test.db-journal] \
      [file exists test.db.lock]
  } {1 1 1}
  
  do_test 2.dotfile.4 {
    forcecopy test.db test.db2
    forcecopy test.db-journal test.db2-journal
    file mkdir test.db2.lock
  
    sqlite3 db2 test.db2 -vfs unix-dotfile
    catchsql {
      SELECT count(*) FROM t1;
    } db2
  } {1 {database is locked}}
  
  do_test 2.dotfile.5 {
    file delete test.db2.lock
    execsql {
      PRAGMA integrity_check
    } db2
  } {ok}
  
  db2 close
  
  do_test 2.dotfile.6 {
    forcecopy test.db test.db2
    forcecopy test.db-journal test.db2-journal
  
    sqlite3 db2 file:test.db2?nolock=1 -vfs unix-dotfile -uri 1
    catchsql {
      SELECT count(*) FROM t1;
    } db2
  } {0 1000}
}

finish_test