summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorunknown <davi@mysql.com/endora.local>2008-03-14 17:40:12 -0300
committerunknown <davi@mysql.com/endora.local>2008-03-14 17:40:12 -0300
commit063b50477296f20b22e5cc5c1f50b8302ef55c19 (patch)
tree5b4b1c1d904c1fa627910fa50ffd694754908060 /sql-common
parent326c4e90589dd87792eacfa6e8746bc486a10ba0 (diff)
downloadmariadb-git-063b50477296f20b22e5cc5c1f50b8302ef55c19.tar.gz
Bug#35103 mysql_client_test::test_bug29948 causes sporadic failures
The problem was that the COM_STMT_SEND_LONG_DATA was sending a response packet if the prepared statement wasn't found in the server (due to reconnection). The commands COM_STMT_SEND_LONG_DATA and COM_STMT_CLOSE should not send any packets, even error packets should not be sent since they are not expected by the client API. The solution is to clear generated during the execution of the aforementioned commands and to skip resend of prepared statement commands. Another fix is that if the connection breaks during the send of prepared statement command, the command is not sent again since the prepared statement is no longer in the server. libmysql/libmysql.c: The mysql handle might be reset after a reconnection. Pass the now used stmt argument to cli_advanced_command. sql-common/client.c: Don't resend command if the connection broke and it's a prepared statement command. If the session is broken, prepared statements on the server are gone, set the error accordanly. sql/sql_prepare.cc: Clear any error set during the execution of the request command. tests/mysql_client_test.c: Fix memory leak by freeing result associated with statement. Remove test case for Bug 29948 because it's not reliable in 5.0 (fixed in 5.1) due to KILL queries sending two packets for a thread that kills itself.
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 1fc73549520..8b619b5452d 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -665,11 +665,12 @@ my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
const char *arg, ulong arg_length, my_bool skip_check,
- MYSQL_STMT *stmt __attribute__((unused)))
+ MYSQL_STMT *stmt)
{
NET *net= &mysql->net;
my_bool result= 1;
init_sigpipe_variables
+ my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE;
DBUG_ENTER("cli_advanced_command");
/* Don't give sigpipe errors if the client doesn't want them */
@@ -677,7 +678,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (mysql->net.vio == 0)
{ /* Do reconnect if possible */
- if (mysql_reconnect(mysql))
+ if (mysql_reconnect(mysql) || stmt_skip)
DBUG_RETURN(1);
}
if (mysql->status != MYSQL_STATUS_READY ||
@@ -708,7 +709,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
goto end;
}
end_server(mysql);
- if (mysql_reconnect(mysql))
+ if (mysql_reconnect(mysql) || stmt_skip)
goto end;
if (net_write_command(net,(uchar) command, header, header_length,
arg, arg_length))
@@ -2503,6 +2504,9 @@ my_bool mysql_reconnect(MYSQL *mysql)
if (stmt->state != MYSQL_STMT_INIT_DONE)
{
stmt->mysql= 0;
+ stmt->last_errno= CR_SERVER_LOST;
+ strmov(stmt->last_error, ER(CR_SERVER_LOST));
+ strmov(stmt->sqlstate, unknown_sqlstate);
}
else
{