mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-28616 Crash when using derived table over union with order by clause
This bug manifested itself when the server processed a query containing a derived table over union whose ORDER BY clause included a subquery with unresolvable column reference. For such a query the server crashed when trying to resolve column references in the ORDER BY clause used by union. For any union with ORDER BY clause an extra SELECT_LEX structure is created and it is attached to SELECT_LEX_UNIT structure of the union via the field fake_select_lex. The outer context for fake_select_lex must be the same as for other selects of the union. If the union is used in the FROM list of a derived table then the outer context for fake_select_lex must be set to NULL in line with other selects of the union. It was not done and it caused a crash when searching for possible resolution of an unresolvable column reference occurred in a subquery used in the ORDER BY clause. Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
@ -771,6 +771,9 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
cursor->outer_join|= JOIN_TYPE_OUTER;
|
||||
}
|
||||
}
|
||||
// Prevent it for possible ORDER BY clause
|
||||
if (unit->fake_select_lex)
|
||||
unit->fake_select_lex->context.outer_context= 0;
|
||||
|
||||
/*
|
||||
Above cascade call of prepare is important for PS protocol, but after it
|
||||
|
Reference in New Issue
Block a user