1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Fix a crash in handling queries of the form "SELECT aggregate(DISTINCT tbl.col) FROM ... LEFT JOIN tbl ...". Fixes a problem introduced by [ef4ac0ddd297bbd3].

FossilOrigin-Name: 0dcf808ddf23da834da724d88b1715ed06565f1f1290713ff42a3fcf6ffb802e
This commit is contained in:
dan
2021-04-03 19:23:59 +00:00
parent 9af69ff547
commit f330d53ff3
6 changed files with 37 additions and 20 deletions

View File

@ -174,10 +174,15 @@ foreach {tn use_t3 sql res} {
1 1 "SELECT count(*) FROM t3" 2
2 0 "SELECT count(*) FROM t1" 10
2 1 "SELECT count(DISTINCT a) FROM t1, t3" 4
3 0 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3" 4
3 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3" 4
4 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 WHERE t3.x=1" 4
5 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 WHERE t3.x=0" 0
6 0 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 ON (t3.x=0)" 4
6 1 "SELECT count(DISTINCT a) FROM t1 LEFT JOIN t3 ON (t3.x=0)" 4
7 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3" 2
8 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3 WHERE t3.x=1" 1
9 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3 WHERE t3.x=0" 0
10 1 "SELECT count(DISTINCT x) FROM t1 LEFT JOIN t3 ON (t3.x=0)" 0
} {
do_test 5.$tn.1 {
set bUse 0
@ -190,5 +195,18 @@ foreach {tn use_t3 sql res} {
do_execsql_test 5.$tn.2 $sql $res
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 6.0 {
CREATE TABLE t1(a, b);
CREATE TABLE t2(c, d);
INSERT INTO t1 VALUES(123,456);
INSERT INTO t2 VALUES(123,456);
}
do_execsql_test 6.1 {
SELECT count(DISTINCT c) FROM t1 LEFT JOIN t2;
} {1}
finish_test