#At file:///export/home/tmp/ss156133/z/53899-51/ based on revid:georgi.kodinov@stripped
3419 Staale Smedseng 2010-06-29
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.
modified:
libmysql/libmysql.c
=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c 2010-02-26 14:30:14 +0000
+++ b/libmysql/libmysql.c 2010-06-29 16:57:07 +0000
@@ -2495,7 +2495,12 @@ static my_bool execute(MYSQL_STMT *stmt,
stmt->insert_id= mysql->insert_id;
if (res)
{
- set_stmt_errmsg(stmt, net);
+ /*
+ 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);
DBUG_RETURN(1);
}
DBUG_RETURN(0);
@@ -2706,7 +2711,12 @@ stmt_read_row_from_cursor(MYSQL_STMT *st
buff, sizeof(buff), (uchar*) 0, 0,
1, stmt))
{
- set_stmt_errmsg(stmt, net);
+ /*
+ 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);
return 1;
}
if ((*mysql->methods->read_rows_from_cursor)(stmt))
@@ -3387,7 +3397,12 @@ mysql_stmt_send_long_data(MYSQL_STMT *st
buff, sizeof(buff), (uchar*) data,
length, 1, stmt))
{
- set_stmt_errmsg(stmt, &mysql->net);
+ /*
+ 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);
DBUG_RETURN(1);
}
}
@@ -4823,7 +4838,12 @@ int STDCALL mysql_stmt_store_result(MYSQ
if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff),
(uchar*) 0, 0, 1, stmt))
{
- set_stmt_errmsg(stmt, net);
+ /*
+ 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);
DBUG_RETURN(1);
}
}
Attachment: [text/bzr-bundle] bzr/staale.smedseng@sun.com-20100629165707-t1slpbk61jaf6zf9.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (staale.smedseng:3419) Bug#53899 | Staale Smedseng | 29 Jun |