Commit 151495ba authored by unknown's avatar unknown

mysql_stmt_reset now expects ok/error packet from server.


libmysql/libmysql.c:
  Make advanced_command check client reply
sql/sql_prepare.cc:
  mysql_stmt_reset now sends ok/error reply to the client.
tests/client_test.c:
  Memory leak fixed.
parent ffdf46a5
...@@ -3992,7 +3992,8 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt) ...@@ -3992,7 +3992,8 @@ my_bool STDCALL mysql_stmt_reset(MYSQL_STMT *stmt)
mysql= stmt->mysql->last_used_con; mysql= stmt->mysql->last_used_con;
int4store(buff, stmt->stmt_id); /* Send stmt id to server */ int4store(buff, stmt->stmt_id); /* Send stmt id to server */
if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT,buff,MYSQL_STMT_HEADER,0,0,1)) if ((*mysql->methods->advanced_command)(mysql, COM_RESET_STMT, buff,
MYSQL_STMT_HEADER,0,0,0))
{ {
set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno,
mysql->net.sqlstate); mysql->net.sqlstate);
......
...@@ -1555,18 +1555,20 @@ set_params_data_err: ...@@ -1555,18 +1555,20 @@ set_params_data_err:
/* /*
Reset a prepared statement, in case there was an error in send_longdata. Reset a prepared statement in case there was a recoverable error.
Note: we don't send any reply to that command.
SYNOPSIS SYNOPSIS
mysql_stmt_reset() mysql_stmt_reset()
thd Thread handle thd Thread handle
packet Packet with stmt id packet Packet with stmt id
DESCRIPTION DESCRIPTION
This function is useful when one gets an error after calling This function resets statement to the state it was right after prepare.
mysql_stmt_getlongdata() and wants to reset the handle It can be used to:
so that one can call execute again. - clear an error happened during mysql_stmt_send_long_data
See also bug #1664 - cancel long data stream for all placeholders without
having to call mysql_stmt_execute.
Sends 'OK' packet in case of success (statement was reset)
or 'ERROR' packet (unrecoverable error/statement not found/etc).
*/ */
void mysql_stmt_reset(THD *thd, char *packet) void mysql_stmt_reset(THD *thd, char *packet)
...@@ -1577,7 +1579,7 @@ void mysql_stmt_reset(THD *thd, char *packet) ...@@ -1577,7 +1579,7 @@ void mysql_stmt_reset(THD *thd, char *packet)
DBUG_ENTER("mysql_stmt_reset"); DBUG_ENTER("mysql_stmt_reset");
if (!(stmt= find_prepared_statement(thd, stmt_id, "reset", DONT_SEND_ERROR))) if (!(stmt= find_prepared_statement(thd, stmt_id, "reset", SEND_ERROR)))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
stmt->get_longdata_error= 0; stmt->get_longdata_error= 0;
...@@ -1587,6 +1589,8 @@ void mysql_stmt_reset(THD *thd, char *packet) ...@@ -1587,6 +1589,8 @@ void mysql_stmt_reset(THD *thd, char *packet)
mysql_stmt_send_long_data() call. mysql_stmt_send_long_data() call.
*/ */
reset_stmt_params(stmt); reset_stmt_params(stmt);
send_ok(thd);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -163,8 +163,11 @@ MYSQL_STMT *STDCALL ...@@ -163,8 +163,11 @@ MYSQL_STMT *STDCALL
mysql_simple_prepare(MYSQL *mysql, const char *query) mysql_simple_prepare(MYSQL *mysql, const char *query)
{ {
MYSQL_STMT *stmt= mysql_stmt_init(mysql); MYSQL_STMT *stmt= mysql_stmt_init(mysql);
if (mysql_stmt_prepare(stmt, query, strlen(query))) if (stmt && mysql_stmt_prepare(stmt, query, strlen(query)))
{
mysql_stmt_close(stmt);
return 0; return 0;
}
return stmt; return stmt;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment