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

@@ -200,3 +200,18 @@ void select_handler::print_error(int error, myf errflag)
{
my_error(ER_GET_ERRNO, MYF(0), error, hton_name(ht)->str);
}
select_pushdown_type select_handler::get_pushdown_type()
{
/*
In the case of single SELECT select_lex is initialized and lex_unit==NULL,
in the case of whole UNIT select_lex == NULL and lex_unit is initialized,
in the case of partial pushdown both select_lex and lex_unit
are initialized
*/
if(!lex_unit)
return select_pushdown_type::SINGLE_SELECT;
return select_lex ? select_pushdown_type::PART_OF_UNIT :
select_pushdown_type::WHOLE_UNIT;
}