mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 10:31:54 +01:00
BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization
- The bug would show up - when using PS (so that we get re-execution) - the left_expr of the subquery is a reference to viewname.column_name, so that it crashes when one tries to use it without having called fix_fields for it. - when using SJ-Materialization, which makes use of sj_subq_pred->left_expr expression - The fix is to have setup_conds() fix sj_subq_pred->left_expr for semi-join nests it finds.
This commit is contained in:
parent
54f9fe6c8b
commit
d028d986a9
4 changed files with 77 additions and 0 deletions
|
@ -1912,6 +1912,28 @@ WHERE a IN (SELECT MAX(c) FROM t2 WHERE c < 4) AND b=7 AND (a IS NULL OR a=b);
|
||||||
a b
|
a b
|
||||||
SET optimizer_switch=@save_optimizer_switch;
|
SET optimizer_switch=@save_optimizer_switch;
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
#
|
||||||
|
# BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 ( a VARCHAR(1) );
|
||||||
|
INSERT INTO t1 VALUES ('y'),('z');
|
||||||
|
CREATE TABLE t2 ( b VARCHAR(1), c VARCHAR(1) );
|
||||||
|
INSERT INTO t2 VALUES ('v','v'),('v','v');
|
||||||
|
CREATE VIEW v2 AS SELECT * FROM t2;
|
||||||
|
PREPARE ps FROM '
|
||||||
|
SELECT a FROM t1, v2
|
||||||
|
WHERE ( c, b ) IN ( SELECT b, b FROM t2 )
|
||||||
|
GROUP BY a ';
|
||||||
|
EXECUTE ps;
|
||||||
|
a
|
||||||
|
y
|
||||||
|
z
|
||||||
|
EXECUTE ps;
|
||||||
|
a
|
||||||
|
y
|
||||||
|
z
|
||||||
|
DROP VIEW v2;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
# This must be at the end:
|
# This must be at the end:
|
||||||
set optimizer_switch=@subselect_sj_mat_tmp;
|
set optimizer_switch=@subselect_sj_mat_tmp;
|
||||||
set join_cache_level=@save_join_cache_level;
|
set join_cache_level=@save_join_cache_level;
|
||||||
|
|
|
@ -1950,6 +1950,28 @@ WHERE a IN (SELECT MAX(c) FROM t2 WHERE c < 4) AND b=7 AND (a IS NULL OR a=b);
|
||||||
a b
|
a b
|
||||||
SET optimizer_switch=@save_optimizer_switch;
|
SET optimizer_switch=@save_optimizer_switch;
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
#
|
||||||
|
# BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 ( a VARCHAR(1) );
|
||||||
|
INSERT INTO t1 VALUES ('y'),('z');
|
||||||
|
CREATE TABLE t2 ( b VARCHAR(1), c VARCHAR(1) );
|
||||||
|
INSERT INTO t2 VALUES ('v','v'),('v','v');
|
||||||
|
CREATE VIEW v2 AS SELECT * FROM t2;
|
||||||
|
PREPARE ps FROM '
|
||||||
|
SELECT a FROM t1, v2
|
||||||
|
WHERE ( c, b ) IN ( SELECT b, b FROM t2 )
|
||||||
|
GROUP BY a ';
|
||||||
|
EXECUTE ps;
|
||||||
|
a
|
||||||
|
y
|
||||||
|
z
|
||||||
|
EXECUTE ps;
|
||||||
|
a
|
||||||
|
y
|
||||||
|
z
|
||||||
|
DROP VIEW v2;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
# This must be at the end:
|
# This must be at the end:
|
||||||
set optimizer_switch=@subselect_sj_mat_tmp;
|
set optimizer_switch=@subselect_sj_mat_tmp;
|
||||||
set join_cache_level=@save_join_cache_level;
|
set join_cache_level=@save_join_cache_level;
|
||||||
|
|
|
@ -1602,6 +1602,28 @@ SET optimizer_switch=@save_optimizer_switch;
|
||||||
|
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 ( a VARCHAR(1) );
|
||||||
|
INSERT INTO t1 VALUES ('y'),('z');
|
||||||
|
|
||||||
|
CREATE TABLE t2 ( b VARCHAR(1), c VARCHAR(1) );
|
||||||
|
INSERT INTO t2 VALUES ('v','v'),('v','v');
|
||||||
|
|
||||||
|
CREATE VIEW v2 AS SELECT * FROM t2;
|
||||||
|
|
||||||
|
PREPARE ps FROM '
|
||||||
|
SELECT a FROM t1, v2
|
||||||
|
WHERE ( c, b ) IN ( SELECT b, b FROM t2 )
|
||||||
|
GROUP BY a ';
|
||||||
|
|
||||||
|
EXECUTE ps;
|
||||||
|
EXECUTE ps;
|
||||||
|
|
||||||
|
DROP VIEW v2;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
--echo # This must be at the end:
|
--echo # This must be at the end:
|
||||||
set optimizer_switch=@subselect_sj_mat_tmp;
|
set optimizer_switch=@subselect_sj_mat_tmp;
|
||||||
set join_cache_level=@save_join_cache_level;
|
set join_cache_level=@save_join_cache_level;
|
||||||
|
|
|
@ -8497,6 +8497,17 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves,
|
||||||
goto err_no_arena;
|
goto err_no_arena;
|
||||||
select_lex->cond_count++;
|
select_lex->cond_count++;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
If it's a semi-join nest, fix its "left expression", as it is used by
|
||||||
|
the SJ-Materialization
|
||||||
|
*/
|
||||||
|
if (embedded->sj_subq_pred)
|
||||||
|
{
|
||||||
|
Item **left_expr= &embedded->sj_subq_pred->left_expr;
|
||||||
|
if (!(*left_expr)->fixed && (*left_expr)->fix_fields(thd, left_expr))
|
||||||
|
goto err_no_arena;
|
||||||
|
}
|
||||||
|
|
||||||
embedding= embedded->embedding;
|
embedding= embedded->embedding;
|
||||||
}
|
}
|
||||||
while (embedding &&
|
while (embedding &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue