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_recover.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_recover.test` 104 lines ยท 2050 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_recover 19 20 ifcapable !wal {finish_test ; return } 21 # ifcapable !setlk_timeout {finish_test ; return } 22 23 do_execsql_test 1.0 { 24 PRAGMA journal_mode = wal; 25 CREATE TABLE t1(a, b); 26 INSERT INTO t1 VALUES(1, 2); 27 INSERT INTO t1 VALUES(3, 4); 28 INSERT INTO t1 VALUES(5, 6); 29 } {wal} 30 31 db_save_and_close 32 db_restore 33 34 testfixture_nb myvar { 35 36 testvfs tvfs -fullshm 1 37 sqlite3 db test.db -vfs tvfs 38 tvfs script vfs_callback 39 tvfs filter xRead 40 41 set ::done 0 42 proc vfs_callback {method file args} { 43 if {$::done==0 && [string match *wal $file]} { 44 after 4000 45 set ::done 1 46 } 47 return "SQLITE_OK" 48 } 49 50 db eval { 51 SELECT * FROM t1 52 } 53 54 db close 55 } 56 57 # Give the [testfixture_nb] command time to start 58 after 1000 {set xyz 1} 59 vwait xyz 60 61 testvfs tvfs -fullshm 1 62 sqlite3 db test.db -vfs tvfs 63 64 tvfs script sleep_callback 65 tvfs filter xSleep 66 set ::sleep_count 0 67 proc sleep_callback {args} { 68 incr ::sleep_count 69 } 70 71 sqlite3 db test.db -vfs tvfs 72 db timeout 500 73 set tm [lindex [time { 74 catch { 75 db eval {SELECT * FROM t1} 76 } msg 77 }] 0] 78 79 do_test 1.2 { set ::msg } {database is locked} 80 do_test 1.3.($::tm) { expr $::tm>400000 && $::tm<`2000000` } 1 81 82 vwait myvar 83 84 do_execsql_test 1.4 { 85 SELECT * FROM t1 86 } {1 2 3 4 5 6} 87 88 db close 89 tvfs delete 90 91 # All SQLite builds should pass the tests above. SQLITE_ENABLE_SETLK_TIMEOUT=1 92 # builds do so without calling the VFS xSleep method. 93 if {$::sqlite_options(setlk_timeout)==1} { 94 do_test 1.5.1 { 95 set ::sleep_count 96 } 0 97 } else { 98 do_test 1.5.2 { 99 expr $::sleep_count>0 100 } 1 101 } 102 103 finish_test 104