mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-26145: Incorrect metadata is sent on running query with union in PS mode
Test cases like the following one produce different result sets if it's run with and without th option --ps-protocol. CREATE TABLE t1(a INT); --enable_metadata (SELECT MAX(a) FROM t1) UNION (SELECT MAX(a) FROM t1); --disable_metadata DROP TABLE t1; Result sets differ in metadata for the query (SELECT MAX(a) FROM t1) UNION (SELECT MAX(a) FROM t1); The reason for different content of query metadata is that for queries with union the items being created on JOIN preparing phase is placed into item_list from SELECT_LEX_UNIT whereas for queries without union item_list from SELECT_LEX is used instead.
This commit is contained in:
@ -1674,7 +1674,12 @@ static int mysql_test_select(Prepared_statement *stmt,
|
||||
if (!lex->describe && !thd->lex->analyze_stmt && !stmt->is_sql_prepare())
|
||||
{
|
||||
/* Make copy of item list, as change_columns may change it */
|
||||
List<Item> fields(lex->select_lex.item_list);
|
||||
SELECT_LEX_UNIT* master_unit= unit->first_select()->master_unit();
|
||||
bool is_union_op=
|
||||
master_unit->is_union() || master_unit->fake_select_lex;
|
||||
|
||||
List<Item> fields(is_union_op ? unit->item_list :
|
||||
lex->select_lex.item_list);
|
||||
|
||||
/* Change columns if a procedure like analyse() */
|
||||
if (unit->last_procedure && unit->last_procedure->change_columns(thd, fields))
|
||||
|
Reference in New Issue
Block a user