github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/queryonly.test (about) 1 # 2013-07-11 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 # This file implements regression tests for SQLite library. 12 # 13 # This file tests the "query_only" pragma. 14 # 15 16 set testdir [file dirname $argv0] 17 source $testdir/tester.tcl 18 19 do_execsql_test queryonly-1.1 { 20 CREATE TABLE t1(a); 21 INSERT INTO t1 VALUES(123),(456); 22 SELECT a FROM t1 ORDER BY a; 23 } {123 456} 24 do_execsql_test queryonly-1.2 { 25 PRAGMA query_only; 26 } {0} 27 do_execsql_test queryonly-1.3 { 28 PRAGMA query_only=ON; 29 PRAGMA query_only; 30 } {1} 31 do_test queryonly-1.4 { 32 catchsql {INSERT INTO t1 VALUES(789);} 33 } {1 {attempt to write a readonly database}} 34 do_test queryonly-1.5 { 35 catchsql {DELETE FROM t1;} 36 } {1 {attempt to write a readonly database}} 37 do_test queryonly-1.6 { 38 catchsql {UPDATE t1 SET a=a+1;} 39 } {1 {attempt to write a readonly database}} 40 do_test queryonly-1.7 { 41 catchsql {CREATE TABLE t2(b);} 42 } {1 {attempt to write a readonly database}} 43 do_test queryonly-1.8 { 44 catchsql {CREATE INDEX t1a ON t1(a);} 45 } {1 {attempt to write a readonly database}} 46 do_test queryonly-1.9 { 47 catchsql {DROP TABLE t1;} 48 } {1 {attempt to write a readonly database}} 49 do_test queryonly-1.10 { 50 catchsql {ANALYZE;} 51 } {1 {attempt to write a readonly database}} 52 do_execsql_test queryonly-1.11 { 53 SELECT a FROM t1 ORDER BY a; 54 } {123 456} 55 56 do_execsql_test queryonly-2.2 { 57 PRAGMA query_only; 58 } {1} 59 do_execsql_test queryonly-2.3 { 60 PRAGMA query_only=OFF; 61 PRAGMA query_only; 62 } {0} 63 do_execsql_test queryonly-2.4 { 64 INSERT INTO t1 VALUES(789); 65 SELECT a FROM t1 ORDER BY a; 66 } {123 456 789} 67 do_execsql_test queryonly-2.5 { 68 UPDATE t1 SET a=a+1; 69 SELECT a FROM t1 ORDER BY a; 70 } {124 457 790} 71 72 finish_test