1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-30828 Prevent pushing down unions with incorrect ORDER BY

Fake_select_lex->join was prepared at the unit execution stage so
the validation of fake_select_lex before the unit pushdown
was incomplete. That caused pushing down of statements having
an incorrect ORDER BY clause.
This commit moves preparation of the fake_select_lex->join to the unit
prepare() method, before initializing of the pushdown handler,
so incorrect clauses error out before being pushed down
This commit is contained in:
Oleg Smirnov
2023-04-03 18:05:44 +07:00
parent 8290a46d50
commit d6c6102cad
7 changed files with 238 additions and 148 deletions

View File

@@ -563,6 +563,7 @@ void JOIN::init(THD *thd_arg, List<Item> &fields_arg,
sjm_scan_tables= 0;
is_orig_degenerated= false;
with_ties_order_count= 0;
prepared= false;
};
@@ -1816,6 +1817,7 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
unit= unit_arg;
if (prepare_stage2())
goto err;
prepared= true;
DBUG_RETURN(0); // All OK
@@ -5185,7 +5187,8 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
}
else
{
if ((err= join->prepare(tables, conds, og_num, order, false, group,
if (!join->prepared &&
(err= join->prepare(tables, conds, og_num, order, false, group,
having, proc_param, select_lex, unit)))
{
goto err;
@@ -5211,7 +5214,8 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
DBUG_RETURN(TRUE);
THD_STAGE_INFO(thd, stage_init);
thd->lex->used_tables=0;
if ((err= join->prepare(tables, conds, og_num, order, false, group, having,
if (!join->prepared &&
(err= join->prepare(tables, conds, og_num, order, false, group, having,
proc_param, select_lex, unit)))
{
goto err;