aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/csv01.test2
-rw-r--r--test/dbstatus.test61
-rw-r--r--test/json101.test29
-rw-r--r--test/minmax.test14
-rw-r--r--test/releasetest.tcl1
-rw-r--r--test/shell1.test1
-rw-r--r--test/tclsqlite.test2
-rw-r--r--test/tester.tcl1
-rw-r--r--test/trace3.test233
-rw-r--r--test/vacuummem.test14
-rw-r--r--test/walcrash4.test1
11 files changed, 324 insertions, 35 deletions
diff --git a/test/csv01.test b/test/csv01.test
index a6fff81c3..8151c4771 100644
--- a/test/csv01.test
+++ b/test/csv01.test
@@ -13,7 +13,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-set testprefix closure01
+set testprefix csv01
ifcapable !vtab||!cte { finish_test ; return }
diff --git a/test/dbstatus.test b/test/dbstatus.test
index 00c5deabd..711d66ebb 100644
--- a/test/dbstatus.test
+++ b/test/dbstatus.test
@@ -379,35 +379,40 @@ foreach ::lookaside_buffer_size {0 64 120} {
# The following tests focus on DBSTATUS_CACHE_USED_SHARED
#
ifcapable shared_cache {
- proc do_cacheused_test {tn db res} {
- set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]
- set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]
- set cu [lindex $cu 1]
- set pcu [lindex $pcu 1]
- uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"]
- }
- reset_db
- sqlite3 db file:test.db?cache=shared
-
- do_execsql_test 4.0 {
- CREATE TABLE t1(a, b, c);
- INSERT INTO t1 VALUES(1, 2, 3);
- }
- do_cacheused_test 4.0.1 db { 4568 4568 }
- do_execsql_test 4.1 {
- CREATE TEMP TABLE tt(a, b, c);
- INSERT INTO tt VALUES(1, 2, 3);
+ if {[permutation]=="memsys3"
+ || [permutation]=="memsys5"
+ || $::tcl_platform(os)=="Linux"} {
+ proc do_cacheused_test {tn db res} {
+ set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]
+ set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]
+ set cu [lindex $cu 1]
+ set pcu [lindex $pcu 1]
+ uplevel [list do_test $tn [list list $cu $pcu] "#/$res/"]
+ }
+ reset_db
+ sqlite3 db file:test.db?cache=shared
+
+ do_execsql_test 4.0 {
+ PRAGMA auto_vacuum=NONE;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+ }
+ do_cacheused_test 4.0.1 db { 4568 4568 }
+ do_execsql_test 4.1 {
+ CREATE TEMP TABLE tt(a, b, c);
+ INSERT INTO tt VALUES(1, 2, 3);
+ }
+ do_cacheused_test 4.1.1 db { 9000 9000 }
+
+ sqlite3 db2 file:test.db?cache=shared
+ do_cacheused_test 4.2.1 db2 { 4568 2284 }
+ do_cacheused_test 4.2.2 db { 9000 6716 }
+ db close
+ do_cacheused_test 4.2.3 db2 { 4568 4568 }
+ sqlite3 db file:test.db?cache=shared
+ do_cacheused_test 4.2.4 db2 { 4568 2284 }
+ db2 close
}
- do_cacheused_test 4.1.1 db { 9000 9000 }
-
- sqlite3 db2 file:test.db?cache=shared
- do_cacheused_test 4.2.1 db2 { 4568 2284 }
- do_cacheused_test 4.2.2 db { 9000 6716 }
- db close
- do_cacheused_test 4.2.3 db2 { 4568 4568 }
- sqlite3 db file:test.db?cache=shared
- do_cacheused_test 4.2.4 db2 { 4568 2284 }
- db2 close
}
finish_test
diff --git a/test/json101.test b/test/json101.test
index 9b780a379..3ee007c1c 100644
--- a/test/json101.test
+++ b/test/json101.test
@@ -356,5 +356,34 @@ do_execsql_test json-8.2 {
SELECT a=json_extract(b,'$[0]') FROM t8;
} {1}
+# The json_quote() function transforms an SQL value into a JSON value.
+# String values are quoted and interior quotes are escaped. NULL values
+# are rendered as the unquoted string "null".
+#
+do_execsql_test json-9.1 {
+ SELECT json_quote('abc"xyz');
+} {{"abc\"xyz"}}
+do_execsql_test json-9.2 {
+ SELECT json_quote(3.14159);
+} {3.14159}
+do_execsql_test json-9.3 {
+ SELECT json_quote(12345);
+} {12345}
+do_execsql_test json-9.4 {
+ SELECT json_quote(null);
+} {"null"}
+do_catchsql_test json-9.5 {
+ SELECT json_quote(x'30313233');
+} {1 {JSON cannot hold BLOB values}}
+do_catchsql_test json-9.6 {
+ SELECT json_quote(123,456)
+} {1 {wrong number of arguments to function json_quote()}}
+do_catchsql_test json-9.7 {
+ SELECT json_quote()
+} {1 {wrong number of arguments to function json_quote()}}
+
+
+
+
finish_test
diff --git a/test/minmax.test b/test/minmax.test
index fb9bbb383..04a3f06df 100644
--- a/test/minmax.test
+++ b/test/minmax.test
@@ -628,5 +628,19 @@ do_test_13_noopt 13.7 {
SELECT min(c), count(c) FROM t1 WHERE a='a';
} {1 5}
+# 2016-07-26. https://www.sqlite.org/src/info/a0bac8b3c3d1bb75
+# Incorrect result on a min() query after a CREATE INDEX.
+#
+do_execsql_test 14.1 {
+ CREATE TABLE t14(a INTEGER, b INTEGER);
+ INSERT INTO t14(a,b) VALUES(100,2),(200,2),(300,2),(400,1),(500,2);
+ SELECT min(a) FROM t14 WHERE b='2' AND a>'50';
+} {100}
+do_execsql_test 14.2 {
+ CREATE INDEX t14ba ON t14(b,a);
+ SELECT min(a) FROM t14 WHERE b='2' AND a>'50';
+} {100}
+
+
finish_test
diff --git a/test/releasetest.tcl b/test/releasetest.tcl
index 2961fc385..e13a3d734 100644
--- a/test/releasetest.tcl
+++ b/test/releasetest.tcl
@@ -120,7 +120,6 @@ array set ::Configs [strip_comments {
-DSQLITE_ENABLE_FTS3=1
-DSQLITE_ENABLE_RTREE=1
-DSQLITE_ENABLE_MEMSYS5=1
- -DSQLITE_ENABLE_MEMSYS3=1
-DSQLITE_ENABLE_COLUMN_METADATA=1
-DSQLITE_ENABLE_STAT4
-DSQLITE_ENABLE_HIDDEN_COLUMNS
diff --git a/test/shell1.test b/test/shell1.test
index 498cd64a9..03c2dee1d 100644
--- a/test/shell1.test
+++ b/test/shell1.test
@@ -870,6 +870,7 @@ do_test shell1-5.0 {
if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} {
continue
}
+ if {$i>=0xE0 && $tcl_platform(os)=="OpenBSD"} continue
set hex [format %02X $i]
set char [subst \\x$hex]; set oldChar $char
set escapes [list]
diff --git a/test/tclsqlite.test b/test/tclsqlite.test
index 767dd01be..bdb0fc56d 100644
--- a/test/tclsqlite.test
+++ b/test/tclsqlite.test
@@ -34,7 +34,7 @@ do_test tcl-1.1 {
do_test tcl-1.2 {
set v [catch {db bogus} msg]
lappend v $msg
-} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, transaction, unlock_notify, update_hook, version, or wal_hook}}
+} {1 {bad option "bogus": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, trace_v2, transaction, unlock_notify, update_hook, version, or wal_hook}}
do_test tcl-1.2.1 {
set v [catch {db cache bogus} msg]
lappend v $msg
diff --git a/test/tester.tcl b/test/tester.tcl
index f258425c4..8e470cc9e 100644
--- a/test/tester.tcl
+++ b/test/tester.tcl
@@ -373,6 +373,7 @@ proc do_not_use_codec {} {
set ::do_not_use_codec 1
reset_db
}
+unset -nocomplain do_not_use_codec
# Return true if the "reserved_bytes" integer on database files is non-zero.
#
diff --git a/test/trace3.test b/test/trace3.test
new file mode 100644
index 000000000..0809759d8
--- /dev/null
+++ b/test/trace3.test
@@ -0,0 +1,233 @@
+# 2016 July 14
+#
+# 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. The focus of
+# this test file is the "sqlite3_trace_v2()" and "sqlite3_expanded_sql()"
+# APIs.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+ifcapable !trace { finish_test ; return }
+set ::testprefix trace3
+
+proc trace_v2_error { args } {
+ lappend ::stmtlist(error) [string trim $args]
+ error "trace error"; # this will be ignored.
+}
+proc trace_v2_record { args } {
+ lappend ::stmtlist(record) [string trim $args]
+}
+proc trace_v2_nop { args } {}; # do nothing.
+
+do_test trace3-1.0 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,NULL);
+ INSERT INTO t1 VALUES(2,-1);
+ INSERT INTO t1 VALUES(3,0);
+ INSERT INTO t1 VALUES(4,1);
+ INSERT INTO t1 VALUES(5,-2147483648);
+ INSERT INTO t1 VALUES(6,2147483647);
+ INSERT INTO t1 VALUES(7,-9223372036854775808);
+ INSERT INTO t1 VALUES(8,9223372036854775807);
+ INSERT INTO t1 VALUES(9,-1.0);
+ INSERT INTO t1 VALUES(10,0.0);
+ INSERT INTO t1 VALUES(11,1.0);
+ INSERT INTO t1 VALUES(12,'');
+ INSERT INTO t1 VALUES(13,'1');
+ INSERT INTO t1 VALUES(14,'one');
+ INSERT INTO t1 VALUES(15,x'abcd0123');
+ INSERT INTO t1 VALUES(16,x'4567cdef');
+ }
+} {}
+
+do_test trace3-1.1 {
+ set rc [catch {db trace_v2 1 2 3} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db trace_v2 ?CALLBACK? ?MASK?"}}
+do_test trace3-1.2 {
+ set rc [catch {db trace_v2 1 bad} msg]
+ lappend rc $msg
+} {1 {bad trace type "bad": must be statement, profile, row, or close}}
+
+do_test trace3-2.1 {
+ db trace_v2 trace_v2_nop
+ db trace_v2
+} {trace_v2_nop}
+
+do_test trace3-3.1 {
+ unset -nocomplain ::stmtlist
+ db trace_v2 trace_v2_nop
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ array get ::stmtlist
+} {}
+do_test trace3-3.2 {
+ set ::stmtlist(error) {}
+ db trace_v2 trace_v2_error
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(error)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+do_test trace3-3.3 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+do_test trace3-3.4 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record statement
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+do_test trace3-3.5 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 1
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ \{SELECT a, b FROM t1 ORDER BY a;\}\}$/}
+
+do_test trace3-4.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record profile
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ -?\d+\}$/}
+do_test trace3-4.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 2
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} {/^\{-?\d+ -?\d+\}$/}
+
+do_test trace3-5.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record row
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^[string trim [string repeat {\d+ } 16]]\$/"
+do_test trace3-5.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 4
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^[string trim [string repeat {\d+ } 16]]\$/"
+
+do_test trace3-6.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record {profile row}
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^[string trim [string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/"
+do_test trace3-6.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record {statement profile row}
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ set ::stmtlist(record)
+} "/^\\\{-?\\d+ \\\{SELECT a, b FROM t1 ORDER BY a;\\\}\\\} [string trim \
+[string repeat {-?\d+ } 16]] \\\{-?\\d+ -?\\d+\\\}\$/"
+
+do_test trace3-7.1 {
+ set DB [sqlite3_connection_pointer db]
+
+ set STMT [sqlite3_prepare_v2 $DB \
+ "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 TAIL]
+} {/^[0-9A-Fa-f]+$/}
+
+do_test trace3-8.1 {
+ list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = NULL ORDER BY a;}}
+do_test trace3-8.2 {
+ list [sqlite3_bind_int $STMT 1 123] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}
+do_test trace3-8.3 {
+ list [sqlite3_bind_int64 $STMT 1 123] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}
+do_test trace3-8.4 {
+ list [sqlite3_bind_text $STMT 1 "some string" 11] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 'some string' ORDER BY a;}}
+do_test trace3-8.5 {
+ list [sqlite3_bind_text $STMT 1 "some 'bad' string" 17] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 'some ''bad'' string' ORDER BY a;}}
+do_test trace3-8.6 {
+ list [sqlite3_bind_double $STMT 1 123] [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 123.0 ORDER BY a;}}
+do_test trace3-8.7 {
+ list [sqlite3_bind_text16 $STMT 1 \
+ [encoding convertto unicode hi\000yall\000] 16] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = 'hi' ORDER BY a;}}
+do_test trace3-8.8 {
+ list [sqlite3_bind_blob $STMT 1 "\x12\x34\x56" 3] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}}
+do_test trace3-8.9 {
+ list [sqlite3_bind_blob $STMT 1 "\xAB\xCD\xEF" 3] \
+ [sqlite3_expanded_sql $STMT]
+} {{} {SELECT a, b FROM t1 WHERE b = x'abcdef' ORDER BY a;}}
+
+do_test trace3-9.1 {
+ sqlite3_finalize $STMT
+} {SQLITE_OK}
+
+do_test trace3-10.1 {
+ db trace_v2 ""
+ db trace_v2
+} {}
+do_test trace3-10.2 {
+ unset -nocomplain ::stmtlist
+ db trace_v2 "" {statement profile row}
+ execsql {
+ SELECT a, b FROM t1 ORDER BY a;
+ }
+ array get ::stmtlist
+} {}
+
+do_test trace3-11.1 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record close
+ db close
+ set ::stmtlist(record)
+} {/^-?\d+$/}
+
+reset_db
+
+do_test trace3-11.2 {
+ set ::stmtlist(record) {}
+ db trace_v2 trace_v2_record 8
+ db close
+ set ::stmtlist(record)
+} {/^-?\d+$/}
+
+finish_test
diff --git a/test/vacuummem.test b/test/vacuummem.test
index 967e28cec..b214c83b3 100644
--- a/test/vacuummem.test
+++ b/test/vacuummem.test
@@ -17,6 +17,12 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix vacuummem
+if {[permutation]=="memsubsys1"} {
+ finish_test
+ return
+}
+
+
proc memory_used {} {
set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1]
lindex $stat 1
@@ -35,20 +41,20 @@ do_execsql_test 1.0 {
CREATE INDEX t1b ON t1(b);
CREATE INDEX t1c ON t1(c);
}
+set ans "#/[memory_used]/"
-do_test 1.1 { memory_used } {#/2300000/}
+do_test 1.1 { memory_used } $ans
do_execsql_test 1.2 VACUUM
-do_test 1.3 { memory_used } {#/2300000/}
+do_test 1.3 { memory_used } $ans
do_execsql_test 1.4 {
SELECT count(*) FROM t1 WHERE +a IS NOT NULL
} {100000}
-do_test 1.5 { memory_used } {#/2300000/}
+do_test 1.5 { memory_used } $ans
finish_test
-
diff --git a/test/walcrash4.test b/test/walcrash4.test
index 3abc16d1e..80839b39e 100644
--- a/test/walcrash4.test
+++ b/test/walcrash4.test
@@ -17,6 +17,7 @@ source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
ifcapable !wal {finish_test ; return }
set testprefix walcrash4
+do_not_use_codec
#-------------------------------------------------------------------------
# At one point, if "PRAGMA synchronous=full" is set and the platform