From 5828d9630b7b1fd5838b5918857e0b693e1ec938 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 24 Jun 2009 19:24:13 +0200 Subject: [PATCH] Backport into build-200906240007-5.1.34sp1 > ------------------------------------------------------------ > revno: 2857.1.8 > revision-id: sergey.glukhov@sun.com-20090417084627-yvt63k51vvvjbx9j > parent: anurag.shekhar@sun.com-20090417055354-7vw80v1rwn0z1tt4 > parent: sergey.glukhov@sun.com-20090417074115-dv9h5ijalj2hgq3r > committer: Sergey Glukhov > branch nick: mysql-5.1-bugteam > timestamp: Fri 2009-04-17 13:46:27 +0500 > message: > 5.0-bugteam->5.1-bugteam merge > ------------------------------------------------------------ > revno: 1810.3882.12 > revision-id: sergey.glukhov@sun.com-20090417074115-dv9h5ijalj2hgq3r > parent: patrick.crews@sun.com-20090416174744-u9fxu6ophud91a1h > committer: Sergey Glukhov > branch nick: mysql-5.0-bugteam > timestamp: Fri 2009-04-17 12:41:15 +0500 > message: > Bug#44151 using handler commands on information_schema tables crashes server > information schema tables are based on internal tmp tables which are removed > after each statement execution. So HANDLER comands can not be used with > information schema. --- mysql-test/include/handler.inc | 8 ++++++++ mysql-test/r/handler_innodb.result | 4 ++++ mysql-test/r/handler_myisam.result | 4 ++++ sql/sql_handler.cc | 8 ++++++++ 4 files changed, 24 insertions(+) diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 4eb9e413822..96f90aba8e0 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -720,3 +720,11 @@ connection con1; drop table t1; disconnect con1; connection default; + +# +# Bug#44151 using handler commands on information_schema tables crashes server +# +USE information_schema; +--error ER_WRONG_USAGE +HANDLER COLUMNS OPEN; +USE test; diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index 59a46cabe5f..957fc30acef 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -739,3 +739,7 @@ handler t1 read a next; ERROR HY000: Table storage engine for 't1' doesn't have this option handler t1 close; drop table t1; +USE information_schema; +HANDLER COLUMNS OPEN; +ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema +USE test; diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result index afbf2d9fb6d..dde6a4586bc 100644 --- a/mysql-test/r/handler_myisam.result +++ b/mysql-test/r/handler_myisam.result @@ -737,3 +737,7 @@ handler t1 read a next; ERROR HY000: Table storage engine for 't1' doesn't have this option handler t1 close; drop table t1; +USE information_schema; +HANDLER COLUMNS OPEN; +ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema +USE test; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 9c8bba6208c..16810e29343 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -199,6 +199,14 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) tables->db, tables->table_name, tables->alias, (int) reopen)); + if (tables->schema_table) + { + my_error(ER_WRONG_USAGE, MYF(0), "HANDLER OPEN", + INFORMATION_SCHEMA_NAME.str); + DBUG_PRINT("exit",("ERROR")); + DBUG_RETURN(TRUE); + } + if (! hash_inited(&thd->handler_tables_hash)) { /*