diff options
author | unknown <jimw@mysql.com> | 2005-03-28 09:59:41 -0800 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-03-28 09:59:41 -0800 |
commit | 92db4a838f9198ab0924b8b876b5991bfe00e8d9 (patch) | |
tree | 78e84e0886e0c93e92557c2a21167ac6e8d2ebd2 /sql-common/client.c | |
parent | 3785d2188f557bc01be28e7f2480be42ca598ab9 (diff) | |
download | mariadb-git-92db4a838f9198ab0924b8b876b5991bfe00e8d9.tar.gz |
Fix reconnect when using prepared statements, and add
--disable_reconnect and --enable_reconnect to mysqltest
so that it can be tested properly. (Bug #8866)
client/mysqltest.c:
Add support for --disable_reconnect and --enable_reconnect
mysql-test/r/kill.result:
Update results
mysql-test/t/kill.test:
Fix test to actually verify that killing a connection is working,
and that automatic reconnect is working as desired.
sql-common/client.c:
Clean up MYSQL->stmts on reconnect by invalidating statements
not in the MYSQL_STMT_INIT_DONE state, and reconnecting others
to the new MYSQL object.
Diffstat (limited to 'sql-common/client.c')
-rw-r--r-- | sql-common/client.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 3de2483ef75..b1455f0976a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2189,6 +2189,29 @@ my_bool mysql_reconnect(MYSQL *mysql) DBUG_RETURN(1); } tmp_mysql.free_me= mysql->free_me; + + /* + For each stmt in mysql->stmts, move it to tmp_mysql if it is + in state MYSQL_STMT_INIT_DONE, otherwise close it. + */ + { + LIST *element= mysql->stmts; + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + if (stmt->state != MYSQL_STMT_INIT_DONE) + { + stmt->mysql= 0; + } + else + { + tmp_mysql.stmts= list_add(tmp_mysql.stmts, &stmt->list); + } + /* No need to call list_delete for statement here */ + } + mysql->stmts= NULL; + } + /* Don't free options as these are now used in tmp_mysql */ bzero((char*) &mysql->options,sizeof(mysql->options)); mysql->free_me=0; @@ -2277,6 +2300,10 @@ static void mysql_close_free(MYSQL *mysql) SYNOPSYS mysql_detach_stmt_list() stmt_list pointer to mysql->stmts + + NOTE + There is similar code in mysql_reconnect(), so changes here + should also be reflected there. */ void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused))) |