1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Merge latest trunk changes into this branch.

FossilOrigin-Name: 3ed89c344fcb3b7ee8b764d95144643e42e053e1116150d6eda8355fbd6669df
This commit is contained in:
dan
2023-08-10 17:07:34 +00:00
40 changed files with 491 additions and 212 deletions

View File

@ -1269,6 +1269,7 @@ do_test 15.0 {
}]} {}
extra_schema_checks 0
optimization_control db one-pass off
do_catchsql_test 15.1 {
PRAGMA cell_size_check = 0;
UPDATE c1 SET c= NOT EXISTS(SELECT 1 FROM c1 ORDER BY (SELECT 1 FROM c1 ORDER BY a)) +10 WHERE d BETWEEN 4 AND 7;

Binary file not shown.

View File

@ -397,4 +397,22 @@ do_execsql_test json102-1610 {
6 {} null {} null {} null
]
reset_db
do_execsql_test json102-1700 {
CREATE TABLE t1(a1 DATE, a2 INTEGER PRIMARY KEY, a3 INTEGER, memo TEXT);
CREATE INDEX t1x1 ON t1(a3, a1, memo->>'y');
INSERT INTO t1(a2,a1,a3,memo) VALUES (876, '2023-08-03', 5, '{"x":77,"y":4}');
}
do_execsql_test json102-1710 {
UPDATE t1 SET memo = JSON_REMOVE(memo, '$.y');
PRAGMA integrity_check;
SELECT * FROM t1;
} {ok 2023-08-03 876 5 {{"x":77}}}
do_execsql_test json102-1720 {
UPDATE t1 SET memo = JSON_SET(memo, '$.y', 6)
WHERE a2 IN (876) AND JSON_TYPE(memo, '$.y') IS NULL;
PRAGMA integrity_check;
SELECT * FROM t1;
} {ok 2023-08-03 876 5 {{"x":77,"y":6}}}
finish_test

View File

@ -764,5 +764,27 @@ do_execsql_test update-21.4 {
SELECT * FROM t1 ORDER BY vkey, c5;
ROLLBACK;
} {6 -54 100 NULL}
# Follow-up on 2023-07-31 (forum post https://sqlite.org/forum/forumpost/8ab195fd44e75ed0):
# Only disable one-pass if the subquery is in the WHERE clause. The SET expressions
# do not count.
do_execsql_test update-21.11 {
DROP TABLE t1;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
CREATE TABLE t2(d INT);
}
do_eqp_test update-21.12 {
WITH t3(x,y) AS (SELECT d, row_number()OVER() FROM t2)
UPDATE t1 SET b=(SELECT y FROM t3 WHERE t1.a=t3.x);
} {
QUERY PLAN
|--SCAN t1
`--CORRELATED SCALAR SUBQUERY xxxxxx
|--CO-ROUTINE t3
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN t2
| `--SCAN (subquery-xxxxxx)
|--BLOOM FILTER ON t3 (x=?)
`--SEARCH t3 USING AUTOMATIC COVERING INDEX (x=?)
}
finish_test

View File

@ -47,18 +47,33 @@ do_test where7-1.1 {
SELECT * FROM t1;
}
} {1 2 3 4 2 3 4 5 3 4 6 8 4 5 10 15 5 10 100 1000}
do_execsql_test where7-1.1.1 {
CREATE TABLE t(a);
CREATE INDEX ta ON t(a);
INSERT INTO t(a) VALUES(1),(2);
SELECT * FROM t ORDER BY a;
SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a;
PRAGMA count_changes=ON;
DELETE FROM t WHERE a<2 OR a<3;
SELECT * FROM t;
PRAGMA count_changes=OFF;
DROP TABLE t;
} {1 2 1 2 2}
if {[permutation] != "no_optimization"} {
do_execsql_test where7-1.1.1 {
CREATE TABLE t(a);
CREATE INDEX ta ON t(a);
INSERT INTO t(a) VALUES(1),(2);
SELECT * FROM t ORDER BY a;
SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a;
PRAGMA count_changes=ON;
DELETE FROM t WHERE a<2 OR a<3;
SELECT * FROM t;
PRAGMA count_changes=OFF;
DROP TABLE t;
} {1 2 1 2 2}
} else {
do_execsql_test where7-1.1.1-noopt {
CREATE TABLE t(a);
CREATE INDEX ta ON t(a);
INSERT INTO t(a) VALUES(1),(2);
SELECT * FROM t ORDER BY a;
SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a;
PRAGMA count_changes=ON;
DELETE FROM t WHERE a<2 OR a<3;
SELECT * FROM t;
PRAGMA count_changes=OFF;
DROP TABLE t;
} {1 2 1 2 3}
}
do_test where7-1.2 {
count_steps {
SELECT a FROM t1 WHERE b=3 OR c=6 ORDER BY a