1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-22001: Server crashes in st_select_lex_unit::exclude_level upon execution of SP

Running some statements that use IN subqueries outside context of a regular
query could result in server abnormal termination.

The reason for failure is that internal structures SELECT_LEX/SELECT_LEX_UNIT
created on behalf of parsed query were initialized incorrectly. Incorrect
initialization of the structures SELECT_LEX/SELECT_LEX_UNIT was introduced
by the commit de745ecf29
(MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operations)
pushed into 10.4, that is the reason this bug report is not reproduced in 10.3.

To fix the issue the method SLECTE_LEX::register_unit is used for proper
initialization of the data structures SELECT_LEX/SELECT_LEX_UNIT. Additionally,
the method SELECT_LEX::get_slave() was removed from the source code base
since for those use cases where it is used it can be replaced by the method
first_inner_unit().
This commit is contained in:
Dmitry Shulga
2022-07-12 17:18:48 +07:00
parent 9a0cbd31ce
commit f439cfdf93
4 changed files with 32 additions and 6 deletions

View File

@ -9684,11 +9684,13 @@ void LEX::relink_hack(st_select_lex *select_lex)
{
if (!select_stack_top) // Statements of the second type
{
if (!select_lex->get_master()->get_master())
((st_select_lex *) select_lex->get_master())->
set_master(&builtin_select);
if (!builtin_select.get_slave())
builtin_select.set_slave(select_lex->get_master());
if (!select_lex->outer_select() &&
!builtin_select.first_inner_unit())
{
builtin_select.register_unit(select_lex->master_unit(),
&builtin_select.context);
builtin_select.add_statistics(select_lex->master_unit());
}
}
}