1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-02 06:13:16 +03:00

Fix queries like (SELECT * FROM t ORDER BY 1) UNION (SELECT ...)

This commit is contained in:
Aleksei Antipovskii
2025-08-31 22:32:17 +02:00
committed by Leonid Fedorov
parent 3d26e4d6fd
commit 378f964cca

View File

@@ -6208,9 +6208,9 @@ int processLimitAndOffset(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep
We therefore do not allow limit set to 1 here for such queries. We therefore do not allow limit set to 1 here for such queries.
*/ */
if (gwi.subSelectType != CalpontSelectExecutionPlan::IN_SUBS && if (gwi.subSelectType != CalpontSelectExecutionPlan::IN_SUBS &&
gwi.subSelectType != CalpontSelectExecutionPlan::EXISTS_SUBS && gwi.subSelectType != CalpontSelectExecutionPlan::EXISTS_SUBS)
select_lex.master_unit()->global_parameters()->limit_params.explicit_limit)
{ {
if (select_lex.master_unit()->global_parameters()->limit_params.explicit_limit) {
if (select_lex.master_unit()->global_parameters()->limit_params.offset_limit) if (select_lex.master_unit()->global_parameters()->limit_params.offset_limit)
{ {
Item_int* offset = Item_int* offset =
@@ -6228,6 +6228,7 @@ int processLimitAndOffset(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep
} }
} }
} }
}
// union with explicit select at the top level // union with explicit select at the top level
else if (isUnion && select_lex.limit_params.explicit_limit) else if (isUnion && select_lex.limit_params.explicit_limit)
{ {
@@ -6878,6 +6879,8 @@ int processOrderBy(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep,
} }
} }
if (!unionSel)
{
// re-visit the first of ordercol list // re-visit the first of ordercol list
ordercol = static_cast<ORDER*>(order_list.first); ordercol = static_cast<ORDER*>(order_list.first);
@@ -6955,6 +6958,7 @@ int processOrderBy(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep,
gwi.orderByCols.push_back(SRCP(rc)); gwi.orderByCols.push_back(SRCP(rc));
} }
}
// make sure columnmap, returnedcols and count(*) arg_list are not empty // make sure columnmap, returnedcols and count(*) arg_list are not empty
TableMap::iterator tb_iter = gwi.tableMap.begin(); TableMap::iterator tb_iter = gwi.tableMap.begin();