Bug #53899 Wrong mysql_stmt_errno() after connection loss with
automatic reconnect A client with automatic reconnect enabled will see the error message "Lost connection to MySQL server during query" if the connection is lost between mysql_stmt_prepare() and mysql_stmt_execute(). The mysql_stmt_errno() number, however, is 0 -- not the corresponding value 2013. This patch checks for the case where the prepared statement has been pruned due to a connection loss (i.e., stmt->mysql has been set to NULL) during a call to cli_advanced_command(), and avoids changing the last_errno to the result of the last reconnect attempt.
This commit is contained in:
parent
8a2f3f4b5e
commit
3b3983a408
@ -2495,6 +2495,11 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
|
|||||||
stmt->insert_id= mysql->insert_id;
|
stmt->insert_id= mysql->insert_id;
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Don't set stmt error if stmt->mysql is NULL, as the error in this case
|
||||||
|
has already been set by mysql_prune_stmt_list().
|
||||||
|
*/
|
||||||
|
if (stmt->mysql)
|
||||||
set_stmt_errmsg(stmt, net);
|
set_stmt_errmsg(stmt, net);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
@ -2706,6 +2711,11 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row)
|
|||||||
buff, sizeof(buff), (uchar*) 0, 0,
|
buff, sizeof(buff), (uchar*) 0, 0,
|
||||||
1, stmt))
|
1, stmt))
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Don't set stmt error if stmt->mysql is NULL, as the error in this case
|
||||||
|
has already been set by mysql_prune_stmt_list().
|
||||||
|
*/
|
||||||
|
if (stmt->mysql)
|
||||||
set_stmt_errmsg(stmt, net);
|
set_stmt_errmsg(stmt, net);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -3387,6 +3397,11 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
|
|||||||
buff, sizeof(buff), (uchar*) data,
|
buff, sizeof(buff), (uchar*) data,
|
||||||
length, 1, stmt))
|
length, 1, stmt))
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Don't set stmt error if stmt->mysql is NULL, as the error in this case
|
||||||
|
has already been set by mysql_prune_stmt_list().
|
||||||
|
*/
|
||||||
|
if (stmt->mysql)
|
||||||
set_stmt_errmsg(stmt, &mysql->net);
|
set_stmt_errmsg(stmt, &mysql->net);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
@ -4823,6 +4838,11 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
|
|||||||
if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
|
if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
|
||||||
(uchar*) 0, 0, 1, stmt))
|
(uchar*) 0, 0, 1, stmt))
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Don't set stmt error if stmt->mysql is NULL, as the error in this case
|
||||||
|
has already been set by mysql_prune_stmt_list().
|
||||||
|
*/
|
||||||
|
if (stmt->mysql)
|
||||||
set_stmt_errmsg(stmt, net);
|
set_stmt_errmsg(stmt, net);
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user