Commit 7e9a6b7f authored by Varun Gupta's avatar Varun Gupta

MDEV-24779: main.subselect fails in buildbot with --ps-protocol

Follow-up fix to commit 26f50335(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.
parent a461e4d3
......@@ -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
#
......@@ -4902,6 +4902,16 @@ DROP TABLE t1;
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 #
......@@ -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;
}
......
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