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

Fix the handling of indexed expressions in an outer query that appear as

corelated values inside an aggregate function within a subquery.
[forum:/forumpost/79cf371080|Forum post 79cf371080].

FossilOrigin-Name: d8259877eaa962e6f90675790d3770ef02bd1a5d86d319cd8c1834710df844c4
This commit is contained in:
drh
2023-03-24 20:35:56 +00:00
parent d23924d1ea
commit b3ad5444d0
4 changed files with 24 additions and 9 deletions

View File

@ -372,4 +372,18 @@ foreach {tn expr} {
" {1 1}
}
# 2023-03-24 https://sqlite.org/forum/forumpost/79cf371080
#
reset_db
do_execsql_test 9.0 {
CREATE TABLE t1(a INT, b INT);
CREATE INDEX t1x ON t1(a, abs(b));
CREATE TABLE t2(c INT, d INT);
INSERT INTO t1(a,b) VALUES(4,4),(5,-5),(5,20),(6,6);
INSERT INTO t2(c,d) VALUES(100,1),(200,1),(300,2);
SELECT *,
(SELECT max(c+abs(b)) FROM t2 GROUP BY d ORDER BY d LIMIT 1) AS subq
FROM t1 WHERE a=5;
} {5 -5 205 5 20 220}
finish_test