Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/walsetlk_snapshot.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / walsetlk_snapshot.test` 109 lines ยท 2113 bytes Raw Blame History 1 # 2025 May 30 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # 12 # TESTRUNNER: slow 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 source $testdir/lock_common.tcl 18 set testprefix walsetlk_snapshot 19 20 ifcapable !wal {finish_test ; return } 21 ifcapable !snapshot {finish_test; return} 22 23 db close 24 testvfs tvfs -fullshm 1 25 sqlite3 db test.db -vfs tvfs 26 tvfs script sleep_callback 27 tvfs filter xSleep 28 set ::sleep_count 0 29 proc sleep_callback {args} { 30 incr ::sleep_count 31 } 32 33 do_execsql_test 1.0 { 34 PRAGMA journal_mode = wal; 35 CREATE TABLE t1(a, b); 36 INSERT INTO t1 VALUES(1, 2); 37 INSERT INTO t1 VALUES(3, 4); 38 INSERT INTO t1 VALUES(5, 6); 39 } {wal} 40 41 do_test 1.1 { 42 db eval BEGIN 43 set ::snap [sqlite3_snapshot_get db main] 44 db eval { 45 INSERT INTO t1 VALUES(7, 8); 46 COMMIT; 47 } 48 } {} 49 50 testfixture_nb myvar { 51 52 testvfs tvfs -fullshm 1 53 sqlite3 db test.db -vfs tvfs 54 tvfs script vfs_callback 55 tvfs filter {xWrite} 56 57 set ::done 0 58 proc vfs_callback {args} { 59 if {$::done==0} { 60 after 4000 61 set ::done 1 62 } 63 return "SQLITE_OK" 64 } 65 66 db eval { 67 PRAGMA wal_checkpoint; 68 } 69 70 db close 71 } 72 73 # Give the [testfixture_nb] command time to start 74 after 1000 {set xyz 1} 75 vwait xyz 76 77 db timeout 500 78 set tm [lindex [time { 79 catch { 80 db eval BEGIN 81 sqlite3_snapshot_open db main $::snap 82 } msg 83 }] 0] 84 85 do_test 1.2 { set ::msg } {SQLITE_BUSY} 86 do_test 1.3.($::tm) { expr $::tm<`2000000` } 1 87 88 do_execsql_test 1.4 { 89 SELECT * FROM t1 90 } {1 2 3 4 5 6 7 8} 91 92 sqlite3_snapshot_free $::snap 93 94 vwait myvar 95 96 # All SQLite builds should pass the tests above. SQLITE_ENABLE_SETLK_TIMEOUT=1 97 # builds do so without calling the VFS xSleep method. 98 if {$::sqlite_options(setlk_timeout)==1} { 99 do_test 1.5.1 { 100 set ::sleep_count 101 } 0 102 } else { 103 do_test 1.5.2 { 104 expr $::sleep_count>0 105 } 1 106 } 107 108 finish_test 109