mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-24 14:17:58 +03:00
When the result of a subquery is to be stored in a register and that
subquery has an ORDER BY clause and an OFFSET, NULL out the destination register before starting the ORDER BY so that the register will be set correctly even if the OFFSET is larger than the number of output rows. Fix for the problem reported in [forum:/forumpost/0ec80f12d02acb3f|forum post 0ec80f12d02acb3f]. FossilOrigin-Name: 9282bcde301cee2a5c3c068b5b0b7ce992c155ece894413a6a9a51a81e4133fd
This commit is contained in:
@@ -594,4 +594,23 @@ do_execsql_test subquery-8.1 {
|
||||
SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x;
|
||||
} {}
|
||||
|
||||
# 2022-01-12 https://sqlite.org/forum/forumpost/0ec80f12d02acb3f
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test subquery-9.1 {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(1),(1),(1);
|
||||
SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 100) FROM t1;
|
||||
} {{} {} {}}
|
||||
do_execsql_test subquery-9.2 {
|
||||
SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 0) FROM t1;
|
||||
} {1 1 1}
|
||||
do_execsql_test subquery-9.3 {
|
||||
INSERT INTO t1 VALUES(2);
|
||||
SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 1) FROM t1;
|
||||
} {2 2 2 2}
|
||||
do_execsql_test subquery-9.4 {
|
||||
SELECT (SELECT DISTINCT x FROM t1 ORDER BY +x LIMIT 1 OFFSET 2) FROM t1;
|
||||
} {{} {} {} {}}
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user