diff options
author | Igor Babaev <igor@askmonty.org> | 2017-12-24 14:08:20 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-12-27 10:37:13 -0800 |
commit | bbb8c9d77310860f3f81bfd8b824ce353271fb14 (patch) | |
tree | bb25393f3f1135780d7d73c9ef264b51ac0d2d19 /sql/sql_lex.cc | |
parent | 02b7dc7bec4ff95c764a244c5037c69f262651e1 (diff) | |
download | mariadb-git-bbb8c9d77310860f3f81bfd8b824ce353271fb14.tar.gz |
Fixed the bug MDEV-14755 Crash when executing prepared statement
for a query that uses CTE
The first reference to a CTE in the processed query uses the unit
built by the parser for the CTE specification. This unit is
considered as the specification of the derived table created for
the first reference of the CTE. This requires some transformation of
the original query tree: the unit of the specification must be moved
to a new position as a slave of the select where the first reference
to the CTE occurs. The transformation is performed by the function
st_select_lex_node::move_as_slave(). There was an obvious bug in this
function. As a result of this bug in many cases the moved unit turned
out to be lost in the query tree. This could cause different problems.
In particular the prepared statements for queries that used CTEs could
miss cleanup for some selects that was performed at the end of the
preparation/execution of the PSs. If such cleanup is not done for a PS
the next execution of the PS causes an assertion abort or a crash.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d086f36a74b..69931643c7f 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2320,10 +2320,8 @@ void st_select_lex_node::move_as_slave(st_select_lex_node *new_master) prev= &curr->next; } else - { prev= &new_master->slave; - new_master->slave= this; - } + *prev= this; next= 0; master= new_master; } |