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

MDEV-32382 FederatedX error on pushdown of statements having CTE

Pushing down statements to FederatedX engine is implemented by
printing either SELECT_LEX or SELECT_LEX_UNIT into a string and
sending that string to the engine. In the case of pushing down a
single SELECT having a CTE (WITH clause) there was a problem, because
normally single SELECTs were printed using SELECT_LEX::print().
But CTEs are stored in the upper unit of the SELECT_LEX -
SELECT_LEX_UNIT, so they were not unfolded in the string produced.

The solution is to invoke SELECT_LEX_UNIT::print() when pushing down
single SELECT statements (but not those which are parts of units),
so the possible CTEs are unfolded and printed.

Reviewed by Sergei Petrunia (sergey@mariadb.com)
This commit is contained in:
Oleg Smirnov
2023-10-10 13:29:04 +07:00
parent 9b2a65e41a
commit 855356ca6d
7 changed files with 218 additions and 25 deletions

View File

@@ -5054,8 +5054,15 @@ select_handler *find_select_handler_inner(THD *thd,
SELECT_LEX *select_lex,
SELECT_LEX_UNIT *select_lex_unit)
{
if (select_lex->master_unit()->outer_select())
if (select_lex->master_unit()->outer_select() ||
(select_lex_unit && select_lex->master_unit()->with_clause))
{
/*
Pushdown is not supported neither for non-top-level SELECTs nor for parts
of SELECT_LEX_UNITs that have CTEs (SELECT_LEX_UNIT::with_clause)
*/
return 0;
}
TABLE_LIST *tbl= nullptr;
// For SQLCOM_INSERT_SELECT the server takes TABLE_LIST