From 8a2f3f4b5ed8778c00b6ad169aaad28a4eb6058c Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Tue, 29 Jun 2010 10:28:17 +0200 Subject: [PATCH 1/2] Fix of bad merge of test case for Bug#41660 (test case moved). --- mysql-test/t/error_simulation.test | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index 8e65c338f36..f6edacfaa29 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -45,6 +45,20 @@ SHOW CREATE TABLE t1; SELECT * FROM t1; DROP TABLE t1; +--echo # +--echo # Bug#42064: low memory crash when importing hex strings, in Item_hex_string::Item_hex_string +--echo # + +CREATE TABLE t1(a BLOB); + +SET SESSION debug="+d,bug42064_simulate_oom"; +# May fail with either ER_OUT_OF_RESOURCES or EE_OUTOFMEMORY +--error ER_OUT_OF_RESOURCES, 5 +INSERT INTO t1 VALUES(""); +SET SESSION debug=DEFAULT; + +DROP TABLE t1; + -- echo # -- echo # Bug#41660: Sort-index_merge for non-first join table may require -- echo # O(#scans) memory @@ -75,20 +89,6 @@ SET SESSION debug = DEFAULT; DROP TABLE t1, t2; ---echo # ---echo # Bug#42064: low memory crash when importing hex strings, in Item_hex_string::Item_hex_string ---echo # - -CREATE TABLE t1(a BLOB); - -SET SESSION debug="+d,bug42064_simulate_oom"; -# May fail with either ER_OUT_OF_RESOURCES or EE_OUTOFMEMORY ---error ER_OUT_OF_RESOURCES, 5 -INSERT INTO t1 VALUES(""); -SET SESSION debug=DEFAULT; - -DROP TABLE t1; - --echo # --echo # End of 5.1 tests --echo # From 3b3983a4083eab3b86c1817f61be9f7471b8f1b5 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Wed, 30 Jun 2010 11:16:06 +0200 Subject: [PATCH 2/2] Bug #53899 Wrong mysql_stmt_errno() after connection loss with automatic reconnect A client with automatic reconnect enabled will see the error message "Lost connection to MySQL server during query" if the connection is lost between mysql_stmt_prepare() and mysql_stmt_execute(). The mysql_stmt_errno() number, however, is 0 -- not the corresponding value 2013. This patch checks for the case where the prepared statement has been pruned due to a connection loss (i.e., stmt->mysql has been set to NULL) during a call to cli_advanced_command(), and avoids changing the last_errno to the result of the last reconnect attempt. --- libmysql/libmysql.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 6ea777a0702..0ba85c1ac07 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2495,7 +2495,12 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) stmt->insert_id= mysql->insert_id; if (res) { - set_stmt_errmsg(stmt, net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } DBUG_RETURN(0); @@ -2706,7 +2711,12 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - set_stmt_errmsg(stmt, net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, net); return 1; } if ((*mysql->methods->read_rows_from_cursor)(stmt)) @@ -3387,7 +3397,12 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, buff, sizeof(buff), (uchar*) data, length, 1, stmt)) { - set_stmt_errmsg(stmt, &mysql->net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, &mysql->net); DBUG_RETURN(1); } } @@ -4823,7 +4838,12 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { - set_stmt_errmsg(stmt, net); + /* + Don't set stmt error if stmt->mysql is NULL, as the error in this case + has already been set by mysql_prune_stmt_list(). + */ + if (stmt->mysql) + set_stmt_errmsg(stmt, net); DBUG_RETURN(1); } }