1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00
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:
unknown
2004-12-14 08:12:04 +00:00
parent e19a3042ef
commit 17d1552bbb

View File

@@ -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 Given a query string with parameter markers, create a Prepared Statement
from it and send PS info back to the client. 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) if (!error)
error= send_prepare_results(stmt, test(name)); error= send_prepare_results(stmt, test(name));
cleanup_stmt_for_execute(stmt);
/* restore to WAIT_PRIOR: QUERY_PRIOR is set inside alloc_query */ /* restore to WAIT_PRIOR: QUERY_PRIOR is set inside alloc_query */
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
@@ -1904,6 +1926,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt,
reset_stmt_params(stmt); reset_stmt_params(stmt);
close_thread_tables(thd); // to close derived tables close_thread_tables(thd); // to close derived tables
thd->set_statement(&thd->stmt_backup); thd->set_statement(&thd->stmt_backup);
cleanup_stmt_for_execute(stmt);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }