summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 17:30:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 17:30:13 +0000
commit5e33abd9c783fe2b9deae602544f1f6f0889958a (patch)
tree120f37dcc1339c59c97cd336badef4633015ec23 /test
parentAdding upstream version 3.45.2. (diff)
downloadsqlite3-5e33abd9c783fe2b9deae602544f1f6f0889958a.tar.xz
sqlite3-5e33abd9c783fe2b9deae602544f1f6f0889958a.zip
Adding upstream version 3.45.3.upstream/3.45.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--test/default.test4
-rw-r--r--test/func.test21
-rw-r--r--test/fuzzinvariants.c8
-rw-r--r--test/join5.test8
-rw-r--r--test/joinH.test38
-rw-r--r--test/misc2.test29
-rw-r--r--test/misc8.test7
-rw-r--r--test/pragma4.test18
-rw-r--r--test/returning1.test43
-rw-r--r--test/rowid.test37
-rw-r--r--test/scanstatus2.test2
-rw-r--r--test/trigger9.test27
-rw-r--r--test/unionall.test2
-rw-r--r--test/vacuum-into.test35
14 files changed, 233 insertions, 46 deletions
diff --git a/test/default.test b/test/default.test
index 06a180c..de67f64 100644
--- a/test/default.test
+++ b/test/default.test
@@ -136,5 +136,9 @@ do_catchsql_test default-5.1 {
CREATE TABLE t1 (a,b DEFAULT(random() NOTNULL IN (RAISE(IGNORE),2,3)));
INSERT INTO t1(a) VALUES(1);
} {1 {RAISE() may only be used within a trigger-program}}
+do_catchsql_test default-5.2 {
+ CREATE TABLE Table0 (Col0 DEFAULT (RAISE(IGNORE) ) ) ;
+ INSERT INTO Table0 DEFAULT VALUES ;
+} {1 {RAISE() may only be used within a trigger-program}}
finish_test
diff --git a/test/func.test b/test/func.test
index c7b8f72..a3ecd4e 100644
--- a/test/func.test
+++ b/test/func.test
@@ -1561,4 +1561,25 @@ do_execsql_test func-38.100 {
WITH t1(x) AS (VALUES(-9e+999)) SELECT sum(x), avg(x), total(x) FROM t1;
} {Inf Inf Inf -Inf -Inf -Inf}
+# 2024-03-21 https://sqlite.org/forum/forumpost/23b8688ef4
+# Another problem with Kahan-Babushka-Neumaier summation and
+# infinities.
+#
+do_execsql_test func-39.101 {
+ WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<1)
+ SELECT sum(1.7976931348623157e308),
+ avg(1.7976931348623157e308),
+ total(1.7976931348623157e308)
+ FROM c;
+} {1.79769313486232e+308 1.79769313486232e+308 1.79769313486232e+308}
+for {set i 2} {$i<10} {incr i} {
+ do_execsql_test func-39.[expr {10*$i+100}] {
+ WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<$i)
+ SELECT sum(1.7976931348623157e308),
+ avg(1.7976931348623157e308),
+ total(1.7976931348623157e308)
+ FROM c;
+ } {Inf Inf Inf}
+}
+
finish_test
diff --git a/test/fuzzinvariants.c b/test/fuzzinvariants.c
index 5d473f1..00b2c11 100644
--- a/test/fuzzinvariants.c
+++ b/test/fuzzinvariants.c
@@ -296,6 +296,14 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){
** WHERE clause. */
continue;
}
+#ifdef SQLITE_ALLOW_ROWID_IN_VIEW
+ if( sqlite3_strlike("%rowid%",zColName,0)==0
+ || sqlite3_strlike("%oid%",zColName,0)==0
+ ){
+ /* ROWID values are unreliable if SQLITE_ALLOW_ROWID_IN_VIEW is used */
+ continue;
+ }
+#endif
for(j=0; j<i; j++){
const char *zPrior = sqlite3_column_name(pBase, j);
if( sqlite3_stricmp(zPrior, zColName)==0 ) break;
diff --git a/test/join5.test b/test/join5.test
index 44c8b71..703c256 100644
--- a/test/join5.test
+++ b/test/join5.test
@@ -370,8 +370,12 @@ do_execsql_test 9.1 {
ANALYZE sqlite_schema;
INSERT INTO sqlite_stat1 VALUES('t1','t1x1','648 324 81 81 81 81 81 81 81081 81 81 81');
ANALYZE sqlite_schema;
- SELECT a FROM (SELECT a FROM t1 NATURAL LEFT JOIN t1) NATURAL LEFT JOIN t1 WHERE (rowid,1)<=(5,0);
-} {1}
+}
+do_catchsql_test 9.2 {
+ SELECT a FROM
+ (SELECT a FROM t1 NATURAL LEFT JOIN t1) NATURAL LEFT JOIN t1
+ WHERE (rowid,1)<=(5,0);
+} {0 1}
# 2022-03-02 https://sqlite.org/forum/info/50a1bbe08ce4c29c
# Bloom-filter pulldown is incompatible with skip-scan.
diff --git a/test/joinH.test b/test/joinH.test
index 3702266..908b93d 100644
--- a/test/joinH.test
+++ b/test/joinH.test
@@ -201,13 +201,13 @@ do_execsql_test 9.0 {
do_catchsql_test 9.1 {
SELECT rowid FROM wo1, x1, x2;
-} {1 {no such column: rowid}}
+} {1 {ambiguous column name: rowid}}
do_catchsql_test 9.2 {
SELECT rowid FROM wo1, (x1, x2);
-} {1 {no such column: rowid}}
+} {1 {ambiguous column name: rowid}}
do_catchsql_test 9.3 {
SELECT rowid FROM wo1 JOIN (x1 JOIN x2);
-} {1 {no such column: rowid}}
+} {1 {ambiguous column name: rowid}}
do_catchsql_test 9.4 {
SELECT a FROM wo1, x1, x2;
} {1 {ambiguous column name: a}}
@@ -309,4 +309,36 @@ do_execsql_test 12.3 {
SELECT * FROM t1 LEFT JOIN t2 ON true RIGHT JOIN t3 ON d2=e3 WHERE c2 BETWEEN NULL AND a1;
}
+#-------------------------------------------------------------------------
+# 2024-04-05 dbsqlfuzz b9e65e2f110df998f1306571fae7af6c01e4d92b
+reset_db
+do_execsql_test 13.1 {
+ CREATE TABLE t1(a INT AS (b), b INT);
+ INSERT INTO t1(b) VALUES(123);
+ CREATE TABLE t2(a INT, c INT);
+ SELECT a FROM t2 NATURAL RIGHT JOIN t1;
+} {123}
+do_execsql_test 13.2 {
+ CREATE INDEX t1a ON t1(a);
+ SELECT a FROM t2 NATURAL RIGHT JOIN t1;
+} {123}
+# Further tests of the same logic (indexes on expressions
+# used by RIGHT JOIN) from check-in ffe23af73fcb324d and
+# forum post https://sqlite.org/forum/forumpost/9b491e1debf0b67a.
+db null NULL
+do_execsql_test 13.3 {
+ CREATE TABLE t3(a INT, b INT);
+ CREATE UNIQUE INDEX t3x ON t3(a, a+b);
+ INSERT INTO t3(a,b) VALUES(1,2),(4,8),(16,32),(4,80),(1,-300);
+ CREATE TABLE t4(x INT, y INT);
+ INSERT INTO t4(x,y) SELECT a, b FROM t3;
+ INSERT INTO t4(x,y) VALUES(99,99);
+ SELECT a1.a, sum( a1.a+a1.b ) FROM t3 AS a1 RIGHT JOIN t4 ON a=x
+ GROUP BY a1.a ORDER BY 1;
+} {NULL NULL 1 -592 4 192 16 48}
+do_execsql_test 13.4 {
+ SELECT sum( a1.a+a1.b ) FROM t3 AS a1 RIGHT JOIN t3 ON true
+ GROUP BY a1.a ORDER BY 1;
+} {-1480 240 480}
+
finish_test
diff --git a/test/misc2.test b/test/misc2.test
index 4796d5d..607799e 100644
--- a/test/misc2.test
+++ b/test/misc2.test
@@ -54,19 +54,34 @@ do_test misc2-2.1 {
}
} {}
ifcapable subquery {
- do_catchsql_test misc2-2.2 {
- SELECT rowid, * FROM (SELECT * FROM t1, t2);
- } {1 {no such column: rowid}}
+ ifcapable allow_rowid_in_view {
+ do_catchsql_test misc2-2.2 {
+ SELECT rowid, * FROM (SELECT * FROM t1, t2);
+ } {0 {{} 1 2 3 7 8 9}}
+ } else {
+ do_catchsql_test misc2-2.2 {
+ SELECT rowid, * FROM (SELECT * FROM t1, t2);
+ } {1 {no such column: rowid}}
+ }
do_catchsql_test misc2-2.2b {
SELECT 'rowid', * FROM (SELECT * FROM t1, t2);
} {0 {rowid 1 2 3 7 8 9}}
}
ifcapable view {
- do_catchsql_test misc2-2.3 {
- CREATE VIEW v1 AS SELECT * FROM t1, t2;
- SELECT rowid, * FROM v1;
- } {1 {no such column: rowid}}
+ ifcapable allow_rowid_in_view {
+ do_catchsql_test misc2-2.3 {
+ CREATE VIEW v1 AS SELECT * FROM t1, t2;
+ SELECT rowid, * FROM v1;
+ } {0 {{} 1 2 3 7 8 9}}
+ } else {
+ do_catchsql_test misc2-2.3 {
+ CREATE VIEW v1 AS SELECT * FROM t1, t2;
+ SELECT rowid, * FROM v1;
+ } {1 {no such column: rowid}}
+ }
+
+
do_catchsql_test misc2-2.3b {
SELECT 'rowid', * FROM v1;
} {0 {rowid 1 2 3 7 8 9}}
diff --git a/test/misc8.test b/test/misc8.test
index 32b3a59..60b44fe 100644
--- a/test/misc8.test
+++ b/test/misc8.test
@@ -100,6 +100,11 @@ do_execsql_test misc8-2.1 {
# 2016-02-26: An assertion fault found by the libFuzzer project
#
+ifcapable allow_rowid_in_view {
+ set nosuch "1 {ambiguous column name: rowid}"
+} else {
+ set nosuch "1 {no such column: rowid}"
+}
do_catchsql_test misc8-3.0 {
SELECT *
FROM
@@ -110,7 +115,7 @@ do_catchsql_test misc8-3.0 {
(SELECT 6 AS j UNION ALL SELECT 7) AS x4
WHERE i<rowid
ORDER BY 1;
-} {1 {no such column: rowid}}
+} $nosuch
# The SQLITE_DBCONFIG_MAINDBNAME interface
#
diff --git a/test/pragma4.test b/test/pragma4.test
index b82df81..97c6226 100644
--- a/test/pragma4.test
+++ b/test/pragma4.test
@@ -83,7 +83,7 @@ foreach {tn sql} {
# Verify that that P4_INTARRAY argument to OP_IntegrityCk is rendered
# correctly.
#
-db close
+catch {db close}
forcedelete test.db
sqlite3 db test.db
do_test pragma4-2.100 {
@@ -264,5 +264,21 @@ do_execsql_test 5.0 {
0 a {} 0 'abc' 0 1 b {} 0 -1 0 2 c {} 0 +4.0 0
}
+# 2024-03-24 https://sqlite.org/forum/forumpost/85b6a8b6705fb77a
+#
+catch {db2 close}
+catch {db3 close}
+ifcapable vtab {
+ reset_db
+ do_execsql_test 6.0 {
+ CREATE TABLE t1(a INT PRIMARY KEY, b INT);
+ CREATE TABLE t2(c INT PRIMARY KEY, d INT REFERENCES t1);
+ SELECT t.name, f."table", f."from", i.name, i.pk
+ FROM pragma_table_list() AS t
+ JOIN pragma_foreign_key_list(t.name, t.schema) AS f
+ JOIN pragma_table_info(f."table", t.schema) AS i
+ WHERE i.pk;
+ } {t2 t1 d a 1}
+}
finish_test
diff --git a/test/returning1.test b/test/returning1.test
index 6c098dc..2403249 100644
--- a/test/returning1.test
+++ b/test/returning1.test
@@ -212,17 +212,38 @@ do_execsql_test 10.2 {
END;
}
-do_catchsql_test 10.3a {
- INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid;
-} {1 {no such column: new.rowid}}
-
-do_catchsql_test 10.3b {
- UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid;
-} {1 {no such column: new.rowid}}
-
-do_execsql_test 10.4 {
- SELECT * FROM log;
-} {}
+ifcapable !allow_rowid_in_view {
+ do_catchsql_test 10.3a {
+ INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid;
+ } {1 {no such column: new.rowid}}
+
+ do_catchsql_test 10.3b {
+ UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid;
+ } {1 {no such column: new.rowid}}
+
+ do_execsql_test 10.4 {
+ SELECT * FROM log;
+ } {}
+} else {
+ # Note: The values returned by the RETURNING clauses of the following
+ # two statements are the rowid columns of views. These values are not
+ # well defined, so the INSERT returns -1, and the UPDATE returns 1, 2
+ # and 3. These match the values used for new.rowid expressions, but
+ # not much else.
+ do_catchsql_test 10.3a {
+ INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid;
+ } {0 -1}
+
+ do_catchsql_test 10.3b {
+ UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid;
+ } {0 {1 2 3}}
+
+ do_execsql_test 10.4 {
+ SELECT * FROM log;
+ } {
+ insert -1 1234 5678 update 1 z y update 2 z y update 3 z y
+ }
+}
# 2021-04-27 dbsqlfuzz 78b9400770ef8cc7d9427dfba26f4fcf46ea7dc2
# Returning clauses on TEMP tables with triggers.
diff --git a/test/rowid.test b/test/rowid.test
index 4327004..84f0e4d 100644
--- a/test/rowid.test
+++ b/test/rowid.test
@@ -803,18 +803,31 @@ do_execsql_test 16.0 {
INSERT INTO t3(rowid, z) VALUES(3, 3);
}
-do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1}
-do_execsql_test 16.2 { SELECT rowid FROM t1, v1; } {1}
-do_execsql_test 16.3 { SELECT rowid FROM t3, v1; } {3}
-do_execsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } {3}
-
-do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1}
-do_execsql_test 16.6 { SELECT rowid FROM v1, t1; } {1}
-do_execsql_test 16.7 { SELECT rowid FROM v1, t3; } {3}
-do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3}
-
-do_catchsql_test 16.5 { SELECT rowid FROM t1, t3; } {1 {no such column: rowid}}
-
+ifcapable allow_rowid_in_view {
+ set nosuch "1 {ambiguous column name: rowid}"
+ do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1}
+ do_catchsql_test 16.2 { SELECT rowid FROM t1, v1; } $nosuch
+ do_catchsql_test 16.3 { SELECT rowid FROM t3, v1; } $nosuch
+ do_catchsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } $nosuch
+
+ do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1}
+ do_catchsql_test 16.6 { SELECT rowid FROM v1, t1; } $nosuch
+ do_catchsql_test 16.7 { SELECT rowid FROM v1, t3; } $nosuch
+ do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3}
+} else {
+ do_execsql_test 16.1 { SELECT rowid FROM t1, t2; } {1}
+ do_execsql_test 16.2 { SELECT rowid FROM t1, v1; } {1}
+ do_execsql_test 16.3 { SELECT rowid FROM t3, v1; } {3}
+ do_execsql_test 16.4 { SELECT rowid FROM t3, (SELECT 123); } {3}
+
+ do_execsql_test 16.5 { SELECT rowid FROM t2, t1; } {1}
+ do_execsql_test 16.6 { SELECT rowid FROM v1, t1; } {1}
+ do_execsql_test 16.7 { SELECT rowid FROM v1, t3; } {3}
+ do_execsql_test 16.8 { SELECT rowid FROM (SELECT 123), t3; } {3}
+}
+do_catchsql_test 16.9 {
+ SELECT rowid FROM t1, t3;
+} {1 {ambiguous column name: rowid}}
finish_test
diff --git a/test/scanstatus2.test b/test/scanstatus2.test
index e4b510d..ca3a42f 100644
--- a/test/scanstatus2.test
+++ b/test/scanstatus2.test
@@ -247,7 +247,7 @@ QUERY (nCycle=nnn)
----SCAN rt2 (nCycle=nnn)
----USE TEMP B-TREE FOR GROUP BY (nCycle=nnn)
--SCAN rt1 (nCycle=nnn)
---CREATE AUTOMATIC INDEX ON v1(x1, cnt) (nCycle=nnn)
+--CREATE AUTOMATIC INDEX ON v1(x1, cnt, x1) (nCycle=nnn)
--BLOOM FILTER ON v1 (x1=?)
--SEARCH v1 USING AUTOMATIC COVERING INDEX (x1=?) (nCycle=nnn)
}
diff --git a/test/trigger9.test b/test/trigger9.test
index 6e31d1a..47940de 100644
--- a/test/trigger9.test
+++ b/test/trigger9.test
@@ -242,12 +242,27 @@ do_execsql_test 4.1 {
END;
}
-do_catchsql_test 4.2 {
- DELETE FROM v1 WHERE rowid=1;
-} {1 {no such column: rowid}}
+ifcapable !allow_rowid_in_view {
+ do_catchsql_test 4.2 {
+ DELETE FROM v1 WHERE rowid=1;
+ } {1 {no such column: rowid}}
-do_catchsql_test 4.3 {
- UPDATE v1 SET a=b WHERE rowid=2;
-} {1 {no such column: rowid}}
+ do_catchsql_test 4.3 {
+ UPDATE v1 SET a=b WHERE rowid=2;
+ } {1 {no such column: rowid}}
+} else {
+ do_execsql_test 4.2a {
+ DELETE FROM log;
+ }
+ do_catchsql_test 4.2 {
+ DELETE FROM v1 WHERE rowid=1;
+ } {0 {}}
+ do_catchsql_test 4.3 {
+ UPDATE v1 SET a=b WHERE rowid=2;
+ } {0 {}}
+ do_execsql_test 4.3b {
+ SELECT * FROM log;
+ }
+}
finish_test
diff --git a/test/unionall.test b/test/unionall.test
index 99cb48a..9057199 100644
--- a/test/unionall.test
+++ b/test/unionall.test
@@ -351,7 +351,7 @@ do_catchsql_test 5.30 {
SELECT * FROM (t1 NATURAL JOIN pragma_table_xinfo('t1_a') NATURAL JOIN t3) t1
NATURAL JOIN t2 NATURAL JOIN t3
WHERE rowid ISNULL>0 AND 0%y;
-} {1 {no such column: rowid}}
+} {1 {ambiguous column name: rowid}}
}
reset_db
diff --git a/test/vacuum-into.test b/test/vacuum-into.test
index 698d65f..d559b7f 100644
--- a/test/vacuum-into.test
+++ b/test/vacuum-into.test
@@ -26,13 +26,36 @@ ifcapable {!vacuum} {
forcedelete out.db
do_execsql_test vacuum-into-100 {
- CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t1(
+ a INTEGER PRIMARY KEY,
+ b ANY,
+ c INT AS (b+1), --- See "2024-04-09" block
+ CHECK( typeof(b)!='integer' OR b>a-5 ) --- comment below
+ );
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
INSERT INTO t1(a,b) SELECT x, randomblob(600) FROM c;
CREATE INDEX t1b ON t1(b);
DELETE FROM t1 WHERE a%2;
SELECT count(*), sum(a), sum(length(b)) FROM t1;
} {50 2550 30000}
+
+# Update 2024-04-09 for forum post eec177d68fe7fa2c.
+#
+# VACUUM INTO is sensitive to tables holding both generated columns
+# and CHECK constraints.
+#
+# CHECK constraints are ignored for read-only databases in order to save
+# memory (see check-in 34ddf02d3d21151b on 2014-05-21). But the xfer
+# optimization normally only works if CHECK constraints match between the
+# source and destination tables. So the xfer optimization was not
+# working for VACUUM INTO when the source was a read-only database and the
+# table held CHECK constraints. But if the table has generated columns,
+# then the xfer optimization is required or else VACUUM will raise an
+# error.
+#
+# Fix this by ignoring CHECK constraints when determining whether or not
+# the xfer optimization can run while doing VACUUM.
+
do_execsql_test vacuum-into-110 {
VACUUM main INTO 'out.db';
} {}
@@ -88,11 +111,21 @@ do_catchsql_test vacuum-into-420 {
# The ability to VACUUM INTO a read-only database
db close
+if {$tcl_platform(platform)=="windows"} {
+ file attributes test.db -readonly 1
+} else {
+ file attributes test.db -permissions 292 ;# 292 == 0444
+}
sqlite3 db test.db -readonly 1
forcedelete test.db2
do_execsql_test vacuum-into-500 {
VACUUM INTO 'test.db2';
}
+if {$tcl_platform(platform)=="windows"} {
+ file attributes test.db -readonly 0
+} else {
+ file attributes test.db -permissions 420 ;# 420 = 0644
+}
sqlite3 db2 test.db2
do_test vacuum-into-510 {
db2 eval {SELECT name FROM sqlite_master ORDER BY 1}