diff options
author | unknown <svoj@mysql.com/june.mysql.com> | 2008-03-07 18:41:50 +0400 |
---|---|---|
committer | unknown <svoj@mysql.com/june.mysql.com> | 2008-03-07 18:41:50 +0400 |
commit | 44df0f6e9cece95b914f3f3b0ce3d3baa6f2dbf1 (patch) | |
tree | 13e34f7c8b77b46abce848e37244196b67932b31 | |
parent | 1ed34fed3390e10ff67981c4470f46c6ce1e2a6e (diff) | |
download | mariadb-git-44df0f6e9cece95b914f3f3b0ce3d3baa6f2dbf1.tar.gz |
BUG#34656 - KILL a query = Assertion failed: m_status == DA_ERROR ||
m_status == DA_OK
Reading from information_scema.tables or information_schema.columns
may cause assertion failure in debug builds. This may happen under
rare circumstances when information_schema fails to get information
about a table (e.g. when a connection is killed).
This happens because open_normal_and_derived_tables() can return an
error without setting an error message in THD. But information_schema
attempts to get an error message from THD unconditionally.
With this fix information_schema attempts to get an error message
from THD only in case error message is set in THD.
mysql-test/r/information_schema.result:
A test case for BUG#34656.
mysql-test/t/information_schema.test:
A test case for BUG#34656.
sql/item_func.cc:
Set proc info to "User sleep".
sql/sql_show.cc:
open_normal_and_derived_tables() can return an error without
setting an error message in THD. That means we must access
error message conditionally, only in case thd->is_error() is
true.
-rw-r--r-- | mysql-test/r/information_schema.result | 2 | ||||
-rw-r--r-- | mysql-test/t/information_schema.test | 44 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 7 |
4 files changed, 52 insertions, 3 deletions
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 708d8ab027d..cfd96ccfd68 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1638,4 +1638,6 @@ show open tables where f1()=0; show open tables where f1()=0; drop table t1; drop function f1; +select * from information_schema.tables where 1=sleep(100000); +select * from information_schema.columns where 1=sleep(100000); End of 5.1 tests. diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 6e76a043645..9f99f0fe32b 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1270,4 +1270,48 @@ show open tables where f1()=0; drop table t1; drop function f1; +# +# BUG#34656 - KILL a query = Assertion failed: m_status == DA_ERROR || +# m_status == DA_OK +# +connect (conn1, localhost, root,,); +connection conn1; +let $ID= `select connection_id()`; +send select * from information_schema.tables where 1=sleep(100000); +connection default; +let $wait_timeout= 10; +let $wait_condition=select count(*)=1 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.tables where 1=sleep(100000)'; +--source include/wait_condition.inc +disable_query_log; +eval kill $ID; +enable_query_log; +disconnect conn1; +let $wait_timeout= 10; +let $wait_condition=select count(*)=0 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.tables where 1=sleep(100000)'; +--source include/wait_condition.inc + +connect (conn1, localhost, root,,); +connection conn1; +let $ID= `select connection_id()`; +send select * from information_schema.columns where 1=sleep(100000); +connection default; +let $wait_timeout= 10; +let $wait_condition=select count(*)=1 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.columns where 1=sleep(100000)'; +--source include/wait_condition.inc +disable_query_log; +eval kill $ID; +enable_query_log; +disconnect conn1; +let $wait_timeout= 10; +let $wait_condition=select count(*)=0 from information_schema.processlist +where state='User sleep' and +info='select * from information_schema.columns where 1=sleep(100000)'; +--source include/wait_condition.inc + --echo End of 5.1 tests. diff --git a/sql/item_func.cc b/sql/item_func.cc index 65d3a627d2d..b61f683ae9f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3722,6 +3722,7 @@ longlong Item_func_sleep::val_int() pthread_cond_init(&cond, NULL); pthread_mutex_lock(&LOCK_user_locks); + thd_proc_info(thd, "User sleep"); thd->mysys_var->current_mutex= &LOCK_user_locks; thd->mysys_var->current_cond= &cond; @@ -3733,6 +3734,7 @@ longlong Item_func_sleep::val_int() break; error= 0; } + thd_proc_info(thd, 0); pthread_mutex_unlock(&LOCK_user_locks); pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6d817cb0620..a6516d5bf46 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3430,7 +3430,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, /* there was errors during opening tables */ - const char *error= thd->main_da.message(); + const char *error= thd->is_error() ? thd->main_da.message() : ""; if (tables->view) table->field[3]->store(STRING_WITH_LEN("VIEW"), cs); else if (tables->schema_table) @@ -3631,8 +3631,9 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, I.e. we are in SELECT FROM INFORMATION_SCHEMA.COLUMS rather than in SHOW COLUMNS */ - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - thd->main_da.sql_errno(), thd->main_da.message()); + if (thd->is_error()) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + thd->main_da.sql_errno(), thd->main_da.message()); thd->clear_error(); res= 0; } |