1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Merge the latest trunk changes into the reuse-schema branch.

FossilOrigin-Name: 3d1b0403d657cf147cda58eee0f05f5e2837a10f1741375db77e11cc53c4a476
This commit is contained in:
drh
2023-12-28 14:07:27 +00:00
61 changed files with 1944 additions and 430 deletions

View File

@@ -472,6 +472,16 @@ do_execsql_test 9.5 {
FROM t1;
} {6}
# 2023-12-16
# New test case for check-in [4470f657d2069972] from 2023-11-02
# https://bugs.chromium.org/p/chromium/issues/detail?id=1511689
#
do_execsql_test 10.1 {
DROP TABLE IF EXISTS t0;
DROP TABLE IF EXISTS t1;
CREATE TABLE t0(c1, c2); INSERT INTO t0 VALUES(1,2);
CREATE TABLE t1(c3, c4); INSERT INTO t1 VALUES(3,4);
SELECT * FROM t0 WHERE EXISTS (SELECT 1 FROM t1 GROUP BY c3 HAVING ( SELECT count(*) FROM (SELECT 1 UNION ALL SELECT sum(DISTINCT c1) ) ) ) BETWEEN 1 AND 1;
} {1 2}
finish_test

View File

@@ -118,5 +118,45 @@ do_execsql_test aggorderby-8.2 {
SELECT sum(DISTINCT x ORDER BY y) FROM c;
} 6
# Subtype information is transfered through the sorter for aggregates
# that make use of subtype info.
#
do_execsql_test aggorderby-9.0 {
WITH c(x,y) AS (VALUES
('{a:3}', 3),
('[1,1]', 1),
('[4,4]', 4),
('{x:2}', 2))
SELECT json_group_array(json(x) ORDER BY y) FROM c;
} {{[[1,1],{"x":2},{"a":3},[4,4]]}}
do_execsql_test aggorderby-9.1 {
WITH c(x,y) AS (VALUES
('[4,4]', 4),
('{a:3}', 3),
('[4,4]', 4),
('[1,1]', 1),
('[4,4]', 4),
('{x:2}', 2))
SELECT json_group_array(DISTINCT json(x) ORDER BY y) FROM c;
} {{[[1,1],{"x":2},{"a":3},[4,4]]}}
do_execsql_test aggorderby-9.2 {
WITH c(x,y) AS (VALUES
('{a:3}', 3),
('[1,1]', 1),
('[4,4]', 4),
('{x:2}', 2))
SELECT json_group_array(json(x) ORDER BY json(x)) FROM c;
} {{[[1,1],[4,4],{"a":3},{"x":2}]}}
do_execsql_test aggorderby-9.3 {
WITH c(x,y) AS (VALUES
('[4,4]', 4),
('{a:3}', 3),
('[4,4]', 4),
('[1,1]', 1),
('[4,4]', 4),
('{x:2}', 2))
SELECT json_group_array(DISTINCT json(x) ORDER BY json(x)) FROM c;
} {{[[1,1],[4,4],{"a":3},{"x":2}]}}
finish_test

42
test/fts3integrity.test Normal file
View File

@@ -0,0 +1,42 @@
# 2023 December 16
#
# 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 runs all tests.
#
# $Id: fts3.test,v 1.2 2008/07/23 18:17:32 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix fts3integrity
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
finish_test
return
}
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE t1 USING fts3(x);
INSERT INTO t1 VALUES('first row');
INSERT INTO t1 VALUES('second row');
CREATE TABLE t2(x PRIMARY KEY);
INSERT INTO t2 VALUES('first row');
INSERT INTO t2 VALUES('second row');
}
sqlite3 db2 test.db
do_execsql_test -db db2 1.1 {
CREATE TABLE t3(x, y);
}
do_execsql_test 1.2 {
PRAGMA integrity_check;
} {ok}
finish_test

View File

@@ -159,9 +159,10 @@ static struct GlobalVars {
} g;
/*
** Include the external vt02.c module.
** 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*);
/*
@@ -1267,6 +1268,8 @@ int runCombinedDbSqlInput(
}
sqlite3_limit(cx.db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 100);
sqlite3_hard_heap_limit64(heapLimit);
rc = 1;
sqlite3_test_control(SQLITE_TESTCTRL_JSON_SELFCHECK, &rc);
if( nDb>=20 && aDb[18]==2 && aDb[19]==2 ){
aDb[18] = aDb[19] = 1;
@@ -1295,6 +1298,9 @@ int runCombinedDbSqlInput(
/* Add the vt02 virtual table */
sqlite3_vt02_init(cx.db, 0, 0);
/* Add the random_json() and random_json5() functions */
sqlite3_randomjson_init(cx.db, 0, 0);
/* Add support for sqlite_dbdata and sqlite_dbptr virtual tables used
** by the recovery API */
sqlite3_dbdata_init(cx.db, 0, 0);

View File

@@ -13,7 +13,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix json104
set testprefix json105
# This is the example from pages 2 and 3 of RFC-7396
db eval {

70
test/json106.test Normal file
View File

@@ -0,0 +1,70 @@
# 2023-12-18
#
# 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.
#
#***********************************************************************
# Invariant tests for JSON built around the randomjson extension
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix json106
load_static_extension db randomjson
db eval {
CREATE TEMP TABLE t1(j0,j5,p);
CREATE TEMP TABLE kv(n,key,val);
}
unset -nocomplain ii
for {set ii 1} {$ii<=5000} {incr ii} {
do_execsql_test $ii.1 {
DELETE FROM t1;
INSERT INTO t1(j0,j5) VALUES(random_json($ii),random_json5($ii));
SELECT json_valid(j0), json_valid(j5,2) FROM t1;
} {1 1}
do_execsql_test $ii.2 {
SELECT count(*)
FROM t1, json_tree(j0) AS rt
WHERE rt.type NOT IN ('object','array')
AND rt.atom IS NOT (j0 ->> rt.fullkey);
} 0
do_execsql_test $ii.3 {
SELECT count(*)
FROM t1, json_tree(j5) AS rt
WHERE rt.type NOT IN ('object','array')
AND rt.atom IS NOT (j0 ->> rt.fullkey);
} 0
do_execsql_test $ii.4 {
DELETE FROM kv;
INSERT INTO kv
SELECT rt.rowid, rt.fullkey, rt.atom
FROM t1, json_tree(j0) AS rt
WHERE rt.type NOT IN ('object','array');
}
do_execsql_test $ii.5 {
SELECT count(*)
FROM t1, kv
WHERE key NOT LIKE '%]'
AND json_remove(j5,key)->>key IS NOT NULL
} 0
do_execsql_test $ii.6 {
SELECT count(*)
FROM t1, kv
WHERE key NOT LIKE '%]'
AND json_insert(json_remove(j5,key),key,val)->>key IS NOT val
} 0
do_execsql_test $ii.7 {
UPDATE t1 SET p=json_patch(j0,j5);
SELECT count(*)
FROM t1, kv
WHERE p->>key IS NOT val
} 0
}
finish_test

View File

@@ -47,7 +47,7 @@ do_execsql_test 3.2 {
db null null
do_execsql_test 3.3 {
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(json_insert('{}','$.a\',111,'$."b\\"',222));
INSERT INTO t1 VALUES(jsonb_insert('{}','$.a\',111,'$."b\\"',222));
@@ -58,8 +58,10 @@ do_execsql_test 3.4 {
SELECT json_patch('{"a\x62c":123}','{"ab\x63":456}') ->> 'abc';
} 456
do_execsql_test 4.1 {
SELECT * FROM json_tree('{"\u0017":1}','$."\x17"');
} {{\x17} 1 integer 1 1 null {$."\x17"} {$}}
ifcapable vtab {
do_execsql_test 4.1 {
SELECT * FROM json_tree('{"\u0017":1}','$."\x17"');
} {{\x17} 1 integer 1 1 null {$."\x17"} {$}}
}
finish_test

View File

@@ -58,6 +58,8 @@ Usage:
$a0 status
where SWITCHES are:
--buildonly
--dryrun
--jobs NUMBER-OF-JOBS
--zipvfs ZIPVFS-SOURCE-DIR

View File

@@ -30,7 +30,7 @@ namespace eval trd {
set tcltest(osx.Locking-Style) veryquick
set tcltest(osx.Have-Not) veryquick
set tcltest(osx.Apple) all
set tcltest(osx.Apple) all_less_no_mutex_try
set tcltest(win.Stdcall) veryquick
set tcltest(win.Have-Not) veryquick
@@ -100,11 +100,11 @@ namespace eval trd {
}
set build(All-Sanitize) {
-DSQLITE_OMIT_LOOKASIDE=1
--enable-all -fsanitize=address,undefined
--enable-all -fsanitize=address,undefined -fno-sanitize-recover=undefined
}
set build(Sanitize) {
CC=clang -fsanitize=address,undefined
CC=clang -fsanitize=address,undefined -fno-sanitize-recover=undefined
-DSQLITE_ENABLE_STAT4
-DSQLITE_OMIT_LOOKASIDE=1
-DCONFIG_SLOWDOWN_FACTOR=5.0
@@ -367,6 +367,9 @@ proc trd_configs {platform bld} {
set clist $all_configs
} elseif {$clist=="all_plus_autovacuum_crash"} {
set clist [concat $all_configs autovacuum_crash]
} elseif {$clist=="all_less_no_mutex_try"} {
set idx [lsearch $all_configs no_mutex_try]
set clist [lreplace $all_configs $idx $idx]
}
}

View File

@@ -346,6 +346,11 @@ do_execsql_test 5.10 {
do_execsql_test 5.20 {
SELECT *, '+' FROM t1 LEFT JOIN t3 ON (a NOT IN(SELECT v FROM t1 LEFT JOIN t2 ON (a=k))=k);
} {0 {} {} {} + 1 one {} {} + 2 two {} {} + 5 five {} {} + 3 three {} {} + 6 six {} {} +}
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}}
reset_db
do_execsql_test 6.0 {

View File

@@ -492,5 +492,27 @@ foreach disabled_opt {none omit-noop-join all} {
} {123}
}
# 2023-12-23
# https://sqlite.org/forum/forumpost/2568d1f6e6
#
# Index usage should be "x=? and y=?" - equality on both values.
# Not: "x=? AND y>?" - inequality on "y"
#
reset_db
do_execsql_test where3-8.1 {
CREATE TABLE t1(a,b,c,d); INSERT INTO t1 VALUES(1,2,3,4);
CREATE TABLE t2(x,y); INSERT INTO t2 VALUES(3,4);
CREATE INDEX t2xy ON t2(x,y);
SELECT 1 FROM t1 JOIN t2 ON x=c AND y=d WHERE d>0;
} 1
do_eqp_test where3-8.2 {
SELECT 1 FROM t1 JOIN t2 ON x=c AND y=d WHERE d>0;
} {
QUERY PLAN
|--SCAN t1
`--SEARCH t2 USING COVERING INDEX t2xy (x=? AND y=?)
}
finish_test