Commit 9b049266 authored by Igor Babaev's avatar Igor Babaev

MDEV-32569 Failure when executing PS for query using IN subquery

This patch corrects the fix for MDEV-32369. No Item_direct_ref_to_item
objects should be allocated at the optimizer phase after permanent
rewritings have been done.

The patch also adds another test case for MDEV-32369 that uses MyISAM
with more than one row.

Approved by Rex Johnston <rex.johnston@mariadb.com>
parent edabb819
......@@ -3,6 +3,20 @@
#
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('b'), ('a'), ('c');
INSERT INTO t2 VALUES ('c'), ('d'), ('b');
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
EXECUTE stmt;
a
c
b
EXECUTE stmt;
a
c
b
DEALLOCATE PREPARE stmt;
DELETE FROM t1;
DELETE FROM t2;
INSERT INTO t1 VALUES ('b');
INSERT INTO t2 VALUES ('b');
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
......@@ -14,3 +28,21 @@ a
b
DEALLOCATE PREPARE stmt;
DROP TABLE t1, t2;
#
# MDEV-32569: Failure when executing PS for query using IN subquery
#
CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('b');
INSERT INTO t2 VALUES ('b');
PREPARE stmt FROM
"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
EXECUTE stmt;
a
b
EXECUTE stmt;
a
b
DEALLOCATE PREPARE stmt;
DROP TABLE t1,t2;
# End of 10.4 tests
......@@ -13,6 +13,19 @@
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('b'), ('a'), ('c');
INSERT INTO t2 VALUES ('c'), ('d'), ('b');
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DELETE FROM t1;
DELETE FROM t2;
INSERT INTO t1 VALUES ('b');
INSERT INTO t2 VALUES ('b');
......@@ -25,3 +38,24 @@ DEALLOCATE PREPARE stmt;
DROP TABLE t1, t2;
--echo #
--echo # MDEV-32569: Failure when executing PS for query using IN subquery
--echo #
CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('b');
INSERT INTO t2 VALUES ('b');
PREPARE stmt FROM
"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1,t2;
--echo # End of 10.4 tests
......@@ -2585,7 +2585,8 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
if (conv->fix_fields_if_needed(thd, arg))
return TRUE;
if (!thd->stmt_arena->is_conventional())
if (!thd->stmt_arena->is_conventional() &&
thd->lex->current_select->first_cond_optimization)
{
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment