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/readonly.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 / readonly.test` 58 lines ยท 1365 bytes Raw Blame History 1 # 2024 March 21 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 # This file contains tests for using databases in read-only mode on 13 # unix. 14 # 15 16 set testdir [file dirname $argv0] 17 source $testdir/tester.tcl 18 if {$tcl_platform(platform) eq "windows"} { 19 finish_test 20 return 21 } 22 source $testdir/lock_common.tcl 23 source $testdir/wal_common.tcl 24 set ::testprefix readonly 25 26 do_execsql_test 1.0 { 27 CREATE TABLE t1(a, b); 28 INSERT INTO t1 VALUES(1, 2), (3, 4), (5, 6); 29 } 30 31 db close 32 file attributes test.db -permissions r--r--r-- 33 34 sqlite3 db test.db 35 36 do_catchsql_test 1.1 { 37 INSERT INTO t1 VALUES(7, 8); 38 } {1 {attempt to write a readonly database}} 39 40 do_execsql_test 1.2 { 41 BEGIN; 42 SELECT * FROM t1; 43 } {1 2 3 4 5 6} 44 45 # The following attempts to open a read/write fd on the database 20,000 46 # times. And each time instead opens a read-only fd. At one point this 47 # was failing to reuse cached fds, causing a "too many open file-descriptors" 48 # error. 49 do_test 1.3 { 50 for {set ii 0} {$ii < 20000} {incr ii} { 51 sqlite3 db2 test.db 52 db2 close 53 } 54 set {} {} 55 } {} 56 57 58 finish_test