summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/func.test8
-rw-r--r--test/fuzzcheck.c4
-rw-r--r--test/json101.test14
-rw-r--r--test/memdb1.test15
-rw-r--r--test/notnull2.test16
-rw-r--r--test/pragma.test15
-rw-r--r--test/printf.test17
-rw-r--r--test/shell5.test14
-rw-r--r--test/types3.test30
-rw-r--r--test/upsert5.test42
10 files changed, 166 insertions, 9 deletions
diff --git a/test/func.test b/test/func.test
index 883950a..c7b8f72 100644
--- a/test/func.test
+++ b/test/func.test
@@ -786,6 +786,11 @@ do_test func-16.1 {
}
} {X'616263' NULL}
+# Test the quote function for +Inf and -Inf
+do_execsql_test func-16.2 {
+ SELECT quote(4.2e+859), quote(-7.8e+904);
+} {9.0e+999 -9.0e+999}
+
# Correctly handle function error messages that include %. Ticket #1354
#
do_test func-17.1 {
@@ -1042,6 +1047,9 @@ do_test func-21.8 {
SELECT replace('aaaaaaa', 'a', '0123456789');
}
} {0123456789012345678901234567890123456789012345678901234567890123456789}
+do_execsql_test func-21.9 {
+ SELECT typeof(replace(1,'',0));
+} {text}
ifcapable tclvar {
do_test func-21.9 {
diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c
index dd49120..e4ad1c1 100644
--- a/test/fuzzcheck.c
+++ b/test/fuzzcheck.c
@@ -161,8 +161,8 @@ static struct GlobalVars {
/*
** Include the external vt02.c and randomjson.c modules.
*/
-extern int sqlite3_vt02_init(sqlite3*,char***,void*);
-extern int sqlite3_randomjson_init(sqlite3*,char***,void*);
+extern int sqlite3_vt02_init(sqlite3*,char**,const sqlite3_api_routines*);
+extern int sqlite3_randomjson_init(sqlite3*,char**,const sqlite3_api_routines*);
/*
diff --git a/test/json101.test b/test/json101.test
index bae68e7..3963ffb 100644
--- a/test/json101.test
+++ b/test/json101.test
@@ -378,6 +378,20 @@ do_execsql_test json101-5.8 {
WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
} {}
+# 2024-02-16 https://sqlite.org/forum/forumpost/ecb94cd210
+# Regression in json_tree()/json_each(). The value column
+# should have the "J" subtype if the value is an array or
+# object.
+#
+do_execsql_test json101-5.10 {
+ SELECT json_insert('{}','$.a',value) FROM json_tree('[1,2,3]') WHERE atom IS NULL;
+} {{{"a":[1,2,3]}}}
+# ^^^^^^^--- In double-quotes, a string literal, prior to bug fix
+
+do_execsql_test json101-5.11 {
+ SELECT json_insert('{}','$.a',value) FROM json_tree('"[1,2,3]"');
+} {{{"a":"[1,2,3]"}}}
+
do_execsql_test json101-6.1 {
SELECT json_valid('{"a":55,"b":72,}');
} {0}
diff --git a/test/memdb1.test b/test/memdb1.test
index 5e219a4..3a31c8e 100644
--- a/test/memdb1.test
+++ b/test/memdb1.test
@@ -84,7 +84,6 @@ do_test 152 {
catchsql {INSERT INTO t1 VALUES(3,4);}
} {1 {attempt to write a readonly database}}
-breakpoint
do_test 160 {
db deserialize -maxsize 32768 $db1
db eval {SELECT * FROM t1}
@@ -248,6 +247,7 @@ if {[wal_is_capable]} {
set fd [open test.db]
fconfigure $fd -translation binary -encoding binary
set data [read $fd [expr 20*1024]]
+ close $fd
sqlite3 db ""
db deserialize $data
@@ -267,4 +267,17 @@ if {[wal_is_capable]} {
} {1 {database disk image is malformed}}
}
+# 2024-01-20
+# https://sqlite.org/forum/forumpost/498777780e16880a
+#
+# Make sure a database is initialized before serializing it.
+#
+reset_db
+sqlite3 dbempty :memory:
+do_test 900 {
+ set len [string length [dbempty serialize]]
+ expr {$len>0}
+} 1
+dbempty close
+
finish_test
diff --git a/test/notnull2.test b/test/notnull2.test
index 7f68086..09161ef 100644
--- a/test/notnull2.test
+++ b/test/notnull2.test
@@ -59,14 +59,14 @@ do_vmstep_test 1.4.2 {
do_vmstep_test 1.5.1 {
SELECT count(*) FROM t2 WHERE EXISTS(
- SELECT t2.d IS NULL FROM t1 WHERE t1.a=450
+ SELECT 1 FROM t1 WHERE t1.a=450 AND t2.d IS NULL
)
-} 10000 {1000}
+} 7000 {0}
do_vmstep_test 1.5.2 {
SELECT count(*) FROM t2 WHERE EXISTS(
- SELECT t2.c IS NULL FROM t1 WHERE t1.a=450
+ SELECT 1 FROM t1 WHERE t1.a=450 AND t2.c IS NULL
)
-} +100000 {1000}
+} +8000 {0}
#-------------------------------------------------------------------------
reset_db
@@ -111,4 +111,12 @@ do_execsql_test 4.1 {
SELECT * FROM (SELECT 3 AS c FROM t1) AS t3 LEFT JOIN t2 ON c IS NULL;
} {3 {}}
+# 2024-03-08 https://sqlite.org/forum/forumpost/440f2a2f17
+#
+reset_db
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a INT NOT NULL);
+ SELECT a IS NULL, a IS NOT NULL, count(*) FROM t1;
+} {1 0 0}
+
finish_test
diff --git a/test/pragma.test b/test/pragma.test
index 5b45a74..8f78a7e 100644
--- a/test/pragma.test
+++ b/test/pragma.test
@@ -556,6 +556,21 @@ ifcapable altertable {
do_execsql_test pragma-3.23 {
PRAGMA integrity_check(1);
} {{non-unique entry in index t1a}}
+
+ # forum post https://sqlite.org/forum/forumpost/ee4f6fa5ab
+ do_execsql_test pragma-3.24 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a);
+ INSERT INTO t1 VALUES (1);
+ ALTER TABLE t1 ADD COLUMN b NOT NULL DEFAULT 0.25;
+ SELECT * FROM t1;
+ PRAGMA integrity_check(t1);
+ } {1 0.25 ok}
+ do_execsql_test pragma-3.25 {
+ ALTER TABLE t1 ADD COLUMN c CHECK (1);
+ SELECT * FROM t1;
+ PRAGMA integrity_check(t1);
+ } {1 0.25 {} ok}
}
# PRAGMA integrity check (or more specifically the sqlite3BtreeCount()
diff --git a/test/printf.test b/test/printf.test
index 6d4ad71..cc439e6 100644
--- a/test/printf.test
+++ b/test/printf.test
@@ -3833,4 +3833,21 @@ do_execsql_test printf-18.1 {
SELECT length( format('%,.249f', -5.0e-300) );
} {252}
+# 2024-02-16
+# https://sqlite.org/forum/info/393708f4a8
+#
+# The problem introduced by on 2023-07-03 by
+# https://sqlite.org/src/info/32befb224b254639
+#
+do_execsql_test printf-19.1 {
+ SELECT format('%0.0f %0.0g %0.0g', 0.9, 0.09, 1.9);
+} {{1 0.09 2}}
+do_execsql_test printf-19.2 {
+ SELECT format('%0.0f %#0.0f',0.0, 0.0);
+} {{0 0.}}
+do_execsql_test printf-19.3 {
+ SELECT format('%,.0f %,.0f',12345e+10, 12345e+11);
+} {{123,450,000,000,000 1,234,500,000,000,000}}
+
+
finish_test
diff --git a/test/shell5.test b/test/shell5.test
index 39018a0..20f2ba2 100644
--- a/test/shell5.test
+++ b/test/shell5.test
@@ -570,4 +570,18 @@ SELECT * FROM t1;}
} {0 { 1 = あい
2 = うえお}}
+# 2024-03-11 https://sqlite.org/forum/forumpost/ca014d7358
+# Import into a table that contains computed columns.
+#
+do_test shell5-7.1 {
+ set out [open shell5.csv w]
+ fconfigure $out -translation lf
+ puts $out {aaa|bbb}
+ close $out
+ forcedelete test.db
+ catchcmd :memory: {CREATE TABLE t1(a TEXT, b TEXT, c AS (a||b));
+.import shell5.csv t1
+SELECT * FROM t1;}
+} {0 aaa|bbb|aaabbb}
+
finish_test
diff --git a/test/types3.test b/test/types3.test
index 807ae84..0ff346c 100644
--- a/test/types3.test
+++ b/test/types3.test
@@ -12,8 +12,6 @@
# of this file is testing the interaction of SQLite manifest types
# with Tcl dual-representations.
#
-# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $
-#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -96,4 +94,32 @@ do_test types3-2.6 {
tcl_variable_type V
} {}
+# See https://sqlite.org/forum/forumpost/3776b48e71
+#
+# On a text-affinity comparison of two values where one of
+# the values has both MEM_Str and a numeric type like MEM_Int,
+# make sure that only the MEM_Str representation is used.
+#
+sqlite3_create_function db
+do_execsql_test types3-3.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(x TEXT PRIMARY KEY);
+ INSERT INTO t1 VALUES('1');
+ SELECT * FROM t1 WHERE NOT x=upper(1);
+} {}
+do_execsql_test types3-3.2 {
+ SELECT * FROM t1 WHERE NOT x=add_text_type(1);
+} {}
+do_execsql_test types3-3.3 {
+ SELECT * FROM t1 WHERE NOT x=add_int_type('1');
+} {}
+do_execsql_test types3-3.4 {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(1.25);
+ SELECT * FROM t1 WHERE NOT x=add_real_type('1.25');
+} {}
+do_execsql_test types3-3.5 {
+ SELECT * FROM t1 WHERE NOT x=add_text_type(1.25);
+} {}
+
finish_test
diff --git a/test/upsert5.test b/test/upsert5.test
index 3161abf..e56e71d 100644
--- a/test/upsert5.test
+++ b/test/upsert5.test
@@ -408,4 +408,46 @@ do_catchsql_test 2.1 {
} {1 {no such table: nosuchtable}}
+# 2024-03-08 https://sqlite.org/forum/forumpost/919c6579c8
+# A redundant ON CONFLICT clause in an upsert can lead to
+# index corruption.
+#
+reset_db
+do_execsql_test 3.0 {
+ CREATE TABLE t1(aa INTEGER PRIMARY KEY, bb INT);
+ INSERT INTO t1 VALUES(11,22);
+ CREATE UNIQUE INDEX t1bb ON t1(bb);
+ REPLACE INTO t1 VALUES(11,33)
+ ON CONFLICT(bb) DO UPDATE SET aa = 44
+ ON CONFLICT(bb) DO UPDATE SET aa = 44;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 3.1 {
+ SELECT * FROM t1 NOT INDEXED;
+} {11 33}
+do_execsql_test 3.2 {
+ SELECT * FROM t1 INDEXED BY t1bb;
+} {11 33}
+do_execsql_test 3.3 {
+ DROP TABLE t1;
+ CREATE TABLE t1(aa INTEGER PRIMARY KEY, bb INT, cc INT);
+ INSERT INTO t1 VALUES(10,21,32),(11,22,33),(12,23,34);
+ CREATE UNIQUE INDEX t1bb ON t1(bb);
+ CREATE UNIQUE INDEX t1cc ON t1(cc);
+ REPLACE INTO t1 VALUES(11,44,55)
+ ON CONFLICT(bb) DO UPDATE SET aa = 99
+ ON CONFLICT(cc) DO UPDATE SET aa = 99
+ ON CONFLICT(bb) DO UPDATE SET aa = 99;
+ PRAGMA integrity_check;
+} {ok}
+do_execsql_test 3.4 {
+ SELECT * FROM t1 NOT INDEXED ORDER BY +aa;
+} {10 21 32 11 44 55 12 23 34}
+do_execsql_test 3.5 {
+ SELECT * FROM t1 INDEXED BY t1bb ORDER BY +aa;
+} {10 21 32 11 44 55 12 23 34}
+do_execsql_test 3.6 {
+ SELECT * FROM t1 INDEXED BY t1cc ORDER BY +aa;
+} {10 21 32 11 44 55 12 23 34}
+
finish_test