summaryrefslogtreecommitdiff
path: root/test/pragma.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/pragma.test')
-rw-r--r--test/pragma.test109
1 files changed, 109 insertions, 0 deletions
diff --git a/test/pragma.test b/test/pragma.test
index bb10327..3c8d23a 100644
--- a/test/pragma.test
+++ b/test/pragma.test
@@ -16,6 +16,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+set testprefix pragma
# Do not use a codec for tests in this file, as the database file is
# manipulated directly using tcl scripts (using the [hexio_write] command).
@@ -40,6 +41,9 @@ do_not_use_codec
# pragma-15.*: Test that the value set using the cache_size pragma is not
# reset when the schema is reloaded.
# pragma-16.*: Test proxy locking
+# pragma-20.*: Test data_store_directory.
+# pragma-22.*: Test that "PRAGMA [db].integrity_check" respects the "db"
+# directive - if it is present.
#
ifcapable !pragma {
@@ -1510,5 +1514,110 @@ do_test pragma-19.5 {
file tail [lindex [execsql {PRAGMA filename}] 0]
} {test.db}
+if {$tcl_platform(platform)=="windows"} {
+# Test data_store_directory pragma
+#
+db close
+sqlite3 db test.db
+file mkdir data_dir
+do_test pragma-20.1 {
+ catchsql {PRAGMA data_store_directory}
+} {0 {}}
+do_test pragma-20.2 {
+ set pwd [string map {' ''} [file nativename [get_pwd]]]
+ catchsql "PRAGMA data_store_directory='$pwd';"
+} {0 {}}
+do_test pragma-20.3 {
+ catchsql {PRAGMA data_store_directory}
+} [list 0 [list [file nativename [get_pwd]]]]
+do_test pragma-20.4 {
+ set pwd [string map {' ''} [file nativename \
+ [file join [get_pwd] data_dir]]]
+ catchsql "PRAGMA data_store_directory='$pwd';"
+} {0 {}}
+do_test pragma-20.5 {
+ sqlite3 db2 test2.db
+ catchsql "PRAGMA database_list;" db2
+} [list 0 [list 0 main [file nativename \
+ [file join [get_pwd] data_dir test2.db]]]]
+catch {db2 close}
+do_test pragma-20.6 {
+ sqlite3 db2 [file join [get_pwd] test2.db]
+ catchsql "PRAGMA database_list;" db2
+} [list 0 [list 0 main [file nativename \
+ [file join [get_pwd] test2.db]]]]
+catch {db2 close}
+do_test pragma-20.7 {
+ catchsql "PRAGMA data_store_directory='';"
+} {0 {}}
+do_test pragma-20.8 {
+ catchsql {PRAGMA data_store_directory}
+} {0 {}}
+
+forcedelete data_dir
+} ;# endif windows
+
+do_test 21.1 {
+ # Create a corrupt database in testerr.db. And a non-corrupt at test.db.
+ #
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 1);
+ }
+ for {set i 0} {$i < 10} {incr i} {
+ execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 }
+ }
+ db close
+ forcecopy test.db testerr.db
+ hexio_write testerr.db 15000 [string repeat 55 100]
+} {100}
+
+set mainerr {*** in database main ***
+Multiple uses for byte 672 of page 15}
+set auxerr {*** in database aux ***
+Multiple uses for byte 672 of page 15}
+
+do_test 22.2 {
+ catch { db close }
+ sqlite3 db testerr.db
+ execsql { PRAGMA integrity_check }
+} [list $mainerr]
+
+do_test 22.3.1 {
+ catch { db close }
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'testerr.db' AS 'aux';
+ PRAGMA integrity_check;
+ }
+} [list $auxerr]
+do_test 22.3.2 {
+ execsql { PRAGMA main.integrity_check; }
+} {ok}
+do_test 22.3.3 {
+ execsql { PRAGMA aux.integrity_check; }
+} [list $auxerr]
+
+do_test 22.4.1 {
+ catch { db close }
+ sqlite3 db testerr.db
+ execsql {
+ ATTACH 'test.db' AS 'aux';
+ PRAGMA integrity_check;
+ }
+} [list $mainerr]
+do_test 22.4.2 {
+ execsql { PRAGMA main.integrity_check; }
+} [list $mainerr]
+do_test 22.4.3 {
+ execsql { PRAGMA aux.integrity_check; }
+} {ok}
finish_test
+
+