From 0a4b46be90c770de32e1de2352e745ce87484f00 Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 25 Jun 2007 13:31:34 +0500 Subject: [PATCH 1/2] Bug #29252 Assertion 'table->file || table->file->inited == handler::NONE' failed when index_init() or rnd_init() return an error, we still set handler->inited to INDEX or RND in ha_index_init and ha_rnd_init. As caller doesn't call ha_*_end() in this case, we get DBUG_ASSERT failed. --- sql/handler.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sql/handler.h b/sql/handler.h index 6a16dd96f49..cac272a9661 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1097,10 +1097,12 @@ public: int ha_index_init(uint idx, bool sorted) { + int result; DBUG_ENTER("ha_index_init"); DBUG_ASSERT(inited==NONE); - inited=INDEX; - DBUG_RETURN(index_init(idx, sorted)); + if (!(result= index_init(idx, sorted))) + inited=INDEX; + DBUG_RETURN(result); } int ha_index_end() { @@ -1111,10 +1113,11 @@ public: } int ha_rnd_init(bool scan) { + int result; DBUG_ENTER("ha_rnd_init"); DBUG_ASSERT(inited==NONE || (inited==RND && scan)); - inited=RND; - DBUG_RETURN(rnd_init(scan)); + inited= (result= rnd_init(scan)) ? NONE: RND; + DBUG_RETURN(result); } int ha_rnd_end() { From 43e0e17ae637ac5984905f7433d38bfe0cf7e9bc Mon Sep 17 00:00:00 2001 From: "holyfoot/hf@mysql.com/hfmain.(none)" <> Date: Mon, 25 Jun 2007 16:40:29 +0500 Subject: [PATCH 2/2] Bug #29247 Double free in libmysqlclient_r when mysql restarted. If one sets MYSQL_READ_DEFAULTS_FILE and MYSQL_READ_DEFAULT_GROUP options after mysql_real_connect() called with that MYSQL instance, these options will affect next mysql_reconnect then. As we use a copy of the original MYSQL object inside mysql_reconnect, and mysql_real_connect frees options.my_cnf_file and _group strings, we will free these twice when we execute mysql_reconnect with the same MYSQL for the second time. I don't think we should ever read defaults files handling mysql_reconnect. So i just set them to 0 for the temporary MYSQL object there/ --- sql-common/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sql-common/client.c b/sql-common/client.c index 3e5ceb1a738..c18c56e9c47 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2451,6 +2451,7 @@ my_bool mysql_reconnect(MYSQL *mysql) } mysql_init(&tmp_mysql); tmp_mysql.options= mysql->options; + tmp_mysql.options.my_cnf_file= tmp_mysql.options.my_cnf_group= 0; tmp_mysql.rpl_pivot= mysql->rpl_pivot; if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,