diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2010-08-18 13:29:04 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2010-08-18 13:29:04 +0200 |
commit | eb498cce4dafc2eda285c71ed96d64e451f02ec2 (patch) | |
tree | b38d061771d52ab55fe9d428e45627d4c08d5f63 /sql/datadict.cc | |
parent | 6293c44ff6debb4f617260df727b281e77a41b5c (diff) | |
parent | e28d6ee66a8404dd0f8fe3aaabb9d72544e5d42e (diff) | |
download | mariadb-git-eb498cce4dafc2eda285c71ed96d64e451f02ec2.tar.gz |
Manual merge from mysql-5.5-bugfixing to mysql-5.5-runtime.
Diffstat (limited to 'sql/datadict.cc')
-rw-r--r-- | sql/datadict.cc | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/sql/datadict.cc b/sql/datadict.cc index 7eea977fd5d..e3f679cc7ec 100644 --- a/sql/datadict.cc +++ b/sql/datadict.cc @@ -22,7 +22,9 @@ /** Check type of .frm if we are not going to parse it. - @param path path to FRM file + @param[in] thd The current session. + @param[in] path path to FRM file. + @param[out] dbt db_type of the table if FRMTYPE_TABLE, otherwise undefined. @retval FRMTYPE_ERROR error @retval FRMTYPE_TABLE table @@ -66,29 +68,28 @@ frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt) /** - Given a table name, check if the storage engine for the - table referred by this name supports an option 'flag'. - Return an error if the table does not exist or is not a - base table. + Given a table name, check type of .frm and legacy table type. - @pre Any metadata lock on the table. + @param[in] thd The current session. + @param[in] db Table schema. + @param[in] table_name Table database. + @param[out] table_type handlerton of the table if FRMTYPE_TABLE, + otherwise undefined. - @param[in] thd The current session. - @param[in] db Table schema. - @param[in] table_name Table database. - @param[in] flag The option to check. - @param[out] yes_no The result. Undefined if error. + @return FALSE if FRMTYPE_TABLE and storage engine found. TRUE otherwise. */ -bool dd_check_storage_engine_flag(THD *thd, - const char *db, const char *table_name, - uint32 flag, bool *yes_no) +bool dd_frm_storage_engine(THD *thd, const char *db, const char *table_name, + handlerton **table_type) { char path[FN_REFLEN + 1]; enum legacy_db_type db_type; - handlerton *table_type; LEX_STRING db_name = {(char *) db, strlen(db)}; + /* There should be at least some lock on the table. */ + DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, + table_name, MDL_SHARED)); + if (check_db_name(&db_name)) { my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str); @@ -101,23 +102,47 @@ bool dd_check_storage_engine_flag(THD *thd, return TRUE; } - /* There should be at least some lock on the table. */ - DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, - table_name, MDL_SHARED)); - (void) build_table_filename(path, sizeof(path) - 1, db, table_name, reg_ext, 0); dd_frm_type(thd, path, &db_type); /* Type is unknown if the object is not found or is not a table. */ - if (db_type == DB_TYPE_UNKNOWN) + if (db_type == DB_TYPE_UNKNOWN || + !(*table_type= ha_resolve_by_legacy_type(thd, db_type))) { my_error(ER_NO_SUCH_TABLE, MYF(0), db, table_name); return TRUE; } - table_type= ha_resolve_by_legacy_type(thd, db_type); + return FALSE; +} + + +/** + Given a table name, check if the storage engine for the + table referred by this name supports an option 'flag'. + Return an error if the table does not exist or is not a + base table. + + @pre Any metadata lock on the table. + + @param[in] thd The current session. + @param[in] db Table schema. + @param[in] table_name Table database. + @param[in] flag The option to check. + @param[out] yes_no The result. Undefined if error. +*/ + +bool dd_check_storage_engine_flag(THD *thd, + const char *db, const char *table_name, + uint32 flag, bool *yes_no) +{ + handlerton *table_type; + + if (dd_frm_storage_engine(thd, db, table_name, &table_type)) + return TRUE; + *yes_no= ha_check_storage_engine_flag(table_type, flag); return FALSE; |