diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-09 15:50:30 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-09 15:50:30 +0200 |
commit | cdc01e29d3a9f6d98aaa482363af81003485e256 (patch) | |
tree | 20c8ce171e2666e720ac5977561997038fe3c2f2 /sql/sql_truncate.cc | |
parent | 15c936e4b3d151346c027bd4b51b44c826b095b6 (diff) | |
download | mariadb-git-cdc01e29d3a9f6d98aaa482363af81003485e256.tar.gz |
remove dd_frm_type(), dd_frm_storage_engine(), dd_check_storage_engine_flag()
from everywhere - now RENAME, SHOW FULL TABLES, and TRUNCATE work with discovery.
improve error messages in truncate
Diffstat (limited to 'sql/sql_truncate.cc')
-rw-r--r-- | sql/sql_truncate.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 0e97de5a6aa..92c4d150433 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -341,9 +341,27 @@ bool Truncate_statement::lock_table(THD *thd, TABLE_LIST *table_ref, MYSQL_OPEN_SKIP_TEMPORARY)) DBUG_RETURN(TRUE); - if (dd_check_storage_engine_flag(thd, table_ref->db, table_ref->table_name, - HTON_CAN_RECREATE, hton_can_recreate)) + handlerton *hton; + if (!ha_table_exists(thd, table_ref->db, table_ref->table_name, &hton) || + hton == view_pseudo_hton) + { + my_error(ER_NO_SUCH_TABLE, MYF(0), table_ref->db, table_ref->table_name); DBUG_RETURN(TRUE); + } + + if (!hton) + { + /* + The table exists, but its storage engine is unknown, perhaps not + loaded at the moment. We need to open and parse the frm to know the + storage engine in question, so let's proceed with the truncation and + try to open the table. This will produce the correct error message + about unknown engine. + */ + *hton_can_recreate= false; + } + else + *hton_can_recreate= hton->flags & HTON_CAN_RECREATE; } /* |