# 2002 March 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the PRAGMA command. # # $Id: pragma.test,v 1.4 2003/02/15 23:09:17 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Delete the preexisting database to avoid the special setup # that the "all.test" script does. # db close file delete test.db set DB [sqlite db test.db] do_test pragma-1.1 { execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {2000 2000 1 1} do_test pragma-1.2 { execsql { PRAGMA cache_size=1234; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {1234 2000 1 1} do_test pragma-1.3 { db close sqlite db test.db execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {2000 2000 1 1} do_test pragma-1.4 { execsql { PRAGMA synchronous=OFF; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {2000 2000 0 1} do_test pragma-1.5 { execsql { PRAGMA cache_size=4321; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {4321 2000 0 1} do_test pragma-1.6 { execsql { PRAGMA synchronous=ON; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {4321 2000 1 1} do_test pragma-1.7 { db close sqlite db test.db execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {2000 2000 1 1} do_test pragma-1.8 { execsql { PRAGMA default_synchronous=OFF; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {2000 2000 0 0} do_test pragma-1.9 { execsql { PRAGMA default_cache_size=123; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 0 0} do_test pragma-1.10 { db close set ::DB [sqlite db test.db] execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 0 0} do_test pragma-1.11 { execsql { PRAGMA synchronous=NORMAL; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 1 0} do_test pragma-1.12 { execsql { PRAGMA synchronous=FULL; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 2 0} do_test pragma-1.13 { db close set ::DB [sqlite db test.db] execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 0 0} do_test pragma-1.14 { execsql { PRAGMA default_synchronous=FULL; PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 2 2} do_test pragma-1.15 { db close set ::DB [sqlite db test.db] execsql { PRAGMA cache_size; PRAGMA default_cache_size; PRAGMA synchronous; PRAGMA default_synchronous; } } {123 123 2 2} do_test pragma-2.1 { execsql { PRAGMA show_datatypes=on; PRAGMA empty_result_callbacks=off; } sqlite_datatypes $::DB {SELECT * FROM sqlite_master} } {} do_test pragma-2.2 { execsql { PRAGMA empty_result_callbacks=on; } sqlite_datatypes $::DB {SELECT * FROM sqlite_master} } {text text text integer text} do_test pragma-2.3 { execsql { CREATE TABLE t1( a INTEGER, b TEXT, c WHATEVER, d CLOB, e BLOB, f VARCHAR(123), g nVaRcHaR(432) ); } sqlite_datatypes $::DB {SELECT * FROM t1} } {INTEGER TEXT WHATEVER CLOB BLOB VARCHAR(123) nVaRcHaR(432)} do_test pragma-2.4 { sqlite_datatypes $::DB { SELECT 1, 'hello', NULL } } {NUMERIC TEXT TEXT} do_test pragma-2.5 { sqlite_datatypes $::DB { SELECT 1+2 AS X, 'hello' || 5 AS Y, NULL AS Z } } {NUMERIC TEXT TEXT} do_test pragma-2.6 { execsql { CREATE VIEW v1 AS SELECT a+b, b||c, * FROM t1; } sqlite_datatypes $::DB {SELECT * FROM v1} } {NUMERIC TEXT INTEGER TEXT WHATEVER CLOB BLOB VARCHAR(123) nVaRcHaR(432)} do_test pragma-2.7 { sqlite_datatypes $::DB { SELECT d,e FROM t1 UNION SELECT a,c FROM t1 } } {INTEGER WHATEVER} do_test pragma-2.8 { sqlite_datatypes $::DB { SELECT d,e FROM t1 EXCEPT SELECT c,e FROM t1 } } {WHATEVER BLOB} do_test pragma-2.9 { sqlite_datatypes $::DB { SELECT d,e FROM t1 INTERSECT SELECT c,e FROM t1 } } {WHATEVER BLOB} do_test pragma-2.10 { sqlite_datatypes $::DB { SELECT d,e FROM t1 INTERSECT SELECT c,e FROM v1 } } {WHATEVER BLOB} finish_test