mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#12713 "Error in a stored function called from a SELECT doesn't
cause ROLLBACK of statement", part 1. Review fixes. Do not send OK/EOF packets to the client until we reached the end of the current statement. This is a consolidation, to keep the functionality that is shared by all SQL statements in one place in the server. Currently this functionality includes: - close_thread_tables() - log_slow_statement(). After this patch and the subsequent patch for Bug#12713, it shall also include: - ha_autocommit_or_rollback() - net_end_statement() - query_cache_end_of_result(). In future it may also include: - mysql_reset_thd_for_next_command().
This commit is contained in:
@ -230,6 +230,8 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
|
||||
NET *net= &stmt->thd->net;
|
||||
uchar buff[12];
|
||||
uint tmp;
|
||||
int error;
|
||||
THD *thd= stmt->thd;
|
||||
DBUG_ENTER("send_prep_stmt");
|
||||
|
||||
buff[0]= 0; /* OK packet indicator */
|
||||
@ -244,11 +246,16 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
|
||||
Send types and names of placeholders to the client
|
||||
XXX: fix this nasty upcast from List<Item_param> to List<Item>
|
||||
*/
|
||||
DBUG_RETURN(my_net_write(net, buff, sizeof(buff)) ||
|
||||
(stmt->param_count &&
|
||||
stmt->thd->protocol_text.send_fields((List<Item> *)
|
||||
&stmt->lex->param_list,
|
||||
Protocol::SEND_EOF)));
|
||||
error= my_net_write(net, buff, sizeof(buff));
|
||||
if (stmt->param_count && ! error)
|
||||
{
|
||||
error= thd->protocol_text.send_fields((List<Item> *)
|
||||
&stmt->lex->param_list,
|
||||
Protocol::SEND_EOF);
|
||||
}
|
||||
/* Flag that a response has already been sent */
|
||||
thd->main_da.disable_status();
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
#else
|
||||
static bool send_prep_stmt(Prepared_statement *stmt,
|
||||
@ -259,6 +266,7 @@ static bool send_prep_stmt(Prepared_statement *stmt,
|
||||
thd->client_stmt_id= stmt->id;
|
||||
thd->client_param_count= stmt->param_count;
|
||||
thd->clear_error();
|
||||
thd->main_da.disable_status();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2526,6 +2534,8 @@ void mysql_stmt_close(THD *thd, char *packet)
|
||||
DBUG_ASSERT(! (stmt->flags & (uint) Prepared_statement::IS_IN_USE));
|
||||
(void) stmt->deallocate();
|
||||
|
||||
thd->main_da.disable_status();
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -2590,6 +2600,8 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
|
||||
DBUG_ENTER("mysql_stmt_get_longdata");
|
||||
|
||||
status_var_increment(thd->status_var.com_stmt_send_long_data);
|
||||
|
||||
thd->main_da.disable_status();
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
/* Minimal size of long data packet is 6 bytes */
|
||||
if (packet_length < MYSQL_LONG_DATA_HEADER)
|
||||
@ -2664,11 +2676,7 @@ bool Select_fetch_protocol_binary::send_fields(List<Item> &list, uint flags)
|
||||
|
||||
bool Select_fetch_protocol_binary::send_eof()
|
||||
{
|
||||
Protocol *save_protocol= thd->protocol;
|
||||
|
||||
thd->protocol= &protocol;
|
||||
::send_eof(thd);
|
||||
thd->protocol= save_protocol;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -3097,7 +3105,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
|
||||
thd->query_length) <= 0)
|
||||
{
|
||||
error= mysql_execute_command(thd);
|
||||
query_cache_end_of_result(thd);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user