mirror of
https://github.com/status-im/sqlcipher.git
synced 2026-08-30 22:11:14 +00:00
Merge sqlite-release(3.34.1) into prerelease-integration
This commit is contained in:
+4
-4
@@ -72,10 +72,10 @@ do_execsql_test affinity3-200 {
|
||||
CREATE TABLE mzed AS SELECT * FROM idmap;
|
||||
}
|
||||
|
||||
do_execsql_test affinity3-210 {
|
||||
PRAGMA automatic_index=ON;
|
||||
SELECT * FROM data JOIN idmap USING(id);
|
||||
} {1 abc a 4 xyz e}
|
||||
#do_execsql_test affinity3-210 {
|
||||
#PRAGMA automatic_index=ON;
|
||||
#SELECT * FROM data JOIN idmap USING(id);
|
||||
#} {1 abc a 4 xyz e}
|
||||
do_execsql_test affinity3-220 {
|
||||
SELECT * FROM data JOIN mzed USING(id);
|
||||
} {1 abc a 4 xyz e}
|
||||
|
||||
@@ -677,4 +677,39 @@ do_execsql_test 22.1 {
|
||||
SELECT * FROM t1;
|
||||
} {1 2 78 a b 78}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
db collate compare64 compare64
|
||||
|
||||
do_execsql_test 23.1 {
|
||||
CREATE TABLE gigo(a text);
|
||||
CREATE TABLE idx(x text COLLATE compare64);
|
||||
CREATE VIEW v1 AS SELECT * FROM idx WHERE x='abc';
|
||||
}
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
|
||||
do_execsql_test 23.2 {
|
||||
alter table gigo rename to ggiiggoo;
|
||||
alter table idx rename to idx2;
|
||||
}
|
||||
|
||||
do_execsql_test 23.3 {
|
||||
SELECT sql FROM sqlite_master;
|
||||
} {
|
||||
{CREATE TABLE "ggiiggoo"(a text)}
|
||||
{CREATE TABLE "idx2"(x text COLLATE compare64)}
|
||||
{CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE x='abc'}
|
||||
}
|
||||
|
||||
do_execsql_test 23.4 {
|
||||
ALTER TABLE idx2 RENAME x TO y;
|
||||
SELECT sql FROM sqlite_master;
|
||||
} {
|
||||
{CREATE TABLE "ggiiggoo"(a text)}
|
||||
{CREATE TABLE "idx2"(y text COLLATE compare64)}
|
||||
{CREATE VIEW v1 AS SELECT * FROM "idx2" WHERE y='abc'}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
+48
-1
@@ -600,5 +600,52 @@ do_execsql_test 25.1 {
|
||||
# ALTER TABLE t2 RENAME COLUMN a TO aaa;
|
||||
#}
|
||||
|
||||
finish_test
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 26.1 {
|
||||
CREATE TABLE t1(x);
|
||||
|
||||
CREATE TABLE t3(y);
|
||||
CREATE TABLE t4(z);
|
||||
|
||||
CREATE TRIGGER tr1 INSERT ON t3 BEGIN
|
||||
UPDATE t3 SET y=z FROM (SELECT z FROM t4);
|
||||
END;
|
||||
|
||||
CREATE TRIGGER tr2 INSERT ON t3 BEGIN
|
||||
UPDATE t3 SET y=abc FROM (SELECT x AS abc FROM t1);
|
||||
END;
|
||||
}
|
||||
|
||||
do_execsql_test 26.2 {
|
||||
ALTER TABLE t1 RENAME TO t2;
|
||||
}
|
||||
|
||||
do_execsql_test 26.3 {
|
||||
ALTER TABLE t2 RENAME x TO xx;
|
||||
}
|
||||
|
||||
do_execsql_test 26.4 {
|
||||
SELECT sql FROM sqlite_schema WHERE name='tr2'
|
||||
} {
|
||||
{CREATE TRIGGER tr2 INSERT ON t3 BEGIN
|
||||
UPDATE t3 SET y=abc FROM (SELECT xx AS abc FROM "t2");
|
||||
END}
|
||||
}
|
||||
|
||||
# 2020-11-02 OSSFuzz
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 26.5 {
|
||||
CREATE TABLE t1(xx);
|
||||
CREATE TRIGGER xx INSERT ON t1 BEGIN
|
||||
UPDATE t1 SET xx=xx FROM(SELECT xx);
|
||||
END;
|
||||
} {}
|
||||
do_catchsql_test 26.6 {
|
||||
ALTER TABLE t1 RENAME TO t2;
|
||||
} {1 {error in trigger xx: ambiguous column name: xx}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -23,6 +23,16 @@ ifcapable !stat4 {
|
||||
return
|
||||
}
|
||||
|
||||
# This test cannot be run with the sqlite3_prepare() permutation, as it
|
||||
# tests that stat4 data can be used to influence the plans of queries
|
||||
# based on bound variable values. And this is not possible when using
|
||||
# sqlite3_prepare() - as queries cannot be internally re-prepared after
|
||||
# binding values are available.
|
||||
if {[permutation]=="prepare"} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Test Organization:
|
||||
#
|
||||
|
||||
+4
-4
@@ -75,10 +75,10 @@ do_execsql_test atof1-2.30 {
|
||||
CREATE INDEX i1 ON t1(a);
|
||||
SELECT count(*) FROM t1 WHERE substr(a,',');
|
||||
} {1}
|
||||
|
||||
|
||||
|
||||
|
||||
# 2020-08-27 OSSFuzz find related to the above.
|
||||
do_execsql_test atof1-2.40 {
|
||||
SELECT randomblob(0) - 1;
|
||||
} {-1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ for {set i 0} {$i < 9} {incr i} {
|
||||
" [string map {"\n " "\n"} "
|
||||
QUERY PLAN
|
||||
|--SCAN TABLE t$t AS o USING COVERING INDEX sqlite_autoindex_t${t}_1
|
||||
`--CORRELATED SCALAR SUBQUERY
|
||||
`--CORRELATED SCALAR SUBQUERY xxxxxx
|
||||
`--SEARCH TABLE t$t AS i USING INTEGER PRIMARY KEY (rowid=?)
|
||||
"]
|
||||
}
|
||||
|
||||
@@ -131,5 +131,41 @@ do_multiclient_test tn {
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Check that even if the busy-handler fails (returns zero) within a
|
||||
# call to sqlite3_prepare() (or _v2(), or _v3()), it is still invoked
|
||||
# the next time an SQLITE_BUSY is encountered.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
code1 {
|
||||
set ::busy_called 0
|
||||
proc busy {args} {
|
||||
if {$::busy_called} { return 1 }
|
||||
set ::busy_called 1
|
||||
return 0
|
||||
}
|
||||
db busy busy
|
||||
}
|
||||
|
||||
do_test 3.$tn.1 {
|
||||
sql2 {
|
||||
CREATE TABLE t1(x);
|
||||
BEGIN EXCLUSIVE;
|
||||
INSERT INTO t1 VALUES('x');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 3.$tn.2 {
|
||||
set ::busy_called 0
|
||||
list [catch { sql1 { SELECT * FROM t1 } } msg] $::busy_called
|
||||
} {1 1}
|
||||
|
||||
do_test 3.$tn.3 {
|
||||
set ::busy_called 0
|
||||
list [catch { sql1 { SELECT * FROM t1 } } msg] $::busy_called
|
||||
} {1 1}
|
||||
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
# 2020-11-17
|
||||
#
|
||||
# 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 tests for CARRAY extension
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix carray01
|
||||
|
||||
ifcapable !vtab {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
load_static_extension db carray
|
||||
|
||||
# Parameter $stmt must be a prepared statement created using
|
||||
# the sqlite3_prepare_v2 command and with parameters fullly bound.
|
||||
# This routine simply runs the statement, gathers the result, and
|
||||
# returns a list containing the result.
|
||||
#
|
||||
# If the optional second argument is true, then the stmt is finalized
|
||||
# after it is run.
|
||||
#
|
||||
proc run_stmt {stmt {finalizeFlag 0}} {
|
||||
set r {}
|
||||
while {[sqlite3_step $stmt]=="SQLITE_ROW"} {
|
||||
for {set i 0} {$i<[sqlite3_data_count $stmt]} {incr i} {
|
||||
lappend r [sqlite3_column_text $stmt $i]
|
||||
}
|
||||
}
|
||||
if {$finalizeFlag} {
|
||||
sqlite3_finalize $stmt
|
||||
} else {
|
||||
sqlite3_reset $stmt
|
||||
}
|
||||
return $r
|
||||
}
|
||||
|
||||
do_test 100 {
|
||||
set STMT [sqlite3_prepare_v2 db {SELECT 5 IN carray(?3)} -1]
|
||||
sqlite3_carray_bind $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 101 {
|
||||
sqlite3_carray_bind -static $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 110 {
|
||||
sqlite3_carray_bind $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 120 {
|
||||
sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 130 {
|
||||
sqlite3_carray_bind -int64 $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 131 {
|
||||
sqlite3_carray_bind -int64 -static $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 140 {
|
||||
sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 150 {
|
||||
sqlite3_carray_bind -double $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 160 {
|
||||
sqlite3_carray_bind -double $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {1}
|
||||
do_test 170 {
|
||||
sqlite3_carray_bind -text -static $STMT 3 1 2 3 4 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 180 {
|
||||
sqlite3_carray_bind -text -transient $STMT 3 1 2 3 4 5 6 7
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
do_test 190 {
|
||||
sqlite3_carray_bind $STMT 3
|
||||
run_stmt $STMT 0
|
||||
} {0}
|
||||
|
||||
sqlite3_finalize $STMT
|
||||
|
||||
finish_test
|
||||
@@ -474,5 +474,14 @@ ifcapable utf16 {
|
||||
} 1
|
||||
}
|
||||
|
||||
reset_db
|
||||
do_execsql_test cast-9.0 {
|
||||
CREATE TABLE t0(c0);
|
||||
INSERT INTO t0(c0) VALUES (0);
|
||||
CREATE VIEW v1(c0, c1) AS
|
||||
SELECT CAST(0.0 AS NUMERIC), COUNT(*) OVER () FROM t0;
|
||||
SELECT v1.c0 FROM v1, t0 WHERE v1.c0=0;
|
||||
} {0.0}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+25
-19
@@ -40,7 +40,7 @@ do_test check-1.3 {
|
||||
catchsql {
|
||||
INSERT INTO t1 VALUES(6,7);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: x<5}}
|
||||
do_test check-1.4 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
@@ -50,7 +50,7 @@ do_test check-1.5 {
|
||||
catchsql {
|
||||
INSERT INTO t1 VALUES(4,3);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: y>x}}
|
||||
do_test check-1.6 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
@@ -87,7 +87,7 @@ do_test check-1.12 {
|
||||
catchsql {
|
||||
UPDATE t1 SET x=7 WHERE x==2
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: x<5}}
|
||||
do_test check-1.13 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
@@ -97,7 +97,7 @@ do_test check-1.14 {
|
||||
catchsql {
|
||||
UPDATE t1 SET x=5 WHERE x==2
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: x<5}}
|
||||
do_test check-1.15 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
@@ -186,7 +186,7 @@ do_test check-2.11 {
|
||||
catchsql {
|
||||
INSERT INTO t2b VALUES('xyzzy','hi',5);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2b}}
|
||||
} {1 {CHECK constraint failed: typeof(coalesce(x,0))=='integer'}}
|
||||
do_test check-2.12 {
|
||||
execsql {
|
||||
CREATE TABLE t2c(
|
||||
@@ -271,7 +271,7 @@ do_test check-3.9 {
|
||||
catchsql {
|
||||
INSERT INTO t3 VALUES(111,222,333);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t3}}
|
||||
} {1 {CHECK constraint failed: t3.x<25}}
|
||||
|
||||
do_test check-4.1 {
|
||||
execsql {
|
||||
@@ -313,7 +313,10 @@ do_test check-4.6 {
|
||||
catchsql {
|
||||
UPDATE t4 SET x=0, y=1;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t4}}
|
||||
} {1 {CHECK constraint failed: x+y==11
|
||||
OR x*y==12
|
||||
OR x/y BETWEEN 5 AND 8
|
||||
OR -x==y+10}}
|
||||
do_test check-4.7 {
|
||||
execsql {
|
||||
SELECT * FROM t4;
|
||||
@@ -335,7 +338,10 @@ do_test check-4.9 {
|
||||
catchsql {
|
||||
UPDATE t4 SET x=0, y=2;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t4}}
|
||||
} {1 {CHECK constraint failed: x+y==11
|
||||
OR x*y==12
|
||||
OR x/y BETWEEN 5 AND 8
|
||||
OR -x==y+10}}
|
||||
ifcapable vacuum {
|
||||
do_test check_4.10 {
|
||||
catchsql {
|
||||
@@ -386,7 +392,7 @@ do_test check-6.5 {
|
||||
catchsql {
|
||||
UPDATE OR FAIL t1 SET x=7-x, y=y+1;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: x<5}}
|
||||
do_test check-6.6 {
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
@@ -398,7 +404,7 @@ do_test check-6.7 {
|
||||
INSERT INTO t1 VALUES(1,30.0);
|
||||
INSERT OR ROLLBACK INTO t1 VALUES(8,40.0);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: x<5}}
|
||||
do_test check-6.8 {
|
||||
catchsql {
|
||||
COMMIT;
|
||||
@@ -417,7 +423,7 @@ do_test check-6.12 {
|
||||
catchsql {
|
||||
REPLACE INTO t1 VALUES(6,7);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: x<5}}
|
||||
do_test check-6.13 {
|
||||
execsql {SELECT * FROM t1}
|
||||
} {3 12.0 2 20.0}
|
||||
@@ -446,7 +452,7 @@ db func myfunc -deterministic myfunc
|
||||
do_execsql_test 7.1 { CREATE TABLE t6(a CHECK (myfunc(a))) }
|
||||
do_execsql_test 7.2 { INSERT INTO t6 VALUES(9) }
|
||||
do_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } \
|
||||
{1 {CHECK constraint failed: t6}}
|
||||
{1 {CHECK constraint failed: myfunc(a)}}
|
||||
|
||||
do_test 7.4 {
|
||||
sqlite3 db2 test.db
|
||||
@@ -469,7 +475,7 @@ do_test 7.7 {
|
||||
do_test 7.8 {
|
||||
db2 func myfunc myfunc
|
||||
catchsql { INSERT INTO t6 VALUES(12) } db2
|
||||
} {1 {CHECK constraint failed: t6}}
|
||||
} {1 {CHECK constraint failed: myfunc(a)}}
|
||||
|
||||
# 2013-08-02: Silently ignore database name qualifiers in CHECK constraints.
|
||||
#
|
||||
@@ -550,10 +556,10 @@ do_execsql_test 12.20 {
|
||||
} {}
|
||||
do_catchsql_test 12.21 {
|
||||
INSERT INTO t1(a) VALUES('xyz');
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: a<>+a}}
|
||||
do_catchsql_test 12.22 {
|
||||
INSERT INTO t1(a) VALUES(123);
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: a<>+a}}
|
||||
do_execsql_test 12.30 {
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a TEXT, CHECK(NOT(a=+a)));
|
||||
@@ -561,10 +567,10 @@ do_execsql_test 12.30 {
|
||||
} {}
|
||||
do_catchsql_test 12.31 {
|
||||
INSERT INTO t1(a) VALUES('xyz');
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: NOT(a=+a)}}
|
||||
do_catchsql_test 12.32 {
|
||||
INSERT INTO t1(a) VALUES(123);
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: NOT(a=+a)}}
|
||||
do_execsql_test 12.40 {
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a TEXT, CHECK(NOT(a<>+a)));
|
||||
@@ -585,7 +591,7 @@ do_execsql_test 12.60 {
|
||||
} {NULL}
|
||||
do_catchsql_test 12.61 {
|
||||
INSERT INTO t1(a) VALUES(456);
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: a NOT BETWEEN 0 AND +a}}
|
||||
do_execsql_test 12.70 {
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a TEXT, CHECK(a BETWEEN +a AND 999999));
|
||||
@@ -600,6 +606,6 @@ do_execsql_test 12.80 {
|
||||
} {NULL}
|
||||
do_catchsql_test 12.81 {
|
||||
INSERT INTO t1(a) VALUES(456);
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: a NOT BETWEEN +a AND 999999}}
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -813,7 +813,7 @@ do_test conflict-13.1 {
|
||||
catchsql {
|
||||
REPLACE INTO t13 VALUES(2);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t13}}
|
||||
} {1 {CHECK constraint failed: a!=2}}
|
||||
verify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK
|
||||
do_test conflict-13.2 {
|
||||
execsql {
|
||||
|
||||
+1
-1
@@ -811,7 +811,7 @@ do_test conflict2-13.1 {
|
||||
catchsql {
|
||||
REPLACE INTO t13 VALUES(2);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t13}}
|
||||
} {1 {CHECK constraint failed: a!=2}}
|
||||
verify_ex_errcode conflict2-13.1b SQLITE_CONSTRAINT_CHECK
|
||||
do_test conflict2-13.2 {
|
||||
execsql {
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ do_execsql_test date2-120 {
|
||||
} {2017-07-20 one}
|
||||
do_catchsql_test date2-130 {
|
||||
INSERT INTO t1(x,y) VALUES('2017-08-01','two');
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: date(x) BETWEEN '2017-07-01' AND '2017-07-31'}}
|
||||
|
||||
do_execsql_test date2-200 {
|
||||
CREATE TABLE t2(x,y);
|
||||
@@ -138,7 +138,7 @@ do_catchsql_test date2-601 {
|
||||
} {0 {}}
|
||||
do_catchsql_test date2-602 {
|
||||
INSERT INTO t601(a,b) VALUES(1e100, '1970-01-01');
|
||||
} {1 {CHECK constraint failed: t601}}
|
||||
} {1 {CHECK constraint failed: a<julianday(b)}}
|
||||
do_catchsql_test date2-603 {
|
||||
INSERT INTO t601(a,b) VALUES(10, 'now');
|
||||
} {1 {non-deterministic use of julianday() in a CHECK constraint}}
|
||||
|
||||
+1
-1
@@ -266,7 +266,7 @@ do_execsql_test 2030 {
|
||||
ANALYZE;
|
||||
}
|
||||
do_execsql_test 2040 {
|
||||
SELECT DISTINCT a, b, x FROM t3 CROSS JOIN t2 ORDER BY a;
|
||||
SELECT DISTINCT a, b, x FROM t3 CROSS JOIN t2 ORDER BY a, +b;
|
||||
} {
|
||||
one 0 1
|
||||
one 1 1
|
||||
|
||||
+11
-11
@@ -1433,20 +1433,20 @@ do_execsql_test 4.11 {
|
||||
}
|
||||
|
||||
do_createtable_tests 4.11 -error {CHECK constraint failed: %s} {
|
||||
1a "INSERT INTO x1 VALUES('one', 0)" {x1}
|
||||
1b "INSERT INTO t1 VALUES('one', -4.0)" {t1}
|
||||
1a "INSERT INTO x1 VALUES('one', 0)" {b>0}
|
||||
1b "INSERT INTO t1 VALUES('one', -4.0)" {b>0}
|
||||
|
||||
2a "INSERT INTO x2 VALUES('abc', 1)" {x2}
|
||||
2b "INSERT INTO t2 VALUES('abc', 1)" {t2}
|
||||
2a "INSERT INTO x2 VALUES('abc', 1)" {a||b}
|
||||
2b "INSERT INTO t2 VALUES('abc', 1)" {a||b}
|
||||
|
||||
3a "INSERT INTO x2 VALUES(0, 'abc')" {x2}
|
||||
3b "INSERT INTO t2 VALUES(0, 'abc')" {t2}
|
||||
3a "INSERT INTO x2 VALUES(0, 'abc')" {a||b}
|
||||
3b "INSERT INTO t2 VALUES(0, 'abc')" {a||b}
|
||||
|
||||
4a "UPDATE t1 SET b=-1 WHERE rowid=1" {t1}
|
||||
4b "UPDATE x1 SET b=-1 WHERE rowid=1" {x1}
|
||||
4a "UPDATE t1 SET b=-1 WHERE rowid=1" {b>0}
|
||||
4b "UPDATE x1 SET b=-1 WHERE rowid=1" {b>0}
|
||||
|
||||
4a "UPDATE x2 SET a='' WHERE rowid=1" {x2}
|
||||
4b "UPDATE t2 SET a='' WHERE rowid=1" {t2}
|
||||
4a "UPDATE x2 SET a='' WHERE rowid=1" {a||b}
|
||||
4b "UPDATE t2 SET a='' WHERE rowid=1" {a||b}
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-34109-39108 If the CHECK expression evaluates to NULL,
|
||||
@@ -1639,7 +1639,7 @@ do_execsql_test 4.18.1 {
|
||||
do_execsql_test 4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) }
|
||||
do_catchsql_test 4.18.3 {
|
||||
INSERT INTO t4 SELECT a+4, b+4 FROM t4
|
||||
} {1 {CHECK constraint failed: t4}}
|
||||
} {1 {CHECK constraint failed: b!=10}}
|
||||
do_test e_createtable-4.18.4 { sqlite3_get_autocommit db } 0
|
||||
do_execsql_test 4.18.5 { SELECT * FROM t4 } {1 2 3 4 5 6}
|
||||
|
||||
|
||||
+3
-2
@@ -254,8 +254,9 @@ foreach {tn a b} {
|
||||
#-------------------------------------------------------------------------
|
||||
# Test the % operator.
|
||||
#
|
||||
# EVIDENCE-OF: R-04223-04352 The operator % outputs the integer value of
|
||||
# its left operand modulo its right operand.
|
||||
# EVIDENCE-OF: R-53431-59159 The % operator casts both of its operands
|
||||
# to type INTEGER and then computes the remainder after dividing the
|
||||
# left integer by the right integer.
|
||||
#
|
||||
do_execsql_test e_expr-6.1 {SELECT 72%5} {2}
|
||||
do_execsql_test e_expr-6.2 {SELECT 72%-5} {2}
|
||||
|
||||
+2
-2
@@ -417,14 +417,14 @@ do_test fkey2-3.1.2 {
|
||||
} {}
|
||||
do_test fkey2-3.1.3 {
|
||||
catchsql { UPDATE ab SET a = 5 }
|
||||
} {1 {CHECK constraint failed: ef}}
|
||||
} {1 {CHECK constraint failed: e!=5}}
|
||||
do_test fkey2-3.1.4 {
|
||||
execsql { SELECT * FROM ab }
|
||||
} {1 b}
|
||||
do_test fkey2-3.1.4 {
|
||||
execsql BEGIN;
|
||||
catchsql { UPDATE ab SET a = 5 }
|
||||
} {1 {CHECK constraint failed: ef}}
|
||||
} {1 {CHECK constraint failed: e!=5}}
|
||||
do_test fkey2-3.1.5 {
|
||||
execsql COMMIT;
|
||||
execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
|
||||
|
||||
+23
-23
@@ -381,32 +381,32 @@ ifcapable check {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (NULL);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.3 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (NULL);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.4 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.5 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('bad');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.6 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('1234bad');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.7 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('1234.56bad');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.8 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (1234);
|
||||
@@ -416,7 +416,7 @@ ifcapable check {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (1234.56);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.10 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('1234');
|
||||
@@ -426,27 +426,27 @@ ifcapable check {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('1234.56');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.12 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (ZEROBLOB(4));
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.13 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (X'');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.14 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (X'1234');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.15 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (X'12345678');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
do_test func4-3.16 {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES ('1234.00');
|
||||
@@ -467,7 +467,7 @@ ifcapable check {
|
||||
catchsql {
|
||||
INSERT INTO t1 (x) VALUES (9223372036854775808);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}}
|
||||
}
|
||||
do_execsql_test func4-3.20 {
|
||||
SELECT x FROM t1 WHERE x>0 ORDER BY x;
|
||||
@@ -483,32 +483,32 @@ ifcapable check {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (NULL);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.3 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (NULL);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.4 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES ('');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.5 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES ('bad');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.6 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES ('1234bad');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.7 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES ('1234.56bad');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.8 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (1234);
|
||||
@@ -533,22 +533,22 @@ ifcapable check {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (ZEROBLOB(4));
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.13 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (X'');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.14 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (X'1234');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_test func4-4.15 {
|
||||
catchsql {
|
||||
INSERT INTO t2 (x) VALUES (X'12345678');
|
||||
}
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: toreal(x) IS NOT NULL}}
|
||||
do_execsql_test func4-4.16 {
|
||||
SELECT x FROM t2 ORDER BY x;
|
||||
} {1234.0 1234.0 1234.56 1234.56}
|
||||
|
||||
+33
-9
@@ -627,7 +627,7 @@ static int decodeDatabase(
|
||||
unsigned char **paDecode, /* OUT: decoded database file */
|
||||
int *pnDecode /* OUT: Size of decoded database */
|
||||
){
|
||||
unsigned char *a; /* Database under construction */
|
||||
unsigned char *a, *aNew; /* Database under construction */
|
||||
int mx = 0; /* Current size of the database */
|
||||
sqlite3_uint64 nAlloc = 4096; /* Space allocated in a[] */
|
||||
unsigned int i; /* Next byte of zIn[] to read */
|
||||
@@ -673,11 +673,12 @@ static int decodeDatabase(
|
||||
}
|
||||
newSize = MX_FILE_SZ;
|
||||
}
|
||||
a = sqlite3_realloc64( a, newSize );
|
||||
if( a==0 ){
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
aNew = sqlite3_realloc64( a, newSize );
|
||||
if( aNew==0 ){
|
||||
sqlite3_free(a);
|
||||
return -1;
|
||||
}
|
||||
a = aNew;
|
||||
assert( newSize > nAlloc );
|
||||
memset(a+nAlloc, 0, (size_t)(newSize - nAlloc));
|
||||
nAlloc = newSize;
|
||||
@@ -851,7 +852,8 @@ int runCombinedDbSqlInput(const uint8_t *aData, size_t nByte){
|
||||
int nAlloc = 0;
|
||||
int nNotUsed = 0;
|
||||
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0);
|
||||
fprintf(stderr,"Memory leak in mutator: %lld bytes in %d allocations\n",
|
||||
fprintf(stderr,"memory leak prior to test start:"
|
||||
" %lld bytes in %d allocations\n",
|
||||
sqlite3_memory_used(), nAlloc);
|
||||
exit(1);
|
||||
}
|
||||
@@ -866,7 +868,10 @@ int runCombinedDbSqlInput(const uint8_t *aData, size_t nByte){
|
||||
fflush(stdout);
|
||||
}
|
||||
rc = sqlite3_open(0, &cx.db);
|
||||
if( rc ) return 1;
|
||||
if( rc ){
|
||||
sqlite3_free(aDb);
|
||||
return 1;
|
||||
}
|
||||
if( bVdbeDebug ){
|
||||
sqlite3_exec(cx.db, "PRAGMA vdbe_debug=ON", 0, 0, 0);
|
||||
}
|
||||
@@ -1410,7 +1415,8 @@ static void showHelp(void){
|
||||
" --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n"
|
||||
" --help Show this help text\n"
|
||||
" --info Show information about SOURCE-DB w/o running tests\n"
|
||||
" --limit-depth N Limit expression depth to N\n"
|
||||
" --limit-depth N Limit expression depth to N. Default: 500\n"
|
||||
" --limit-heap N Limit heap memory to N. Default: 100M\n"
|
||||
" --limit-mem N Limit memory used by test SQLite instance to N bytes\n"
|
||||
" --limit-vdbe Panic if any test runs for more than 100,000 cycles\n"
|
||||
" --load-sql ARGS... Load SQL scripts fron files into SOURCE-DB\n"
|
||||
@@ -1424,6 +1430,7 @@ static void showHelp(void){
|
||||
" -q|--quiet Reduced output\n"
|
||||
" --rebuild Rebuild and vacuum the database file\n"
|
||||
" --result-trace Show the results of each SQL command\n"
|
||||
" --skip N Skip the first N test cases\n"
|
||||
" --spinner Use a spinner to show progress\n"
|
||||
" --sqlid N Use only SQL where sqlid=N\n"
|
||||
" --timeout N Abort if any single test needs more than N seconds\n"
|
||||
@@ -1451,6 +1458,7 @@ int main(int argc, char **argv){
|
||||
int rebuildFlag = 0; /* --rebuild */
|
||||
int vdbeLimitFlag = 0; /* --limit-vdbe */
|
||||
int infoFlag = 0; /* --info */
|
||||
int nSkip = 0; /* --skip */
|
||||
int bSpinner = 0; /* True for --spinner */
|
||||
int timeoutTest = 0; /* undocumented --timeout-test flag */
|
||||
int runFlags = 0; /* Flags sent to runSql() */
|
||||
@@ -1520,6 +1528,10 @@ int main(int argc, char **argv){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
depthLimit = integerValue(argv[++i]);
|
||||
}else
|
||||
if( strcmp(z,"limit-heap")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
heapLimit = integerValue(argv[++i]);
|
||||
}else
|
||||
if( strcmp(z,"limit-mem")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
nMem = integerValue(argv[++i]);
|
||||
@@ -1578,6 +1590,10 @@ int main(int argc, char **argv){
|
||||
if( strcmp(z,"result-trace")==0 ){
|
||||
runFlags |= SQL_OUTPUT;
|
||||
}else
|
||||
if( strcmp(z,"skip")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
nSkip = atoi(argv[++i]);
|
||||
}else
|
||||
if( strcmp(z,"spinner")==0 ){
|
||||
bSpinner = 1;
|
||||
}else
|
||||
@@ -1898,7 +1914,11 @@ int main(int argc, char **argv){
|
||||
prevAmt = amt;
|
||||
}
|
||||
}
|
||||
runCombinedDbSqlInput(pSql->a, pSql->sz);
|
||||
if( nSkip>0 ){
|
||||
nSkip--;
|
||||
}else{
|
||||
runCombinedDbSqlInput(pSql->a, pSql->sz);
|
||||
}
|
||||
nTest++;
|
||||
g.zTestName[0] = 0;
|
||||
disableOom();
|
||||
@@ -1927,6 +1947,10 @@ int main(int argc, char **argv){
|
||||
prevAmt = amt;
|
||||
}
|
||||
}
|
||||
if( nSkip>0 ){
|
||||
nSkip--;
|
||||
continue;
|
||||
}
|
||||
createVFile("main.db", pDb->sz, pDb->a);
|
||||
sqlite3_randomness(0,0);
|
||||
if( ossFuzzThisDb ){
|
||||
|
||||
Binary file not shown.
+22
-2
@@ -65,8 +65,8 @@ foreach {tn sql1 sql2} {
|
||||
3 "SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING a=2"
|
||||
"SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a COLLATE binary"
|
||||
|
||||
5 "SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING 0"
|
||||
"SELECT a, sum(b) FROM t1 WHERE 0 GROUP BY a COLLATE binary"
|
||||
5 "SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING 1"
|
||||
"SELECT a, sum(b) FROM t1 WHERE 1 GROUP BY a COLLATE binary"
|
||||
|
||||
6 "SELECT count(*) FROM t1,t2 WHERE a=c GROUP BY b, d HAVING b=d"
|
||||
"SELECT count(*) FROM t1,t2 WHERE a=c AND b=d GROUP BY b, d"
|
||||
@@ -154,5 +154,25 @@ do_execsql_test 4.3 {
|
||||
SELECT a, sum(b) FROM t3 WHERE nondeter(a) GROUP BY a
|
||||
} {1 4 2 2}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
do_execsql_test 5.0 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(x, y);
|
||||
INSERT INTO t1 VALUES('a', 'b');
|
||||
}
|
||||
|
||||
# The WHERE clause (a=2), uses an aggregate column from the outer query.
|
||||
# If the HAVING term (0) is moved into the WHERE clause in this case,
|
||||
# SQLite would at one point optimize (a=2 AND 0) to simply (0). Which
|
||||
# is logically correct, but happened to cause problems in aggregate
|
||||
# processing for the outer query. This test case verifies that those
|
||||
# problems are no longer present.
|
||||
do_execsql_test 5.1 {
|
||||
SELECT min(b), (
|
||||
SELECT x FROM t2 WHERE a=2 GROUP BY y HAVING 0
|
||||
) FROM t1;
|
||||
} {b {}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+7
-1
@@ -332,7 +332,7 @@ do_test in-10.2 {
|
||||
catchsql {
|
||||
INSERT INTO t5 VALUES(4);
|
||||
}
|
||||
} {1 {CHECK constraint failed: t5}}
|
||||
} {1 {CHECK constraint failed: a IN (111,222,333)}}
|
||||
|
||||
# Ticket #1821
|
||||
#
|
||||
@@ -791,4 +791,10 @@ do_execsql_test in-19.40 {
|
||||
PRAGMA integrity_check;
|
||||
} {ok}
|
||||
|
||||
# Ticket f3ff1472887
|
||||
#
|
||||
do_execsql_test in-20.1 {
|
||||
SELECT (1 IN (2 IS TRUE));
|
||||
} {1}
|
||||
|
||||
finish_test
|
||||
|
||||
+5
-5
@@ -55,7 +55,7 @@ do_test insert4-1.1 {
|
||||
catchsql {
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: b>a}}
|
||||
xferopt_test insert4-1.2 0
|
||||
do_test insert4-1.3 {
|
||||
execsql {
|
||||
@@ -102,7 +102,7 @@ do_test insert4-2.3.3 {
|
||||
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: b>a}}
|
||||
xferopt_test insert4-2.3.4 0
|
||||
|
||||
# Do not run the transfer optimization if there is a DISTINCT
|
||||
@@ -120,7 +120,7 @@ do_test insert4-2.4.3 {
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1 SELECT DISTINCT * FROM t2;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t1}}
|
||||
} {1 {CHECK constraint failed: b>a}}
|
||||
xferopt_test insert4-2.4.4 0
|
||||
|
||||
# The following procedure constructs two tables then tries to transfer
|
||||
@@ -316,7 +316,7 @@ do_test insert4-6.6 {
|
||||
catchsql {
|
||||
INSERT INTO t6b SELECT * FROM t6a;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t6b}}
|
||||
} {1 {CHECK constraint failed: x<>'abc' COLLATE nocase}}
|
||||
do_test insert4-6.7 {
|
||||
execsql {
|
||||
DROP TABLE t6b;
|
||||
@@ -325,7 +325,7 @@ do_test insert4-6.7 {
|
||||
catchsql {
|
||||
INSERT INTO t6b SELECT * FROM t6a;
|
||||
}
|
||||
} {1 {CHECK constraint failed: t6b}}
|
||||
} {1 {CHECK constraint failed: x COLLATE nocase <>'abc'}}
|
||||
|
||||
# Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
|
||||
# Disable the xfer optimization if the destination table contains
|
||||
|
||||
+5
-5
@@ -112,16 +112,16 @@ do_execsql_test istrue-520 {
|
||||
} {1 1 0 {} {}}
|
||||
do_catchsql_test istrue-521 {
|
||||
INSERT INTO t2 VALUES(2,false,false,null,null);
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: b IS TRUE}}
|
||||
do_catchsql_test istrue-522 {
|
||||
INSERT INTO t2 VALUES(2,true,true,null,null);
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: c IS FALSE}}
|
||||
do_catchsql_test istrue-523 {
|
||||
INSERT INTO t2 VALUES(2,true,false,true,null);
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: d IS NOT TRUE}}
|
||||
do_catchsql_test istrue-524 {
|
||||
INSERT INTO t2 VALUES(2,true,false,null,false);
|
||||
} {1 {CHECK constraint failed: t2}}
|
||||
} {1 {CHECK constraint failed: e IS NOT FALSE}}
|
||||
|
||||
foreach {tn val} [list 1 NaN 2 -NaN 3 NaN0 4 -NaN0 5 Inf 6 -Inf] {
|
||||
do_execsql_test istrue-600.$tn.1 {
|
||||
@@ -193,7 +193,7 @@ do_execsql_test istrue-840 {
|
||||
} {}
|
||||
do_catchsql_test istrue-841 {
|
||||
INSERT INTO False VALUES(5,6,7);
|
||||
} {1 {CHECK constraint failed: false}}
|
||||
} {1 {CHECK constraint failed: 5 IN (false.false)}}
|
||||
do_execsql_test istrue-850 {
|
||||
SELECT 9 IN (false.false) FROM false;
|
||||
} {0}
|
||||
|
||||
+14
-1
@@ -1025,5 +1025,18 @@ do_execsql_test join-24.2 {
|
||||
SELECT * FROM t2 LEFT JOIN t1 ON a=0 WHERE (x='x' OR x IS NULL);
|
||||
} {1 {} {}}
|
||||
|
||||
finish_test
|
||||
# 2020-09-30 ticket 66e4b0e271c47145
|
||||
# The query flattener inserts an "expr AND expr" expression as a substitution
|
||||
# for the column of a view where that view column is part of an ON expression
|
||||
# of a LEFT JOIN.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test join-25.1 {
|
||||
CREATE TABLE t0(c0 INT);
|
||||
CREATE VIEW v0 AS SELECT (NULL AND 5) as c0 FROM t0;
|
||||
INSERT INTO t0(c0) VALUES (NULL);
|
||||
SELECT count(*) FROM v0 LEFT JOIN t0 ON v0.c0;
|
||||
} {1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+16
-1
@@ -294,7 +294,10 @@ do_execsql_test 8.1 {
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Ticket [45f4bf4eb].
|
||||
# Ticket [45f4bf4eb] reported by Manuel Rigger (2020-04-25)
|
||||
#
|
||||
# Follow up error reported by Eric Speckman on the SQLite forum
|
||||
# https://sqlite.org/forum/info/c49496d24d35bd7c (2020-08-19)
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 9.0 {
|
||||
@@ -324,5 +327,17 @@ do_execsql_test 9.5 {
|
||||
UNION SELECT 0,0 WHERE 0;
|
||||
} {0 0}
|
||||
|
||||
do_execsql_test 9.10 {
|
||||
CREATE TABLE t1 (aaa);
|
||||
INSERT INTO t1 VALUES(23456);
|
||||
CREATE TABLE t2(bbb);
|
||||
CREATE VIEW v2(ccc) AS SELECT bbb IS 1234 FROM t2;
|
||||
SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2;
|
||||
} {{} 1}
|
||||
optimization_control db query-flattener 0
|
||||
do_execsql_test 9.11 {
|
||||
SELECT ccc, ccc IS NULL AS ddd FROM t1 LEFT JOIN v2;
|
||||
} {{} 1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -147,6 +147,22 @@ ifcapable compound {
|
||||
} {1 91 92 3 93 5}
|
||||
}
|
||||
|
||||
do_execsql_test join6-5.1 {
|
||||
CREATE TABLE tx(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o PRIMARY KEY)
|
||||
WITHOUT ROWID;
|
||||
INSERT INTO tx VALUES(
|
||||
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
||||
);
|
||||
} {}
|
||||
do_execsql_test joint6-5.2 {
|
||||
SELECT o FROM tx NATURAL JOIN tx;
|
||||
} {15}
|
||||
|
||||
do_execsql_test join6-5.3 {
|
||||
CREATE TABLE ty(a,Ñ,x6,x7,x8,Q,I,v,x1,L,E,x2,x3,x4,x5,s,g PRIMARY KEY,b,c)
|
||||
WITHOUT ROWID;
|
||||
SELECT a FROM ty NATURAL JOIN ty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -296,5 +296,12 @@ do_execsql_test null-9.3 {
|
||||
SELECT * FROM t5 WHERE a IS NULL AND b = 'x';
|
||||
} {{} x two {} x ii}
|
||||
|
||||
# 2020-09-30 ticket 5c4e7aa793943803
|
||||
reset_db
|
||||
do_execsql_test null-10.1 {
|
||||
CREATE TABLE t0(c0 PRIMARY KEY DESC);
|
||||
INSERT INTO t0(c0) VALUES (0);
|
||||
SELECT * FROM t0 WHERE t0.c0 > NULL;
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ do_execsql_test pager1-3.1.2 {
|
||||
} {3 0}
|
||||
do_catchsql_test pager1-3.1.3 {
|
||||
INSERT INTO t1 SELECT a+3, randomblob(1500) FROM t1
|
||||
} {1 {CHECK constraint failed: counter}}
|
||||
} {1 {CHECK constraint failed: i<5}}
|
||||
do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}
|
||||
do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}
|
||||
do_execsql_test pager1-3.6 { COMMIT } {}
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ do_execsql_test 2.3.1 {
|
||||
}
|
||||
do_catchsql_test 2.3.2 {
|
||||
INSERT INTO xyz VALUES(1, 2, 'null');
|
||||
} {1 {CHECK constraint failed: xyz}}
|
||||
} {1 {CHECK constraint failed: c!="null"}}
|
||||
|
||||
do_execsql_test 2.4 {
|
||||
INSERT INTO t1 VALUES(1, 2, 3);
|
||||
|
||||
@@ -54,9 +54,10 @@ array set ::Configs [strip_comments {
|
||||
-DSQLITE_ENABLE_DESERIALIZE
|
||||
}
|
||||
"Sanitize" {
|
||||
CC=clang -fsanitize=undefined
|
||||
CC=clang -fsanitize=address,undefined
|
||||
-DSQLITE_ENABLE_STAT4
|
||||
--enable-session
|
||||
--enable-debug
|
||||
--enable-all
|
||||
}
|
||||
"Stdcall" {
|
||||
-DUSE_STDCALL=1
|
||||
@@ -135,6 +136,11 @@ array set ::Configs [strip_comments {
|
||||
-DSQLITE_MUTATION_TEST
|
||||
--enable-fts5 --enable-json1
|
||||
}
|
||||
"Debug-Two" {
|
||||
-DSQLITE_DEFAULT_MEMSTATUS=0
|
||||
-DSQLITE_MAX_EXPR_DEPTH=0
|
||||
--enable-debug
|
||||
}
|
||||
"Fast-One" {
|
||||
-O6
|
||||
-DSQLITE_ENABLE_FTS4=1
|
||||
@@ -142,6 +148,7 @@ array set ::Configs [strip_comments {
|
||||
-DSQLITE_ENABLE_STAT4
|
||||
-DSQLITE_ENABLE_RBU
|
||||
-DSQLITE_MAX_ATTACHED=125
|
||||
-DSQLITE_MAX_MMAP_SIZE=12884901888
|
||||
-DLONGDOUBLE_TYPE=double
|
||||
--enable-session
|
||||
}
|
||||
@@ -284,6 +291,7 @@ array set ::Platforms [strip_comments {
|
||||
"Check-Symbols*" checksymbols
|
||||
"Fast-One" "fuzztest test"
|
||||
"Debug-One" "mptest test"
|
||||
"Debug-Two" "test"
|
||||
"Have-Not" test
|
||||
"Secure-Delete" test
|
||||
"Unlock-Notify" "QUICKTEST_INCLUDE=notify2.test test"
|
||||
@@ -294,7 +302,7 @@ array set ::Platforms [strip_comments {
|
||||
"No-lookaside" test
|
||||
"Devkit" test
|
||||
"Apple" test
|
||||
"Sanitize" {QUICKTEST_OMIT=func4.test,nan.test test}
|
||||
"Sanitize" {QUICKTEST_OMIT=crash*,shell*,sqldiff*,sessionB.test test}
|
||||
"Device-One" fulltest
|
||||
"Default" "threadtest fulltest"
|
||||
"Valgrind*" valgrindtest
|
||||
|
||||
@@ -1201,4 +1201,13 @@ do_execsql_test select-20.20 {
|
||||
SELECT ifnull(a, max((SELECT 123))), count(a) FROM t1 ;
|
||||
} {10 1}
|
||||
|
||||
# 2020-10-02 dbsqlfuzz find
|
||||
reset_db
|
||||
do_execsql_test select-21.1 {
|
||||
CREATE TABLE t1(a IMTEGES PRIMARY KEY,R);
|
||||
CREATE TABLE t2(x UNIQUE);
|
||||
CREATE VIEW v1a(z,y) AS SELECT x IS NULL, x FROM t2;
|
||||
SELECT a,(+a)b,(+a)b,(+a)b,NOT EXISTS(SELECT null FROM t2),CASE z WHEN 487 THEN 992 WHEN 391 THEN 203 WHEN 10 THEN '?k<D Q' END,'' FROM t1 LEFT JOIN v1a ON z=b;
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
||||
+3
-5
@@ -160,11 +160,9 @@ do_test shared-$av.1.8 {
|
||||
} {}
|
||||
|
||||
do_test shared-$av.2.1 {
|
||||
# Open connection db3 to the database. Use a different path to the same
|
||||
# file so that db3 does *not* share the same pager cache as db and db2
|
||||
# (there should be two open file handles).
|
||||
# Open connection db3 to the database.
|
||||
if {$::tcl_platform(platform)=="unix"} {
|
||||
sqlite3 db3 ./test.db
|
||||
sqlite3 db3 "file:test.db?cache=private" -uri 1
|
||||
} else {
|
||||
sqlite3 db3 TEST.DB
|
||||
}
|
||||
@@ -800,7 +798,7 @@ do_test shared-$av.10.3 {
|
||||
# An external connection should be able to read the database, but not
|
||||
# prepare a write operation.
|
||||
if {$::tcl_platform(platform)=="unix"} {
|
||||
sqlite3 db3 ./test.db
|
||||
sqlite3 db3 "file:test.db?cache=private" -uri 1
|
||||
} else {
|
||||
sqlite3 db3 TEST.DB
|
||||
}
|
||||
|
||||
+8
-7
@@ -70,13 +70,14 @@ do_test shared3-2.5 {
|
||||
# test case shared3-2.3 above). The goal of the following tests is to
|
||||
# ensure that the cache-size really is 10 pages.
|
||||
#
|
||||
if {$::tcl_platform(platform)=="unix"} {
|
||||
set alternative_name ./test.db
|
||||
} else {
|
||||
set alternative_name TEST.DB
|
||||
}
|
||||
#if {$::tcl_platform(platform)=="unix"} {
|
||||
# set alternative_name ./test.db
|
||||
#} else {
|
||||
# set alternative_name TEST.DB
|
||||
#}
|
||||
do_test shared3-2.6 {
|
||||
sqlite3 db3 $alternative_name
|
||||
#sqlite3 db3 $alternative_name
|
||||
sqlite3 db3 "file:./test.db?cache=private" -uri 1
|
||||
catchsql {select count(*) from sqlite_master} db3
|
||||
} {0 1}
|
||||
do_test shared3-2.7 {
|
||||
@@ -96,7 +97,7 @@ do_test shared3-2.8 {
|
||||
# statement above should have caused the pager to grab an exclusive lock
|
||||
# on the database file so that the cache could be spilled.
|
||||
#
|
||||
catch { sqlite3 db3 $alternative_name }
|
||||
catch { sqlite3 db3 "file:./test.db?cache=private" -uri 1 }
|
||||
catchsql {select count(*) from sqlite_master} db3
|
||||
} {1 {database is locked}}
|
||||
|
||||
|
||||
+6
-1
@@ -64,6 +64,10 @@ do_test shell1-1.2.1 {
|
||||
} {1 1 1 1}
|
||||
|
||||
# -init filename read/process named file
|
||||
forcedelete FOO
|
||||
set out [open FOO w]
|
||||
puts $out ""
|
||||
close $out
|
||||
do_test shell1-1.3.1 {
|
||||
catchcmd "-init FOO test.db" ""
|
||||
} {0 {}}
|
||||
@@ -247,6 +251,7 @@ do_test shell1-2.4.2 {
|
||||
do_test shell1-3.1.1 {
|
||||
catchcmd "test.db" ".backup"
|
||||
} {1 {missing FILENAME argument on .backup}}
|
||||
forcedelete FOO
|
||||
do_test shell1-3.1.2 {
|
||||
catchcmd "test.db" ".backup FOO"
|
||||
} {0 {}}
|
||||
@@ -583,7 +588,7 @@ do_test shell1-3.21.2 {
|
||||
do_test shell1-3.21.3 {
|
||||
# too many arguments
|
||||
catchcmd "test.db" ".schema FOO BAD"
|
||||
} {1 {Usage: .schema ?--indent? ?LIKE-PATTERN?}}
|
||||
} {1 {Usage: .schema ?--indent? ?--nosys? ?LIKE-PATTERN?}}
|
||||
|
||||
do_test shell1-3.21.4 {
|
||||
catchcmd "test.db" {
|
||||
|
||||
+4
-4
@@ -30,7 +30,7 @@ do_execsql_test 1.1 {
|
||||
|
||||
expr srand(4)
|
||||
do_test 1.2 {
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
for {set i 0} {$i < 1000} {incr i} {
|
||||
set a [expr int(rand()*4.0) + 1]
|
||||
set b [expr int(rand()*20.0) + 1]
|
||||
execsql { INSERT INTO t1 VALUES($a, $b, NULL) }
|
||||
@@ -43,7 +43,7 @@ foreach {tn q res} {
|
||||
2 "b > 12 AND b < 16" {/*ANY(a) AND b>? AND b<?*/}
|
||||
3 "b > 2 AND b < 16" {/*SCAN TABLE t1*/}
|
||||
4 "b > 18 AND b < 25" {/*ANY(a) AND b>? AND b<?*/}
|
||||
5 "b > 15" {/*ANY(a) AND b>?*/}
|
||||
5 "b > 16" {/*ANY(a) AND b>?*/}
|
||||
6 "b > 5" {/*SCAN TABLE t1*/}
|
||||
7 "b < 15" {/*SCAN TABLE t1*/}
|
||||
8 "b < 5" {/*ANY(a) AND b<?*/}
|
||||
@@ -52,7 +52,7 @@ foreach {tn q res} {
|
||||
11 "b > '12' AND b < '16'" {/*ANY(a) AND b>? AND b<?*/}
|
||||
12 "b > '2' AND b < '16'" {/*SCAN TABLE t1*/}
|
||||
13 "b > '18' AND b < '25'" {/*ANY(a) AND b>? AND b<?*/}
|
||||
14 "b > '15'" {/*ANY(a) AND b>?*/}
|
||||
14 "b > '16'" {/*ANY(a) AND b>?*/}
|
||||
15 "b > '5'" {/*SCAN TABLE t1*/}
|
||||
16 "b < '15'" {/*SCAN TABLE t1*/}
|
||||
17 "b < '5'" {/*ANY(a) AND b<?*/}
|
||||
@@ -108,7 +108,7 @@ foreach {tn dbenc coll} {
|
||||
3 { c > 'q' } {/*ANY(a) AND ANY(b) AND c>?*/}
|
||||
4 { c > 'e' } {/*SCAN TABLE t2*/}
|
||||
5 { c < 'q' } {/*SCAN TABLE t2*/}
|
||||
6 { c < 'c' } {/*ANY(a) AND ANY(b) AND c<?*/}
|
||||
6 { c < 'b' } {/*ANY(a) AND ANY(b) AND c<?*/}
|
||||
} {
|
||||
set sql "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE $q"
|
||||
do_execsql_test 2.$tn.$tn2 $sql $res
|
||||
|
||||
@@ -28,6 +28,7 @@ static const char zHelp[] =
|
||||
" --primarykey Use PRIMARY KEY instead of UNIQUE where appropriate\n"
|
||||
" --repeat N Repeat each SELECT N times (default: 1)\n"
|
||||
" --reprepare Reprepare each statement upon every invocation\n"
|
||||
" --reserve N Reserve N bytes on each database page\n"
|
||||
" --serialized Set serialized threading mode\n"
|
||||
" --singlethread Set single-threaded mode - disables all mutexing\n"
|
||||
" --sqlonly No-op. Only show the SQL that would have been run.\n"
|
||||
@@ -93,6 +94,7 @@ static struct Global {
|
||||
int szTest; /* Scale factor for test iterations */
|
||||
int nRepeat; /* Repeat selects this many times */
|
||||
int doCheckpoint; /* Run PRAGMA wal_checkpoint after each trans */
|
||||
int nReserve; /* Reserve bytes */
|
||||
const char *zWR; /* Might be WITHOUT ROWID */
|
||||
const char *zNN; /* Might be NOT NULL */
|
||||
const char *zPK; /* Might be UNIQUE or PRIMARY KEY */
|
||||
@@ -2135,6 +2137,10 @@ static void displayLinuxIoStats(FILE *out){
|
||||
# define sqlite3_sourceid(X) "(before 3.6.18)"
|
||||
#endif
|
||||
|
||||
#if SQLITE_CKSUMVFS_STATIC
|
||||
int sqlite3_register_cksumvfs(const char*);
|
||||
#endif
|
||||
|
||||
static int xCompileOptions(void *pCtx, int nVal, char **azVal, char **azCol){
|
||||
printf("-- Compile option: %s\n", azVal[0]);
|
||||
return SQLITE_OK;
|
||||
@@ -2169,6 +2175,10 @@ int main(int argc, char **argv){
|
||||
int i; /* Loop counter */
|
||||
int rc; /* API return code */
|
||||
|
||||
#ifdef SQLITE_CKSUMVFS_STATIC
|
||||
sqlite3_register_cksumvfs(0);
|
||||
#endif
|
||||
|
||||
/* Display the version of SQLite being tested */
|
||||
printf("-- Speedtest1 for SQLite %s %.48s\n",
|
||||
sqlite3_libversion(), sqlite3_sourceid());
|
||||
@@ -2303,6 +2313,9 @@ int main(int argc, char **argv){
|
||||
#ifndef SPEEDTEST_OMIT_HASH
|
||||
HashInit();
|
||||
#endif
|
||||
}else if( strcmp(z,"reserve")==0 ){
|
||||
if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]);
|
||||
g.nReserve = atoi(argv[++i]);
|
||||
}else if( strcmp(z,"without-rowid")==0 ){
|
||||
g.zWR = "WITHOUT ROWID";
|
||||
g.zPK = "PRIMARY KEY";
|
||||
@@ -2354,6 +2367,9 @@ int main(int argc, char **argv){
|
||||
if( rc ) fatal_error("lookaside configuration failed: %d\n", rc);
|
||||
}
|
||||
#endif
|
||||
if( g.nReserve>0 ){
|
||||
sqlite3_file_control(g.db, 0, SQLITE_FCNTL_RESERVE_BYTES, &g.nReserve);
|
||||
}
|
||||
|
||||
/* Set database connection options */
|
||||
sqlite3_create_function(g.db, "random", 0, SQLITE_UTF8, 0, randomFunc, 0, 0);
|
||||
|
||||
+4
-5
@@ -11,7 +11,6 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the built-in SUBSTR() functions.
|
||||
#
|
||||
# $Id: substr.test,v 1.7 2009/02/03 13:10:54 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -39,7 +38,7 @@ proc substr-test {id string i1 i2 result} {
|
||||
set qstr '[string map {' ''} $string]'
|
||||
do_test substr-$id.2 [subst {
|
||||
execsql {
|
||||
SELECT substr($qstr, $i1, $i2)
|
||||
SELECT substring($qstr, $i1, $i2)
|
||||
}
|
||||
}] [list $result]
|
||||
}
|
||||
@@ -55,7 +54,7 @@ proc subblob-test {id hex i1 i2 hexresult} {
|
||||
}] [list $hexresult]
|
||||
do_test substr-$id.2 [subst {
|
||||
execsql {
|
||||
SELECT hex(substr(x'$hex', $i1, $i2))
|
||||
SELECT hex(substring(x'$hex', $i1, $i2))
|
||||
}
|
||||
}] [list $hexresult]
|
||||
}
|
||||
@@ -93,7 +92,7 @@ do_test substr-1.92 {
|
||||
db eval {SELECT ifnull(substr('abcdefg',NULL,1),'nil')}
|
||||
} nil
|
||||
do_test substr-1.93 {
|
||||
db eval {SELECT ifnull(substr('abcdefg',NULL),'nil')}
|
||||
db eval {SELECT ifnull(substring('abcdefg',NULL),'nil')}
|
||||
} nil
|
||||
do_test substr-1.94 {
|
||||
db eval {SELECT ifnull(substr('abcdefg',1,NULL),'nil')}
|
||||
@@ -149,7 +148,7 @@ proc substr-2-test {id string idx result} {
|
||||
set qstr '[string map {' ''} $string]'
|
||||
do_test substr-$id.2 [subst {
|
||||
execsql {
|
||||
SELECT substr($qstr, $idx)
|
||||
SELECT substring($qstr, $idx)
|
||||
}
|
||||
}] [list $result]
|
||||
}
|
||||
|
||||
@@ -1731,6 +1731,9 @@ proc crashsql {args} {
|
||||
set msg "child process exited abnormally"
|
||||
}
|
||||
}
|
||||
if {$r && [string match {*ERROR: LeakSanitizer*} $msg]} {
|
||||
set msg "child process exited abnormally"
|
||||
}
|
||||
|
||||
lappend r $msg
|
||||
}
|
||||
|
||||
@@ -1433,6 +1433,7 @@ static void dynamic_triggers(int nMs){
|
||||
#include "tt3_lookaside1.c"
|
||||
#include "tt3_vacuum.c"
|
||||
#include "tt3_stress.c"
|
||||
#include "tt3_shared.c"
|
||||
|
||||
int main(int argc, char **argv){
|
||||
struct ThreadTest {
|
||||
@@ -1457,6 +1458,7 @@ int main(int argc, char **argv){
|
||||
{ vacuum1, "vacuum1", 10000 },
|
||||
{ stress1, "stress1", 10000 },
|
||||
{ stress2, "stress2", 60000 },
|
||||
{ shared1, "shared1", 10000 },
|
||||
};
|
||||
static char *substArgv[] = { 0, "*", 0 };
|
||||
int i, iArg;
|
||||
|
||||
+1
-11
@@ -28,17 +28,7 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
|
||||
do_test tkt2854-1.1 {
|
||||
sqlite3 db test.db
|
||||
sqlite3 db2 test.db
|
||||
|
||||
# This is taken from shared.test. The Windows VFS expands
|
||||
# ./test.db (and test.db) to be the same thing so the path
|
||||
# matches and they share a cache. By changing the case
|
||||
# for Windows platform, we get around this and get a separate
|
||||
# connection.
|
||||
if {$::tcl_platform(platform)=="unix"} {
|
||||
sqlite3 db3 ./test.db
|
||||
} else {
|
||||
sqlite3 db3 TEST.DB
|
||||
}
|
||||
sqlite3 db3 "file:test.db?cache=private" -uri 1
|
||||
|
||||
db eval {
|
||||
CREATE TABLE abc(a, b, c);
|
||||
|
||||
+4
-13
@@ -13,7 +13,6 @@
|
||||
# This file implements tests to verify that ticket #3793 has been
|
||||
# fixed.
|
||||
#
|
||||
# $Id: tkt3793.test,v 1.2 2009/06/01 16:42:18 shane Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@@ -26,18 +25,10 @@ ifcapable !shared_cache||!attach {
|
||||
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
|
||||
|
||||
do_test tkt3793-1.1 {
|
||||
# This is taken from shared.test. The Windows VFS expands
|
||||
# ./test.db (and test.db) to be the same thing so the path
|
||||
# matches and they share a cache. By changing the case
|
||||
# for Windows platform, we get around this and get a separate
|
||||
# connection.
|
||||
if {$::tcl_platform(platform)=="unix"} {
|
||||
sqlite3 db1 test.db
|
||||
sqlite3 db2 test.db
|
||||
} else {
|
||||
sqlite3 db1 TEST.DB
|
||||
sqlite3 db2 TEST.DB
|
||||
}
|
||||
db close
|
||||
sqlite3 db "file:test.db" -uri 1
|
||||
sqlite3 db1 "file:test.db?cache=private" -uri 1
|
||||
sqlite3 db2 "file:test.db?cache=shared" -uri 1
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a, b);
|
||||
|
||||
@@ -84,4 +84,20 @@ do_test tkt3810-6 {
|
||||
|
||||
db2 close
|
||||
|
||||
# 2020-11-06 forum post https://sqlite.org/forum/forumpost/157dc791df
|
||||
#
|
||||
reset_db
|
||||
do_test tkt3810-100 {
|
||||
db eval {
|
||||
ATTACH ':memory:' AS aux1;
|
||||
CREATE TABLE aux1.t1(x);
|
||||
CREATE TEMP TRIGGER r1 DELETE ON t1 BEGIN SELECT *; END;
|
||||
CREATE VIEW t1 AS SELECT *;
|
||||
}
|
||||
catch {db eval {
|
||||
CREATE VIRTUAL TABLE t2 USING nosuchmodule;
|
||||
}}
|
||||
db eval {CREATE TABLE t3(z);}
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
||||
+39
-1
@@ -11,7 +11,6 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is database locks.
|
||||
#
|
||||
# $Id: trans.test,v 1.41 2009/04/28 16:37:59 danielk1977 Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@@ -39,6 +38,19 @@ do_test trans-1.1 {
|
||||
SELECT b FROM two ORDER BY a;
|
||||
}
|
||||
} {I V X}
|
||||
do_test trans-1.2.1 {
|
||||
sqlite3_txn_state db
|
||||
} {0}
|
||||
do_test trans-1.2.2 {
|
||||
sqlite3_txn_state db main
|
||||
} {0}
|
||||
do_test trans-1.2.3 {
|
||||
sqlite3_txn_state db temp
|
||||
} {0}
|
||||
do_test trans-1.2.4 {
|
||||
sqlite3_txn_state db no-such-schema
|
||||
} {-1}
|
||||
|
||||
do_test trans-1.9 {
|
||||
sqlite3 altdb test.db
|
||||
execsql {SELECT b FROM one ORDER BY a} altdb
|
||||
@@ -55,6 +67,9 @@ do_test trans-2.1 {
|
||||
set v [catch {execsql {BEGIN}} msg]
|
||||
lappend v $msg
|
||||
} {0 {}}
|
||||
do_test trans-2.1b {
|
||||
sqlite3_txn_state db
|
||||
} {0}
|
||||
do_test trans-2.2 {
|
||||
set v [catch {execsql {END}} msg]
|
||||
lappend v $msg
|
||||
@@ -95,6 +110,16 @@ do_test trans-3.1 {
|
||||
SELECT a FROM one ORDER BY a;
|
||||
}
|
||||
} {1 2 3}
|
||||
do_test trans-3.1b {
|
||||
sqlite3_txn_state db
|
||||
} {2}
|
||||
do_test trans-3.1c {
|
||||
sqlite3_txn_state db main
|
||||
} {2}
|
||||
do_test trans-3.1d {
|
||||
sqlite3_txn_state db temp
|
||||
} {0}
|
||||
|
||||
do_test trans-3.2 {
|
||||
catchsql {
|
||||
SELECT a FROM two ORDER BY a;
|
||||
@@ -139,6 +164,10 @@ do_test trans-3.9 {
|
||||
do_test trans-3.10 {
|
||||
execsql {END TRANSACTION}
|
||||
} {}
|
||||
do_test trans-3.10b {
|
||||
sqlite3_txn_state db
|
||||
} {0}
|
||||
|
||||
|
||||
do_test trans-3.11 {
|
||||
set v [catch {execsql {
|
||||
@@ -252,6 +281,15 @@ do_test trans-5.2 {
|
||||
execsql {BEGIN TRANSACTION}
|
||||
execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
|
||||
} {}
|
||||
do_test trans-5.2b {
|
||||
sqlite3_txn_state db
|
||||
} {1}
|
||||
do_test trans-5.2c {
|
||||
sqlite3_txn_state db main
|
||||
} {1}
|
||||
do_test trans-5.2d {
|
||||
sqlite3_txn_state db temp
|
||||
} {0}
|
||||
do_test trans-5.3 {
|
||||
execsql {CREATE TABLE one(a text, b int)}
|
||||
execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
** 2020 September 5
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
static char *shared_thread1(int iTid, void *pArg){
|
||||
Error err = {0}; /* Error code and message */
|
||||
|
||||
while( !timetostop(&err) ){
|
||||
Sqlite db = {0}; /* SQLite database connection */
|
||||
opendb(&err, &db, "test.db", 0);
|
||||
sql_script(&err, &db, "SELECT * FROM t1");
|
||||
closedb(&err, &db);
|
||||
}
|
||||
print_and_free_err(&err);
|
||||
return sqlite3_mprintf("done!");
|
||||
}
|
||||
|
||||
|
||||
static void shared1(int nMs){
|
||||
Error err = {0};
|
||||
Sqlite db = {0}; /* SQLite database connection */
|
||||
Threadset threads = {0};
|
||||
int ii;
|
||||
|
||||
opendb(&err, &db, "test.db", 1);
|
||||
sql_script(&err, &db, "CREATE TABLE t1(x)");
|
||||
closedb(&err, &db);
|
||||
|
||||
setstoptime(&err, nMs);
|
||||
sqlite3_enable_shared_cache(1);
|
||||
|
||||
for(ii=0; ii<5; ii++){
|
||||
launch_thread(&err, &threads, shared_thread1, 0);
|
||||
}
|
||||
|
||||
join_all_threads(&err, &threads);
|
||||
sqlite3_enable_shared_cache(0);
|
||||
|
||||
print_and_free_err(&err);
|
||||
}
|
||||
|
||||
@@ -787,4 +787,18 @@ do_execsql_test view-28.2 {
|
||||
SELECT 0 IN (c0) FROM (SELECT c0 FROM t0);
|
||||
} {0}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# 2020-10-26. https://sqlite.org/forum/forumpost/daa2c728cc
|
||||
#
|
||||
reset_db
|
||||
do_catchsql_test view-29.0 {
|
||||
CREATE TABLE t1(a,b,c);
|
||||
CREATE VIEW IF NOT EXISTS IF AS SELECT null;
|
||||
} {1 {malformed database schema (IF) - near "AS": syntax error}}
|
||||
do_catchsql_test view-29.1 {
|
||||
CREATE TABLE t2(c,d,e);
|
||||
SELECT name FROM sqlite_schema ORDER BY name;
|
||||
} {0 {t1 t2}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -122,5 +122,33 @@ do_execsql_test 181 {
|
||||
SELECT name, value FROM tclvar where name = 'xx';
|
||||
} {}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
do_execsql_test 200 {
|
||||
CREATE TABLE var(k TEXT, v TEXT);
|
||||
INSERT INTO var VALUES('testvar1', 10);
|
||||
INSERT INTO var VALUES('testvar2', 20);
|
||||
INSERT INTO var VALUES('testvar3', 30);
|
||||
}
|
||||
|
||||
do_test 210 {
|
||||
foreach {testvar1 testvar2 testvar3} {1 2 3} {}
|
||||
execsql {
|
||||
UPDATE tclvar SET value = var.v FROM var WHERE name = var.k;
|
||||
}
|
||||
list $testvar1 $testvar2 $testvar3
|
||||
} {10 20 30}
|
||||
|
||||
do_test 220 {
|
||||
execsql {
|
||||
CREATE TABLE nam(k TEXT, v TEXT);
|
||||
INSERT INTO nam VALUES('testvar1', 'tv1');
|
||||
INSERT INTO nam VALUES('testvar2', 'tv2');
|
||||
INSERT INTO nam VALUES('testvar3', 'tv3');
|
||||
UPDATE tclvar SET fullname = nam.v FROM nam WHERE name = nam.k;
|
||||
}
|
||||
list $tv1 $tv2 $tv3
|
||||
} {10 20 30}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-2
@@ -490,12 +490,12 @@ ifcapable subquery {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 4}
|
||||
} {2 1 9 5}
|
||||
do_test where-5.15 {
|
||||
count {
|
||||
SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1;
|
||||
}
|
||||
} {2 1 9 3 1 16 8}
|
||||
} {2 1 9 3 1 16 9}
|
||||
do_test where-5.100 {
|
||||
db eval {
|
||||
SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)
|
||||
|
||||
@@ -170,5 +170,20 @@ do_execsql_test whereA-5.1 {
|
||||
SELECT a FROM t1 WHERE b=-99 OR b>1;
|
||||
} {1}
|
||||
|
||||
# 2020-10-02 OSSFuzz find for an issue introduced by a check-in
|
||||
# on the previous day.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test whereA-6.1 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE INDEX t1aa ON t1(a,a);
|
||||
INSERT INTO t1 VALUES(1,2);
|
||||
ANALYZE;
|
||||
UPDATE sqlite_stat1 SET stat='27 3 3' WHERE idx='t1aa';
|
||||
ANALYZE sqlite_schema;
|
||||
PRAGMA reverse_unordered_selects (1) ;
|
||||
SELECT a FROM t1 WHERE a=1 OR a=2;
|
||||
} {1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+9
-3
@@ -220,9 +220,15 @@ do_eqp_test 5.2.4 {
|
||||
SELECT * FROM t1 WHERE likely(b>?)
|
||||
} {SCAN TABLE t1}
|
||||
|
||||
do_eqp_test 5.3.1 {
|
||||
SELECT * FROM t1 WHERE a=?
|
||||
} {SEARCH TABLE t1 USING INDEX i1 (a=?)}
|
||||
ifcapable stat4 {
|
||||
do_eqp_test 5.3.1.stat4 {
|
||||
SELECT * FROM t1 WHERE a=?
|
||||
} {SCAN TABLE t1}
|
||||
} else {
|
||||
do_eqp_test 5.3.1 {
|
||||
SELECT * FROM t1 WHERE a=?
|
||||
} {SEARCH TABLE t1 USING INDEX i1}
|
||||
}
|
||||
do_eqp_test 5.3.2 {
|
||||
SELECT * FROM t1 WHERE likelihood(a=?, 0.9)
|
||||
} {SCAN TABLE t1}
|
||||
|
||||
+37
-1
@@ -352,7 +352,7 @@ do_catchsql_test 7.4 {
|
||||
SELECT i FROM tree WHERE p IN (SELECT id FROM t)
|
||||
)
|
||||
SELECT id FROM t;
|
||||
} {1 {recursive reference in a subquery: t}}
|
||||
} {1 {circular reference: t}}
|
||||
|
||||
do_catchsql_test 7.5 {
|
||||
WITH t(id) AS (
|
||||
@@ -1171,4 +1171,40 @@ do_catchsql_test 26.0 {
|
||||
SELECT x,O. * O FROM i ¬I,I? 10;
|
||||
} {1 {near "O": syntax error}}
|
||||
|
||||
# 2020-09-17 ticket c51489c3b8f919c5
|
||||
# DISTINCT cannot be ignored in a UNION ALL recursive CTE
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 26.1 {
|
||||
CREATE TABLE t (label VARCHAR(10), step INTEGER);
|
||||
INSERT INTO T VALUES('a', 1);
|
||||
INSERT INTO T VALUES('a', 1);
|
||||
INSERT INTO T VALUES('b', 1);
|
||||
WITH RECURSIVE cte(label, step) AS (
|
||||
SELECT DISTINCT * FROM t
|
||||
UNION ALL
|
||||
SELECT label, step + 1 FROM cte WHERE step < 3
|
||||
)
|
||||
SELECT * FROM cte ORDER BY +label, +step;
|
||||
} {a 1 a 2 a 3 b 1 b 2 b 3}
|
||||
do_execsql_test 26.2 {
|
||||
WITH RECURSIVE cte(label, step) AS (
|
||||
SELECT * FROM t
|
||||
UNION
|
||||
SELECT label, step + 1 FROM cte WHERE step < 3
|
||||
)
|
||||
SELECT * FROM cte ORDER BY +label, +step;
|
||||
} {a 1 a 2 a 3 b 1 b 2 b 3}
|
||||
do_execsql_test 26.3 {
|
||||
CREATE TABLE tworow(x);
|
||||
INSERT INTO tworow(x) VALUES(1),(2);
|
||||
DELETE FROM t WHERE rowid=2;
|
||||
WITH RECURSIVE cte(label, step) AS (
|
||||
SELECT * FROM t
|
||||
UNION ALL
|
||||
SELECT DISTINCT label, step + 1 FROM cte, tworow WHERE step < 3
|
||||
)
|
||||
SELECT * FROM cte ORDER BY +label, +step;
|
||||
} {a 1 a 2 a 3 b 1 b 2 b 3}
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ do_catchsql_test 1.0 {
|
||||
SELECT 5 FROM t0 UNION SELECT 8 FROM m
|
||||
)
|
||||
SELECT * FROM i;
|
||||
} {1 {no such table: t0}}
|
||||
} {1 {no such table: m}}
|
||||
|
||||
# 2019-11-09 dbfuzzcheck find
|
||||
do_catchsql_test 1.1 {
|
||||
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
# 2020-10-19
|
||||
#
|
||||
# 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 file is recursive common table expressions with
|
||||
# multiple recursive terms in the compound select.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix with5
|
||||
|
||||
ifcapable {!cte} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 100 {
|
||||
CREATE TABLE link(aa INT, bb INT);
|
||||
CREATE INDEX link_f ON link(aa,bb);
|
||||
CREATE INDEX link_t ON link(bb,aa);
|
||||
INSERT INTO link(aa,bb) VALUES
|
||||
(1,3),
|
||||
(5,3),
|
||||
(7,1),
|
||||
(7,9),
|
||||
(9,9),
|
||||
(5,11),
|
||||
(11,7),
|
||||
(2,4),
|
||||
(4,6),
|
||||
(8,6);
|
||||
} {}
|
||||
do_execsql_test 110 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1)
|
||||
UNION
|
||||
SELECT aa FROM closure, link WHERE link.bb=closure.x
|
||||
UNION
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 3 5 7 9 11}
|
||||
do_execsql_test 111 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1)
|
||||
UNION
|
||||
SELECT aa FROM link, closure WHERE link.bb=closure.x
|
||||
UNION
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 3 5 7 9 11}
|
||||
do_execsql_test 112 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1)
|
||||
UNION
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
UNION
|
||||
SELECT aa FROM link, closure WHERE link.bb=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 3 5 7 9 11}
|
||||
do_execsql_test 113 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1),(200),(300),(400)
|
||||
INTERSECT
|
||||
VALUES(1)
|
||||
UNION
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
UNION
|
||||
SELECT aa FROM link, closure WHERE link.bb=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 3 5 7 9 11}
|
||||
do_execsql_test 114 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1),(200),(300),(400)
|
||||
UNION ALL
|
||||
VALUES(2)
|
||||
UNION
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
UNION
|
||||
SELECT aa FROM link, closure WHERE link.bb=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 2 3 4 5 6 7 8 9 11 200 300 400}
|
||||
|
||||
do_catchsql_test 120 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1),(200),(300),(400)
|
||||
UNION ALL
|
||||
VALUES(2)
|
||||
UNION ALL
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
UNION
|
||||
SELECT aa FROM link, closure WHERE link.bb=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 {circular reference: closure}}
|
||||
do_catchsql_test 121 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1),(200),(300),(400)
|
||||
UNION ALL
|
||||
VALUES(2)
|
||||
UNION
|
||||
SELECT bb FROM closure, link WHERE link.aa=closure.x
|
||||
UNION ALL
|
||||
SELECT aa FROM link, closure WHERE link.bb=closure.x
|
||||
)
|
||||
SELECT x FROM closure ORDER BY x;
|
||||
} {1 {circular reference: closure}}
|
||||
|
||||
do_execsql_test 130 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
SELECT 1 AS x
|
||||
UNION
|
||||
SELECT aa FROM link JOIN closure ON bb=x
|
||||
UNION
|
||||
SELECT bb FROM link JOIN closure on aa=x
|
||||
ORDER BY x LIMIT 4
|
||||
)
|
||||
SELECT * FROM closure;
|
||||
} {1 3 5 7}
|
||||
do_execsql_test 131 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
SELECT 1 AS x
|
||||
UNION ALL
|
||||
SELECT 2
|
||||
UNION
|
||||
SELECT aa FROM link JOIN closure ON bb=x
|
||||
UNION
|
||||
SELECT bb FROM link JOIN closure on aa=x
|
||||
ORDER BY x LIMIT 4
|
||||
)
|
||||
SELECT * FROM closure;
|
||||
} {1 2 3 4}
|
||||
|
||||
do_execsql_test 200 {
|
||||
CREATE TABLE linkA(aa1,aa2);
|
||||
INSERT INTO linkA(aa1,aa2) VALUES(1,3),(5,7),(9,11);
|
||||
CREATE TABLE linkB(bb1,bb2);
|
||||
INSERT INTO linkB(bb1,bb2) VALUES(7,9),(11,13),(3,5);
|
||||
CREATE TABLE linkC(cc1,cc2);
|
||||
INSERT INTO linkC(cc1,cc2) VALUES(1,2),(2,4),(6,8);
|
||||
CREATE TABLE linkD(dd1,dd2);
|
||||
INSERT INTO linkD(dd1,dd2) VALUES(4,6),(100,110);
|
||||
} {}
|
||||
do_execsql_test 210 {
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1)
|
||||
UNION ALL
|
||||
SELECT aa2 FROM linkA JOIN closure ON x=aa1
|
||||
UNION ALL
|
||||
SELECT bb2 FROM linkB JOIN closure ON x=bb1
|
||||
UNION ALL
|
||||
SELECT cc2 FROM linkC JOIN closure ON x=cc1
|
||||
UNION ALL
|
||||
SELECT dd2 FROM linkD JOIN closure ON x=dd1
|
||||
)
|
||||
SELECT x FROM closure ORDER BY +x;
|
||||
} {1 2 3 4 5 6 7 8 9 11 13}
|
||||
do_execsql_test 220 {
|
||||
CREATE TABLE linkA_ipk(aa1 INTEGER PRIMARY KEY,aa2);
|
||||
INSERT INTO linkA_ipk(aa1,aa2) SELECT aa1, aa2 FROM linkA;
|
||||
CREATE TABLE linkB_ipk(bb1 INTEGER PRIMARY KEY,bb2);
|
||||
INSERT INTO linkB_ipk(bb1,bb2) SELECT bb1, bb2 FROM linkB;
|
||||
CREATE TABLE linkC_ipk(cc1 INTEGER PRIMARY KEY,cc2);
|
||||
INSERT INTO linkC_ipk(cc1,cc2) SELECT cc1, cc2 FROM linkC;
|
||||
CREATE TABLE linkD_ipk(dd1 INTEGER PRIMARY KEY,dd2);
|
||||
INSERT INTO linkD_ipk(dd1,dd2) SELECT dd1, dd2 FROM linkD;
|
||||
WITH RECURSIVE closure(x) AS (
|
||||
VALUES(1)
|
||||
UNION ALL
|
||||
SELECT aa2 FROM linkA_ipk JOIN closure ON x=aa1
|
||||
UNION ALL
|
||||
SELECT bb2 FROM linkB_ipk JOIN closure ON x=bb1
|
||||
UNION ALL
|
||||
SELECT cc2 FROM linkC_ipk JOIN closure ON x=cc1
|
||||
UNION ALL
|
||||
SELECT dd2 FROM linkD_ipk JOIN closure ON x=dd1
|
||||
)
|
||||
SELECT x FROM closure ORDER BY +x;
|
||||
} {1 2 3 4 5 6 7 8 9 11 13}
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -341,7 +341,7 @@ do_execsql_test 7.1 {
|
||||
} {}
|
||||
do_catchsql_test 7.2 {
|
||||
INSERT INTO t70a(rowid,a,b) VALUES(33,99,'xyzzy');
|
||||
} {1 {CHECK constraint failed: t70a}}
|
||||
} {1 {CHECK constraint failed: rowid!=33}}
|
||||
do_catchsql_test 7.3 {
|
||||
CREATE TABLE t70b(
|
||||
a INT CHECK( rowid!=33 ),
|
||||
|
||||
@@ -417,14 +417,14 @@ do_test without_rowid3-3.1.2 {
|
||||
} {}
|
||||
do_test without_rowid3-3.1.3 {
|
||||
catchsql { UPDATE ab SET a = 5 }
|
||||
} {1 {CHECK constraint failed: ef}}
|
||||
} {1 {CHECK constraint failed: e!=5}}
|
||||
do_test without_rowid3-3.1.4 {
|
||||
execsql { SELECT * FROM ab }
|
||||
} {1 b}
|
||||
do_test without_rowid3-3.1.4 {
|
||||
execsql BEGIN;
|
||||
catchsql { UPDATE ab SET a = 5 }
|
||||
} {1 {CHECK constraint failed: ef}}
|
||||
} {1 {CHECK constraint failed: e!=5}}
|
||||
do_test without_rowid3-3.1.5 {
|
||||
execsql COMMIT;
|
||||
execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }
|
||||
|
||||
Reference in New Issue
Block a user