Below is the list of changes that have just been committed into a local
5.0 repository of davi. When davi 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@stripped, 2008-03-14 11:19:10-03:00, davi@stripped +4 -0
Bug#35103 mysql_client_test::test_bug29948 causes sporadic failures
The problem is that the COM_STMT_RESET command was sending a response
packet if the prepared statement wasn't found in the server. The commands
COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE and COM_STMT_RESET should not
send any packets, even error packets should not be sent since they are
not expected by the client API.
The solution is to clear generated during the execution of the aforementioned
commands and to skip resend of prepared statement commands. Another fix is
that if the connection breaks during the send of prepared statement command,
the command is not sent again since the prepared statement is no longer in the
server.
libmysql/libmysql.c@stripped, 2008-03-14 11:19:08-03:00, davi@stripped +7 -0
The mysql handle might be reset if after a reconnection.
sql-common/client.c@stripped, 2008-03-14 11:19:08-03:00, davi@stripped +19 -1
Don't resend command if the connection broken and it's a
prepared statement command. If the session is broken, prepared
statements on the server are gone.
sql/sql_parse.cc@stripped, 2008-03-14 11:19:08-03:00, davi@stripped +6 -0
Clear any error set during the execution. It's better to clear the
error at this point then to inspect all possible code paths or to
install a error handler.
tests/mysql_client_test.c@stripped, 2008-03-14 11:19:09-03:00, davi@stripped +1 -78
Fix memory leak by freeing result associated with statement.
Remove test case for Bug 29948 because it's not reliable in
5.0 (fixed in 5.1) due to KILL queries sending two packets for
a thread that kills itself.
diff -Nrup a/libmysql/libmysql.c b/libmysql/libmysql.c
--- a/libmysql/libmysql.c 2007-11-26 14:09:35 -02:00
+++ b/libmysql/libmysql.c 2008-03-14 11:19:08 -03:00
@@ -4737,6 +4737,13 @@ int STDCALL mysql_stmt_store_result(MYSQ
MYSQL_DATA *result= &stmt->result;
DBUG_ENTER("mysql_stmt_store_result");
+ if (!mysql)
+ {
+ /* mysql can be reset in mysql_close called from mysql_reconnect */
+ set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate);
+ DBUG_RETURN(1);
+ }
+
mysql= mysql->last_used_con;
if (!stmt->field_count)
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc 2008-02-20 22:22:00 -03:00
+++ b/sql/sql_parse.cc 2008-03-14 11:19:08 -03:00
@@ -1839,6 +1839,8 @@ bool dispatch_command(enum enum_server_c
case COM_STMT_SEND_LONG_DATA:
{
mysql_stmt_get_longdata(thd, packet, packet_length);
+ // clear errors, response packet is not expected
+ thd->clear_error();
break;
}
case COM_STMT_PREPARE:
@@ -1849,11 +1851,15 @@ bool dispatch_command(enum enum_server_c
case COM_STMT_CLOSE:
{
mysql_stmt_close(thd, packet);
+ // clear errors, response packet is not expected
+ thd->clear_error();
break;
}
case COM_STMT_RESET:
{
mysql_stmt_reset(thd, packet);
+ // clear errors, response packet is not expected
+ thd->clear_error();
break;
}
case COM_QUERY:
diff -Nrup a/sql-common/client.c b/sql-common/client.c
--- a/sql-common/client.c 2007-11-28 12:23:48 -02:00
+++ b/sql-common/client.c 2008-03-14 11:19:08 -03:00
@@ -661,6 +661,24 @@ void free_rows(MYSQL_DATA *cur)
}
}
+static my_bool
+skip_resend(NET *net, enum enum_server_command command)
+{
+ switch (command) {
+ case COM_STMT_EXECUTE:
+ case COM_STMT_FETCH:
+ case COM_STMT_SEND_LONG_DATA:
+ case COM_STMT_PREPARE:
+ case COM_STMT_CLOSE:
+ case COM_STMT_RESET:
+ net->last_errno= CR_SERVER_GONE_ERROR;
+ strmov(net->last_error, ER(net->last_errno));
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
@@ -708,7 +726,7 @@ cli_advanced_command(MYSQL *mysql, enum
goto end;
}
end_server(mysql);
- if (mysql_reconnect(mysql))
+ if (mysql_reconnect(mysql) || skip_resend(net, command))
goto end;
if (net_write_command(net,(uchar) command, header, header_length,
arg, arg_length))
diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c
--- a/tests/mysql_client_test.c 2008-03-06 09:16:52 -03:00
+++ b/tests/mysql_client_test.c 2008-03-14 11:19:09 -03:00
@@ -11746,6 +11746,7 @@ static void test_bug5194()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
+ mysql_stmt_reset(stmt);
}
mysql_stmt_close(stmt);
@@ -15942,83 +15943,6 @@ static void test_bug27592()
DBUG_VOID_RETURN;
}
-#if 0
-
-static void test_bug29948()
-{
- MYSQL *dbc=NULL;
- MYSQL_STMT *stmt=NULL;
- MYSQL_BIND bind;
-
- int res=0;
- my_bool auto_reconnect=1, error=0, is_null=0;
- char kill_buf[20];
- const char *query;
- int buf;
- unsigned long length, cursor_type;
-
- dbc = mysql_init(NULL);
- DIE_UNLESS(dbc);
-
- mysql_options(dbc, MYSQL_OPT_RECONNECT, (char*)&auto_reconnect);
- if (!mysql_real_connect(dbc, opt_host, opt_user,
- opt_password, current_db, opt_port,
- opt_unix_socket,
- (CLIENT_FOUND_ROWS | CLIENT_MULTI_STATEMENTS |
- CLIENT_MULTI_RESULTS)))
- {
- printf("connection failed: %s (%d)", mysql_error(dbc),
- mysql_errno(dbc));
- exit(1);
- }
-
- bzero(&bind, sizeof(bind));
- bind.buffer_type= MYSQL_TYPE_LONG;
- bind.buffer= (char *)&buf;
- bind.is_null= &is_null;
- bind.error= &error;
- bind.length= &length;
-
- res= mysql_query(dbc, "DROP TABLE IF EXISTS t1");
- myquery(res);
- res= mysql_query(dbc, "CREATE TABLE t1 (a INT)");
- myquery(res);
- res= mysql_query(dbc, "INSERT INTO t1 VALUES(1)");
- myquery(res);
-
- stmt= mysql_stmt_init(dbc);
- check_stmt(stmt);
-
- cursor_type= CURSOR_TYPE_READ_ONLY;
- res= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void *)&cursor_type);
- myquery(res);
-
- query= "SELECT * from t1 where a=?";
- res= mysql_stmt_prepare(stmt, query, strlen(query));
- myquery(res);
-
- res= mysql_stmt_bind_param(stmt, &bind);
- myquery(res);
-
- res= mysql_stmt_execute(stmt);
- check_execute(stmt, res);
-
- res= mysql_stmt_bind_result(stmt,&bind);
- check_execute(stmt, res);
-
- sprintf(kill_buf, "kill %ld", dbc->thread_id);
- mysql_query(dbc, kill_buf);
-
- res= mysql_stmt_store_result(stmt);
- DIE_UNLESS(res);
-
- mysql_stmt_free_result(stmt);
- mysql_stmt_close(stmt);
- mysql_query(dbc, "DROP TABLE t1");
- mysql_close(dbc);
-}
-
-#endif
/**
Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW
@@ -16546,7 +16470,6 @@ static struct my_tests_st my_tests[]= {
{ "test_bug28505", test_bug28505 },
{ "test_bug28934", test_bug28934 },
{ "test_bug27592", test_bug27592 },
- /* { "test_bug29948", test_bug29948 }, Bug#35103 */
{ "test_bug29306", test_bug29306 },
{ "test_bug31669", test_bug31669 },
{ "test_bug32265", test_bug32265 },
| Thread |
|---|
| • bk commit into 5.0 tree (davi:1.2597) BUG#35103 | Davi Arnaut | 14 Mar |