mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-20516: Assertion `!lex->proc_list.first && !lex->result && !lex->param_list.elements' failed in mysql_create_view
Execution of the CREATE VIEW statement sent via binary protocol
where the flags of the COM_STMT_EXECUTE request a cursor to be opened
before running the statement results in an assert failure.
This assert fails since the data member thd->lex->result has not null
value pointing to an instance of the class Select_materialize.
The data member thd->lex->result is assigned a pointer to the class
Select_materialize in the function mysql_open_cursor() that invoked
in case the packet COM_STMT_EXECUTE requests a cursor to be opened.
After thd->lex->result is assigned a pointer to an instance of the
class Select_materialize the function mysql_create_view() is called
(indirectly via the function mysql_execute_statement()) and the assert
fails.
The assert
DBUG_ASSERT(!lex->proc_list.first && !lex->result &&
!lex->param_list.elements);
was added by the commit 591c06d4b7
.
Unfortunately , the condition
!lex->result
was specified incorrect. It was supposed that the thd->lex->result
is set only by parser on handling the clauses SELECT ... INTO
but indeed it is also set inside mysql_open_cursor() and
that fact was missed by the assert's condition.
So, the fix for this issue is to just remove the condition
!lex->result
from the failing assert.
This commit is contained in:
@ -408,8 +408,18 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
|
||||
bool res= FALSE;
|
||||
DBUG_ENTER("mysql_create_view");
|
||||
|
||||
/* This is ensured in the parser. */
|
||||
DBUG_ASSERT(!lex->proc_list.first && !lex->result &&
|
||||
/*
|
||||
This is ensured in the parser.
|
||||
NOTE: Originally, the assert below contained the extra condition
|
||||
&& !lex->result
|
||||
but in this form the assert is failed in case CREATE VIEW run under
|
||||
cursor (the case when the byte 'flags' in the COM_STMT_EXECUTE packet has
|
||||
the flag CURSOR_TYPE_READ_ONLY set). For the cursor use case
|
||||
thd->lex->result is assigned a pointer to the class Select_materialize
|
||||
inside the function mysql_open_cursor() just before handling of a statement
|
||||
will be started and the function mysql_create_view() called.
|
||||
*/
|
||||
DBUG_ASSERT(!lex->proc_list.first &&
|
||||
!lex->param_list.elements);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user