From 77d78a883fa61550ab9686f5c7ca0cec9c08ea8a Mon Sep 17 00:00:00 2001 From: "davi@moksha.local" <> Date: Mon, 27 Aug 2007 10:37:12 -0300 Subject: [PATCH] Bug#30632 HANDLER read failure causes hang If, after the tables are locked, one of the conditions to read from a HANDLER table is not met, the handler code wrongly jumps to a error path that won't unlock the tables. The user-visible effect is that after a error in a handler read command, all subsequent handler operations on the same table will hang. The fix is simply to correct the code to jump to the (same) error path that unlocks the tables. --- mysql-test/r/handler.result | 13 +++++++++++++ mysql-test/t/handler.test | 19 +++++++++++++++++++ sql/sql_handler.cc | 6 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result index 5e123df9103..dc3750e16ea 100644 --- a/mysql-test/r/handler.result +++ b/mysql-test/r/handler.result @@ -489,3 +489,16 @@ handler t1 open; ERROR HY000: Table storage engine for 't1' doesn't have this option --> client 1 drop table t1; +drop table if exists t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias read a next; +ERROR HY000: Key 'a' doesn't exist in table 't1_alias' +handler t1_alias READ a next where inexistent > 0; +ERROR 42S22: Unknown column 'inexistent' in 'field list' +handler t1_alias read a next; +ERROR HY000: Key 'a' doesn't exist in table 't1_alias' +handler t1_alias READ a next where inexistent > 0; +ERROR 42S22: Unknown column 'inexistent' in 'field list' +handler t1_alias close; +drop table t1; diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index 4edd5b5ec32..6ef216f6ed2 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -441,3 +441,22 @@ handler t1 open; --echo --> client 1 connection default; drop table t1; + +# +# Bug#30632 HANDLER read failure causes hang +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +handler t1 open as t1_alias; +--error 1176 +handler t1_alias read a next; +--error 1054 +handler t1_alias READ a next where inexistent > 0; +--error 1176 +handler t1_alias read a next; +--error 1054 +handler t1_alias READ a next where inexistent > 0; +handler t1_alias close; +drop table t1; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 83c141f099f..9aefa71647e 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -440,7 +440,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, cond->cleanup(); // File was reopened if ((!cond->fixed && cond->fix_fields(thd, &cond)) || cond->check_cols(1)) - goto err0; + goto err; } if (keyname) @@ -448,13 +448,13 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, if ((keyno=find_type(keyname, &table->s->keynames, 1+2)-1)<0) { my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), keyname, tables->alias); - goto err0; + goto err; } } if (insert_fields(thd, &thd->lex->select_lex.context, tables->db, tables->alias, &it, 0)) - goto err0; + goto err; protocol->send_fields(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);