From 7b965030418e9460c9f0324cdea0f0decd9686ee Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 13:39:42 +0100 Subject: Bug#15518 Reusing a stmt that has failed during prepare does not clear error - Always reset error when calling mysql_stmt_prepare a second time - Set stmt->state to MYSQL_STMT_INIT_DONE before closing prepared stmt in server. - Add test to mysql_client_test - Remove mysql_stmt_close in mysqltest after each query - Close all open statements in mysqltest if disable_ps_protocol is called. client/mysqltest.c: Don't close the statement after each query - reprepare it in next query. When "disable_ps_protocol" is issued make sure to close all open statements. Otherwise the test for @@max_prepared_statements fails. But we also get a test that the statements that are open can be closed and reopened in the middle of the tests. libmysql/libmysql.c: Reset the last error every time mysql_stmt_prepare is called. Set state to MYSQL_STMT_INIT_DONE befoe closing it in the server. That way we will always have right status regardless of wheter close fails or not. tests/mysql_client_test.c: Add testcase for bug15518, re-prepare a previously prepare statement that has failed to prepare. Test also when connection to server has been lost inbetween. Change all assert to DIE_UNLESS so we get printout of line and an error message if it fails. --- client/mysqltest.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/mysqltest.c b/client/mysqltest.c index 005f204d571..b163b5887e4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -719,6 +719,20 @@ void close_connections() } +void close_statements() +{ + struct st_connection *con; + DBUG_ENTER("close_statements"); + for (con= connections; con < next_con; con++) + { + if (con->stmt) + mysql_stmt_close(con->stmt); + con->stmt= 0; + } + DBUG_VOID_RETURN; +} + + void close_files() { DBUG_ENTER("close_files"); @@ -2855,6 +2869,10 @@ void do_close_connection(struct st_command *command) } } #endif + if (next_con->stmt) + mysql_stmt_close(next_con->stmt); + next_con->stmt= 0; + mysql_close(&con->mysql); if (con->util_mysql) mysql_close(con->util_mysql); @@ -5050,10 +5068,7 @@ end: */ var_set_errno(mysql_stmt_errno(stmt)); -#ifndef BUG15518_FIXED - mysql_stmt_close(stmt); - cur_con->stmt= NULL; -#endif + DBUG_VOID_RETURN; } @@ -5838,6 +5853,8 @@ int main(int argc, char **argv) break; case Q_DISABLE_PS_PROTOCOL: ps_protocol_enabled= 0; + /* Close any open statements */ + close_statements(); break; case Q_ENABLE_PS_PROTOCOL: ps_protocol_enabled= ps_protocol; -- cgit v1.2.1