mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +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:
@ -20,6 +20,12 @@
|
||||
#include "mariadb.h"
|
||||
#include "sql_priv.h"
|
||||
|
||||
enum class select_pushdown_type {
|
||||
SINGLE_SELECT,
|
||||
PART_OF_UNIT,
|
||||
WHOLE_UNIT
|
||||
};
|
||||
|
||||
/**
|
||||
@class select_handler
|
||||
|
||||
@ -50,7 +56,7 @@ class select_handler
|
||||
virtual bool prepare();
|
||||
|
||||
/*
|
||||
Select_handler processes one of
|
||||
Select_handler processes these cases:
|
||||
- single SELECT
|
||||
- whole unit (multiple SELECTs combined with UNION/EXCEPT/INTERSECT)
|
||||
- single SELECT that is part of a unit (partial pushdown)
|
||||
@ -60,7 +66,7 @@ class select_handler
|
||||
in the case of partial pushdown both select_lex and lex_unit
|
||||
are initialized
|
||||
*/
|
||||
SELECT_LEX *select_lex; // Single select to be executed
|
||||
SELECT_LEX *select_lex; // Single select/part of a unit to be executed
|
||||
SELECT_LEX_UNIT *lex_unit; // Unit to be executed
|
||||
|
||||
/*
|
||||
@ -99,6 +105,8 @@ protected:
|
||||
|
||||
TABLE *create_tmp_table(THD *thd);
|
||||
|
||||
select_pushdown_type get_pushdown_type();
|
||||
|
||||
THD *thd;
|
||||
handlerton *ht;
|
||||
|
||||
|
Reference in New Issue
Block a user