diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-15 16:28:44 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-16 11:53:13 +0530 |
commit | 7e9a6b7f09bfb00e781d8ca63dfe7701900c368b (patch) | |
tree | 79d3e1ed300525dcc14e4a1fca0b4b322c807636 | |
parent | a461e4d306bc53134cefa0eeeb624f3d9eba70f8 (diff) | |
download | mariadb-git-7e9a6b7f09bfb00e781d8ca63dfe7701900c368b.tar.gz |
MDEV-24779: main.subselect fails in buildbot with --ps-protocol
Follow-up fix to commit 26f5033(MDEV-23449)
The GROUP BY clause inside IN/ALL/ANY subquery is removed
when there is no aggregate function or HAVING clause in the subquery.
When the GROUP BY clause is removed, a subquery can also be removed
if it part of the GROUP BY clause. This is done inside the function
remove_redundant_subquery_clauses. Here we walk over the GROUP BY list
and remove a subselect from its unit via the callback function
eliminate_subselect_processor.
The issue here was that when the query was being re-executed it was trying
to reinitialize the select that was removed as stated above.
This is not required, so the fix would be to remove select_lex
both from tree lex structure and the global list of nodes so that
we don't do the reinitialization again.
-rw-r--r-- | mysql-test/r/ps.result | 12 | ||||
-rw-r--r-- | mysql-test/t/ps.test | 10 | ||||
-rw-r--r-- | sql/item_subselect.cc | 2 |
3 files changed, 23 insertions, 1 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 8d4b52e1b2e..076c7d9abda 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -5390,5 +5390,17 @@ ERROR HY000: Default/ignore value is not supported for such parameter usage EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING 0; Database # +# MDEV-24779: main.subselect fails in buildbot with --ps-protocol +# +CREATE TABLE t1(a INT); +PREPARE stmt FROM "SELECT EXISTS(SELECT 1 FROM t1 GROUP BY a IN (select a from t1))"; +EXECUTE stmt; +EXISTS(SELECT 1 FROM t1 GROUP BY a IN (select a from t1)) +0 +EXECUTE stmt; +EXISTS(SELECT 1 FROM t1 GROUP BY a IN (select a from t1)) +0 +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 90af3ff7ce1..1b1f88094ff 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -4903,5 +4903,15 @@ EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING DEFAULT; EXECUTE IMMEDIATE 'SHOW DATABASES WHERE ?' USING 0; --echo # +--echo # MDEV-24779: main.subselect fails in buildbot with --ps-protocol +--echo # + +CREATE TABLE t1(a INT); +PREPARE stmt FROM "SELECT EXISTS(SELECT 1 FROM t1 GROUP BY a IN (select a from t1))"; +EXECUTE stmt; +EXECUTE stmt; +DROP TABLE t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 802bfca64b7..1ef74d19172 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -368,7 +368,7 @@ bool Item_subselect::mark_as_eliminated_processor(void *arg) bool Item_subselect::eliminate_subselect_processor(void *arg) { unit->item= NULL; - unit->exclude_from_tree(); + unit->exclude(); eliminated= TRUE; return FALSE; } |