mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Bug#7242
The "insert_update" causes a server crash when using prepared statements Must clear table->insert_values after completing every prepared statement
This commit is contained in:
@@ -1514,6 +1514,27 @@ static bool init_param_array(Prepared_statement *stmt)
|
||||
}
|
||||
|
||||
|
||||
/* Init statement before execution */
|
||||
|
||||
static void cleanup_stmt_for_execute(Prepared_statement *stmt)
|
||||
{
|
||||
THD *thd= stmt->thd;
|
||||
LEX *lex= stmt->lex;
|
||||
SELECT_LEX *sl= lex->all_selects_list;
|
||||
|
||||
for (; sl; sl= sl->next_select_in_list())
|
||||
{
|
||||
for (TABLE_LIST *tables= (TABLE_LIST*) sl->table_list.first;
|
||||
tables;
|
||||
tables= tables->next)
|
||||
{
|
||||
if (tables->table)
|
||||
tables->table->insert_values= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Given a query string with parameter markers, create a Prepared Statement
|
||||
from it and send PS info back to the client.
|
||||
@@ -1614,6 +1635,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
|
||||
|
||||
if (!error)
|
||||
error= send_prepare_results(stmt, test(name));
|
||||
cleanup_stmt_for_execute(stmt);
|
||||
|
||||
/* restore to WAIT_PRIOR: QUERY_PRIOR is set inside alloc_query */
|
||||
if (!(specialflag & SPECIAL_NO_PRIOR))
|
||||
@@ -1904,6 +1926,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
|
||||
reset_stmt_params(stmt);
|
||||
close_thread_tables(thd); // to close derived tables
|
||||
thd->set_statement(&thd->stmt_backup);
|
||||
cleanup_stmt_for_execute(stmt);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user