#At file:///export/home/tmp/ss156133/z/43560-51g/ based on revid:pstoev@stripped
2884 Staale Smedseng 2009-05-14
Bug #43560 client crashes in mysql_stmt_execute/
mysql_stmt_close after connection loss
Added test for net->vio != 0 to avoid the SIGSEGV,
and setting the proper error code.
Also, added some code to correctly associate error
state with the statement being executed.
This is due to the fact that mysql_reconnect() only
relates to statements if auto-reconnect is turned on.
modified:
libmysql/libmysql.c
=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c 2009-03-24 13:58:52 +0000
+++ b/libmysql/libmysql.c 2009-05-14 13:30:16 +0000
@@ -2485,13 +2485,16 @@ static my_bool execute(MYSQL_STMT *stmt,
buff[4]= (char) stmt->flags;
int4store(buff+5, 1); /* iteration count */
+ stmt_clear_error(stmt);
res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff),
(uchar*) packet, length, 1, stmt) ||
(*mysql->methods->read_query_result)(mysql));
stmt->affected_rows= mysql->affected_rows;
stmt->server_status= mysql->server_status;
stmt->insert_id= mysql->insert_id;
- if (res)
+
+ /* if stmt->last_errno hasn't already been set, use the net error */
+ if (res && stmt->last_errno == 0)
{
set_stmt_errmsg(stmt, net);
DBUG_RETURN(1);
@@ -2513,6 +2516,7 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
ulong length;
uint null_count;
my_bool result;
+ my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE;
if (!stmt->bind_param_done)
{
@@ -2526,6 +2530,17 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
DBUG_RETURN(1);
}
+ if (!net->vio)
+ {
+ stmt_clear_error(stmt);
+ if (mysql_reconnect(mysql) || stmt_skip) /* Reconnect if possible */
+ {
+ /* associate an error with the stmt if not already done */
+ if (stmt->last_errno == 0)
+ set_stmt_errmsg(stmt, net);
+ DBUG_RETURN(1);
+ }
+ }
net_clear(net, 1); /* Sets net->write_pos */
/* Reserve place for null-marker bytes */
null_count= (stmt->param_count+7) /8;
Attachment: [text/bzr-bundle] bzr/staale.smedseng@sun.com-20090514133016-icrd7h0wirz4ws8n.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (staale.smedseng:2884) Bug#43560 | Staale Smedseng | 14 May |