1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Prevent the ORDER BY LIMIT optimization from running if the innermost loop

is a right-join, as doing so will get an incorrect answer.

FossilOrigin-Name: 3aefc874d31885c64a5e02868edb2aa56a2b4429252d494e67e4088a9298ce5b
This commit is contained in:
drh
2022-04-23 19:21:47 +00:00
parent 30d2aab5fd
commit ecb386b71f
4 changed files with 23 additions and 10 deletions

View File

@ -142,4 +142,18 @@ do_execsql_test join8-4000 {
SELECT a FROM t1 NATURAL RIGHT JOIN t1 WHERE a=5555 OR (1,b)==(SELECT 2 IN (2,2),4);
} {5555}
# 2022-04-23 dbsqlfuzz c7ee5500e3abddec3557016de777713b80c790d3
# Escape from the right-join body subroutine via the ORDER BY LIMIT optimization.
#
reset_db
db null -
do_catchsql_test join8-5000 {
CREATE TABLE t1(x);
INSERT INTO t1(x) VALUES(NULL),(NULL);
CREATE TABLE t2(c, d);
INSERT INTO t2(c,d) SELECT x, x FROM t1;
CREATE INDEX t2dc ON t2(d, c);
SELECT (SELECT c FROM sqlite_temp_schema FULL JOIN t2 ON d IN (1,2,3) ORDER BY d) AS x FROM t1;
} {0 {- -}}
finish_test