mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-10389: Query returns different results on a debug vs non-debug build
The problem was caused by a merged semi-join, which contained a non-merged semi-join, which used references to the top-level query in the left_expr. When moving non-merged semi-join from the subquery to its parent, do not forget to call fix_after_pullout for its Item_subselect. We need to do that specifically, because non-merged semi-joins do not have their IN-equality in the WHERE clause at this stage.
This commit is contained in:
@@ -2261,6 +2261,19 @@ PREPARE stmt FROM '
|
||||
EXECUTE stmt;
|
||||
EXECUTE stmt;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-10389: Query returns different results on a debug vs non-debug build of the same revision
|
||||
#
|
||||
CREATE TABLE t1 (i1 INT, i2 INT NOT NULL);
|
||||
INSERT INTO t1 VALUES (1,4),(2,6);
|
||||
SELECT * FROM t1 AS alias1
|
||||
WHERE alias1.i1 IN (
|
||||
SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 )
|
||||
);
|
||||
i1 i2
|
||||
1 4
|
||||
2 6
|
||||
DROP TABLE t1;
|
||||
set @subselect_mat_test_optimizer_switch_value=null;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
|
||||
|
@@ -2301,3 +2301,16 @@ PREPARE stmt FROM '
|
||||
EXECUTE stmt;
|
||||
EXECUTE stmt;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-10389: Query returns different results on a debug vs non-debug build of the same revision
|
||||
#
|
||||
CREATE TABLE t1 (i1 INT, i2 INT NOT NULL);
|
||||
INSERT INTO t1 VALUES (1,4),(2,6);
|
||||
SELECT * FROM t1 AS alias1
|
||||
WHERE alias1.i1 IN (
|
||||
SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 )
|
||||
);
|
||||
i1 i2
|
||||
1 4
|
||||
2 6
|
||||
DROP TABLE t1;
|
||||
|
@@ -1925,3 +1925,15 @@ EXECUTE stmt;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-10389: Query returns different results on a debug vs non-debug build of the same revision
|
||||
--echo #
|
||||
CREATE TABLE t1 (i1 INT, i2 INT NOT NULL);
|
||||
INSERT INTO t1 VALUES (1,4),(2,6);
|
||||
|
||||
SELECT * FROM t1 AS alias1
|
||||
WHERE alias1.i1 IN (
|
||||
SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 )
|
||||
);
|
||||
DROP TABLE t1;
|
||||
|
||||
|
@@ -1558,7 +1558,12 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
|
||||
{
|
||||
tl->set_tablenr(table_no);
|
||||
if (tl->is_jtbm())
|
||||
{
|
||||
tl->jtbm_table_no= table_no;
|
||||
Item *dummy= tl->jtbm_subselect;
|
||||
tl->jtbm_subselect->fix_after_pullout(parent_lex, &dummy);
|
||||
DBUG_ASSERT(dummy == tl->jtbm_subselect);
|
||||
}
|
||||
SELECT_LEX *old_sl= tl->select_lex;
|
||||
tl->select_lex= parent_join->select_lex;
|
||||
for (TABLE_LIST *emb= tl->embedding;
|
||||
|
Reference in New Issue
Block a user