From: Date: March 28 2005 7:59pm Subject: bk commit into 4.1 tree (jimw:1.2147) BUG#8866 List-Archive: http://lists.mysql.com/internals/23414 X-Bug: 8866 Message-Id: <20050328175944.E18F7A9417@rama.trainedmonkey.com> Below is the list of changes that have just been committed into a local 4.1 repository of jimw. When jimw does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2147 05/03/28 09:59:41 jimw@stripped +4 -0 Fix reconnect when using prepared statements, and add --disable_reconnect and --enable_reconnect to mysqltest so that it can be tested properly. (Bug #8866) sql-common/client.c 1.83 05/03/28 09:59:39 jimw@stripped +27 -0 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. mysql-test/t/kill.test 1.7 05/03/28 09:59:39 jimw@stripped +8 -5 Fix test to actually verify that killing a connection is working, and that automatic reconnect is working as desired. mysql-test/r/kill.result 1.4 05/03/28 09:59:39 jimw@stripped +8 -0 Update results client/mysqltest.c 1.158 05/03/28 09:59:39 jimw@stripped +9 -0 Add support for --disable_reconnect and --enable_reconnect # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: jimw # Host: rama.(none) # Root: /home/jimw/my/mysql-4.1-8866 --- 1.82/sql-common/client.c 2005-01-16 07:38:32 -08:00 +++ 1.83/sql-common/client.c 2005-03-28 09:59:39 -08:00 @@ -2189,6 +2189,29 @@ 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 @@ 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))) --- 1.157/client/mysqltest.c 2005-02-08 09:49:25 -08:00 +++ 1.158/client/mysqltest.c 2005-03-28 09:59:39 -08:00 @@ -280,6 +280,7 @@ Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_START_TIMER, Q_END_TIMER, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, +Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -365,6 +366,8 @@ "character_set", "disable_ps_protocol", "enable_ps_protocol", + "disable_reconnect", + "enable_reconnect", 0 }; @@ -3623,6 +3626,12 @@ break; case Q_ENABLE_PS_PROTOCOL: ps_protocol_enabled= ps_protocol; + break; + case Q_DISABLE_RECONNECT: + cur_con->mysql.reconnect= 0; + break; + case Q_ENABLE_RECONNECT: + cur_con->mysql.reconnect= 1; break; default: processed = 0; break; --- 1.3/mysql-test/r/kill.result 2001-10-10 17:59:44 -07:00 +++ 1.4/mysql-test/r/kill.result 2005-03-28 09:59:39 -08:00 @@ -5,6 +5,14 @@ ((@id := kill_id) - kill_id) 0 kill @id; +select 1; +ERROR HY000: MySQL server has gone away +select ((@id := kill_id) - kill_id) from t1; +((@id := kill_id) - kill_id) +0 +select @id != connection_id(); +@id != connection_id() +1 select 4; 4 4 --- 1.6/mysql-test/t/kill.test 2003-01-05 15:48:52 -08:00 +++ 1.7/mysql-test/t/kill.test 2005-03-28 09:59:39 -08:00 @@ -23,12 +23,15 @@ select ((@id := kill_id) - kill_id) from t1; kill @id; -# Wait for thread to do. ---sleep 5 -# verify that con1 is doning a reconnect connection con1; -ping -ping + +--disable_reconnect +# this statement should fail +--error 2006 +select 1; +--enable_reconnect +# this should work, and we should have a new connection_id() +select ((@id := kill_id) - kill_id) from t1; select @id != connection_id(); #make sure the server is still alive