diff options
author | unknown <msvensson@neptunus.(none)> | 2007-01-16 13:39:42 +0100 |
---|---|---|
committer | unknown <msvensson@neptunus.(none)> | 2007-01-16 13:39:42 +0100 |
commit | 7b965030418e9460c9f0324cdea0f0decd9686ee (patch) | |
tree | c33a821cc43b96773ccb3649535c3122cf5a87b9 /client | |
parent | 89d106c1a4efad141e7850373335482ad46aeec5 (diff) | |
download | mariadb-git-7b965030418e9460c9f0324cdea0f0decd9686ee.tar.gz |
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.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.c | 25 |
1 files changed, 21 insertions, 4 deletions
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; |