mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-22498: SIGSEGV in Bitmap<64u>::merge on SELECT
For the case when the optimizer does the IN-EXISTS transformation, the equality condition is injected in the WHERE OR HAVING clause of the subquery. If the select list of the subquery has a reference to the parent select make sure to use the reference and not the original item.
This commit is contained in:
@ -2534,3 +2534,35 @@ x
|
||||
c1
|
||||
1
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-22498: SIGSEGV in Bitmap<64u>::merge on SELECT
|
||||
#
|
||||
set @save_sql_select_limit= @@sql_select_limit;
|
||||
SET sql_select_limit=0;
|
||||
CREATE TABLE t1(b INT, c INT);
|
||||
CREATE TABLE t2(a INT, b INT);
|
||||
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
|
||||
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
|
||||
EXPLAIN EXTENDED SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Zero limit
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select sum(`test`.`t2`.`a`) AS `sum(a)`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` having <in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`t1` where (<cache>(`test`.`t2`.`a`) = `test`.`t2`.`b`)))
|
||||
SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
|
||||
sum(a) a b
|
||||
SET @@sql_select_limit= @save_sql_select_limit;
|
||||
EXPLAIN EXTENDED SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1276 Field or reference 'test.t2.b' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select sum(`test`.`t2`.`a`) AS `sum(a)`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` having <expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t2`.`b` from `test`.`t1` where (<cache>(`test`.`t2`.`a`) = `test`.`t2`.`b`))))
|
||||
SELECT sum(a), t2.a, t2.b FROM t2 HAVING t2.a IN (SELECT t2.b FROM t1);
|
||||
sum(a) a b
|
||||
6 1 1
|
||||
DROP TABLE t1,t2;
|
||||
|
Reference in New Issue
Block a user