summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-02-01 13:43:19 +0100
committerSergei Golubchik <serg@mariadb.org>2015-02-02 20:57:46 +0100
commit80ce0c1c9c234dc53b963659690a1a8368b52124 (patch)
tree780f5ec1acf50505e6a115cf2005c710429d8d6f
parent06c16904459db6b46518e2f4ac6e21327d336cfd (diff)
downloadmariadb-git-80ce0c1c9c234dc53b963659690a1a8368b52124.tar.gz
cleanup: ha_checktype()
* error reporting was never needed * avoid useless transformaton hton to db_type to hton * in many cases the engine was guaranteed to exist, add asserts * use ha_default_handlerton() instead of ha_checktype(DB_TYPE_DEFAULT)
-rw-r--r--mysql-test/r/partition_not_blackhole.result2
-rw-r--r--mysql-test/t/partition_not_blackhole.test2
-rw-r--r--sql/handler.cc13
-rw-r--r--sql/handler.h8
-rw-r--r--sql/sql_table.cc11
-rw-r--r--sql/table.cc9
6 files changed, 18 insertions, 27 deletions
diff --git a/mysql-test/r/partition_not_blackhole.result b/mysql-test/r/partition_not_blackhole.result
index 923d70c0ad6..c5832d66da4 100644
--- a/mysql-test/r/partition_not_blackhole.result
+++ b/mysql-test/r/partition_not_blackhole.result
@@ -9,7 +9,7 @@ SHOW TABLES;
Tables_in_test
t1
SHOW CREATE TABLE t1;
-ERROR HY000: Incorrect information in file: './test/t1.frm'
+ERROR HY000: Failed to read from the .par file
DROP TABLE t1;
ERROR 42S02: Unknown table 'test.t1'
t1.frm
diff --git a/mysql-test/t/partition_not_blackhole.test b/mysql-test/t/partition_not_blackhole.test
index 7352aeaa230..103c441dac4 100644
--- a/mysql-test/t/partition_not_blackhole.test
+++ b/mysql-test/t/partition_not_blackhole.test
@@ -17,7 +17,7 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
--copy_file std_data/parts/t1_blackhole.par $MYSQLD_DATADIR/test/t1.par
SHOW TABLES;
--replace_result $MYSQLD_DATADIR ./
---error ER_NOT_FORM_FILE
+--error ER_FAILED_READ_FROM_PAR_FILE
SHOW CREATE TABLE t1;
--error ER_BAD_TABLE_ERROR
DROP TABLE t1;
diff --git a/sql/handler.cc b/sql/handler.cc
index 637f27c2ac1..a46174009fa 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -231,24 +231,13 @@ handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type)
/**
Use other database handler if databasehandler is not compiled in.
*/
-handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
- bool no_substitute, bool report_error)
+handlerton *ha_checktype(THD *thd, handlerton *hton, bool no_substitute)
{
- handlerton *hton= ha_resolve_by_legacy_type(thd, database_type);
if (ha_storage_engine_is_enabled(hton))
return hton;
if (no_substitute)
- {
- if (report_error)
- {
- const char *engine_name= ha_resolve_storage_engine_name(hton);
- my_error(ER_FEATURE_DISABLED,MYF(0),engine_name,engine_name);
- }
return NULL;
- }
-
- (void) RUN_HOOK(transaction, after_rollback, (thd, FALSE));
return ha_default_handlerton(thd);
} /* ha_checktype */
diff --git a/sql/handler.h b/sql/handler.h
index aff7bf42c27..5ef92088df5 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -4061,9 +4061,13 @@ plugin_ref ha_lock_engine(THD *thd, const handlerton *hton);
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
handlerton *db_type);
-handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
- bool no_substitute, bool report_error);
+handlerton *ha_checktype(THD *thd, handlerton *hton, bool no_substitute);
+static inline handlerton *ha_checktype(THD *thd, enum legacy_db_type type,
+ bool no_substitute = 0)
+{
+ return ha_checktype(thd, ha_resolve_by_legacy_type(thd, type), no_substitute);
+}
static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type)
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index e61d108731e..ef6252c496b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4452,8 +4452,7 @@ handler *mysql_create_frm_image(THD *thd,
{
if (part_info->default_engine_type == NULL)
{
- part_info->default_engine_type= ha_checktype(thd,
- DB_TYPE_DEFAULT, 0, 0);
+ part_info->default_engine_type= ha_default_handlerton(thd);
}
}
}
@@ -9748,10 +9747,10 @@ static bool check_engine(THD *thd, const char *db_name,
DBUG_ENTER("check_engine");
handlerton **new_engine= &create_info->db_type;
handlerton *req_engine= *new_engine;
- bool no_substitution=
- MY_TEST(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION);
- if (!(*new_engine= ha_checktype(thd, ha_legacy_type(req_engine),
- no_substitution, 1)))
+ bool no_substitution= thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION;
+ *new_engine= ha_checktype(thd, req_engine, no_substitution);
+ DBUG_ASSERT(*new_engine);
+ if (!*new_engine)
DBUG_RETURN(true);
if (req_engine && req_engine != *new_engine)
diff --git a/sql/table.cc b/sql/table.cc
index 14f61837489..9b6b64b93df 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1047,8 +1047,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (frm_image[61] && !share->default_part_plugin)
{
enum legacy_db_type db_type= (enum legacy_db_type) (uint) frm_image[61];
- share->default_part_plugin=
- ha_lock_engine(NULL, ha_checktype(thd, db_type, 1, 0));
+ share->default_part_plugin= ha_lock_engine(NULL, ha_checktype(thd, db_type));
if (!share->default_part_plugin)
goto err;
}
@@ -1060,7 +1059,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
*/
if (legacy_db_type > DB_TYPE_UNKNOWN &&
legacy_db_type < DB_TYPE_FIRST_DYNAMIC)
- se_plugin= ha_lock_engine(NULL, ha_checktype(thd, legacy_db_type, 0, 0));
+ se_plugin= ha_lock_engine(NULL, ha_checktype(thd, legacy_db_type));
share->db_create_options= db_create_options= uint2korr(frm_image+30);
share->db_options_in_use= share->db_create_options;
share->mysql_version= uint4korr(frm_image+51);
@@ -3305,8 +3304,8 @@ void prepare_frm_header(THD *thd, uint reclength, uchar *fileinfo,
fileinfo[1]= 1;
fileinfo[2]= FRM_VER + 3 + MY_TEST(create_info->varchar);
- fileinfo[3]= (uchar) ha_legacy_type(
- ha_checktype(thd,ha_legacy_type(create_info->db_type),0,0));
+ DBUG_ASSERT(ha_storage_engine_is_enabled(create_info->db_type));
+ fileinfo[3]= (uchar) ha_legacy_type(create_info->db_type);
/*
Keep in sync with pack_keys() in unireg.cc