From 07ec1a9e3773c3f55ca0cb16c5c669b0d5d57735 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 26 Jan 2024 12:19:47 +0100 Subject: [PATCH] cleanup: unused function argument --- sql/datadict.cc | 58 ---------------------------------- sql/datadict.h | 3 +- sql/handler.cc | 23 +------------- sql/handler.h | 1 - sql/sql_base.cc | 2 +- sql/sql_plugin.cc | 3 +- sql/sql_rename.cc | 5 ++- sql/sql_show.cc | 5 ++- sql/sql_table.cc | 4 +-- sql/sql_trigger.cc | 2 +- storage/rocksdb/rdb_datadic.cc | 2 +- 11 files changed, 12 insertions(+), 96 deletions(-) diff --git a/sql/datadict.cc b/sql/datadict.cc index e85478a710c..c8e45154629 100644 --- a/sql/datadict.cc +++ b/sql/datadict.cc @@ -57,7 +57,6 @@ static int read_string(File file, uchar**to, size_t length) */ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name, - LEX_CSTRING *partition_engine_name, LEX_CUSTRING *table_version) { File file; @@ -86,11 +85,6 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name, engine_name->length= 0; ((char*) (engine_name->str))[0]= 0; } - if (partition_engine_name) - { - partition_engine_name->length= 0; - partition_engine_name->str= 0; - } if (table_version) { table_version->length= 0; @@ -133,25 +127,10 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name, { if (engine_name) *engine_name= hton2plugin[ht->slot]->name; -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (partition_engine_name && dbt == DB_TYPE_PARTITION_DB) - { - handlerton *p_ht; - legacy_db_type new_dbt= (legacy_db_type) header[61]; - if (new_dbt >= DB_TYPE_FIRST_DYNAMIC) - goto cont; - if (!(p_ht= ha_resolve_by_legacy_type(thd, new_dbt))) - goto err; - *partition_engine_name= *hton_name(p_ht); - } -#endif // WITH_PARTITION_STORAGE_ENGINE goto err; } } -#ifdef WITH_PARTITION_STORAGE_ENGINE -cont: -#endif /* read the true engine name */ if (engine_name) { @@ -197,43 +176,6 @@ cont: } } -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (partition_engine_name && dbt == DB_TYPE_PARTITION_DB) - { - uint len; - const uchar *extra2; - /* Length of the MariaDB extra2 segment in the form file. */ - len = uint2korr(frm_image+4); - extra2= frm_image + 64; - if (*extra2 != '/') // old frm had '/' there - { - const uchar *e2end= extra2 + len; - while (extra2 + 3 <= e2end) - { - uchar type= *extra2++; - size_t length= *extra2++; - if (!length) - { - if (extra2 + 2 >= e2end) - break; - length= uint2korr(extra2); - extra2+= 2; - if (length < 256) - break; - } - if (extra2 + length > e2end) - break; - if (type == EXTRA2_DEFAULT_PART_ENGINE) - { - partition_engine_name->str= thd->strmake((char*)extra2, length); - partition_engine_name->length= length; - break; - } - extra2+= length; - } - } - } -#endif // WITH_PARTITION_STORAGE_ENGINE my_free(frm_image); } diff --git a/sql/datadict.h b/sql/datadict.h index bec093aa141..a9007a4a4fb 100644 --- a/sql/datadict.h +++ b/sql/datadict.h @@ -39,12 +39,11 @@ enum Table_type */ enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name, - LEX_CSTRING *partition_engine_name, LEX_CUSTRING *table_version); static inline bool dd_frm_is_view(THD *thd, char *path) { - return dd_frm_type(thd, path, NULL, NULL, NULL) == TABLE_TYPE_VIEW; + return dd_frm_type(thd, path, NULL, NULL) == TABLE_TYPE_VIEW; } bool dd_recreate_table(THD *thd, const char *db, const char *table_name); diff --git a/sql/handler.cc b/sql/handler.cc index 328eafeb253..5a577f93792 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6660,7 +6660,6 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin, bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, LEX_CUSTRING *table_id, - LEX_CSTRING *partition_engine_name, handlerton **hton, bool *is_sequence) { handlerton *dummy; @@ -6686,21 +6685,6 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db, if (!hton) hton= &dummy; *hton= element->share->db_type(); -#ifdef WITH_PARTITION_STORAGE_ENGINE - if (partition_engine_name && element->share->db_type() == partition_hton) - { - if (!static_cast(element->share->ha_share)-> - partition_engine_name) - { - /* Partition engine found, but table has never been opened */ - tdc_unlock_share(element); - goto retry_from_frm; - } - lex_string_set(partition_engine_name, - static_cast(element->share->ha_share)-> - partition_engine_name); - } -#endif *is_sequence= element->share->table_type == TABLE_TYPE_SEQUENCE; if (*hton != view_pseudo_hton && element->share->tabledef_version.length && table_id && @@ -6711,9 +6695,6 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db, DBUG_RETURN(TRUE); } -#ifdef WITH_PARTITION_STORAGE_ENGINE -retry_from_frm: -#endif char path[FN_REFLEN + 1]; size_t path_len = build_table_filename(path, sizeof(path) - 1, db->str, table_name->str, "", 0); @@ -6726,9 +6707,7 @@ retry_from_frm: { char engine_buf[NAME_CHAR_LEN + 1]; LEX_CSTRING engine= { engine_buf, 0 }; - Table_type type= dd_frm_type(thd, path, &engine, - partition_engine_name, - table_id); + Table_type type= dd_frm_type(thd, path, &engine, table_id); switch (type) { case TABLE_TYPE_UNKNOWN: diff --git a/sql/handler.h b/sql/handler.h index fc21cf8cd97..efb900ce8bf 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -5694,7 +5694,6 @@ int ha_discover_table_names(THD *thd, const LEX_CSTRING *db, MY_DIR *dirp, bool ha_table_exists(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table_name, LEX_CUSTRING *table_version= 0, - LEX_CSTRING *partition_engine_name= 0, handlerton **hton= 0, bool *is_sequence= 0); bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton, const char *op); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f58ed2f7c8e..b5e1a1d5236 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4292,7 +4292,7 @@ static bool upgrade_lock_if_not_exists(THD *thd, DEBUG_SYNC(thd,"create_table_before_check_if_exists"); if (!create_info.or_replace() && ha_table_exists(thd, &create_table->db, &create_table->table_name, - NULL, NULL, &create_table->db_type)) + NULL, &create_table->db_type)) { if (create_info.if_not_exists()) { diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 6f3046f3441..82bb01e18d0 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1715,8 +1715,7 @@ int plugin_init(int *argc, char **argv, int flags) { char path[FN_REFLEN + 1]; build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0); - Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name, - NULL, NULL); + Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name, NULL); if (ttype != TABLE_TYPE_NORMAL) plugin_table_engine_name=empty_clex_str; } diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 98246545bed..1c0641516c1 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -283,8 +283,7 @@ check_rename(THD *thd, rename_param *param, DBUG_ASSERT(param->new_alias.str); if (!ha_table_exists(thd, &ren_table->db, ¶m->old_alias, - ¶m->old_version, NULL, - ¶m->from_table_hton) || + ¶m->old_version, ¶m->from_table_hton) || !param->from_table_hton) { my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0), @@ -304,7 +303,7 @@ check_rename(THD *thd, rename_param *param, DBUG_RETURN(-1); } - if (ha_table_exists(thd, &new_db, ¶m->new_alias, NULL, NULL, 0)) + if (ha_table_exists(thd, &new_db, ¶m->new_alias)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str); DBUG_RETURN(1); // This can't be skipped diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 84d8add3492..64bc41a3eb2 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4735,7 +4735,7 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl, char path[FN_REFLEN]; build_table_filename(path, sizeof(path) - 1, db->str, table->str, reg_ext, 0); - if (dd_frm_type(thd, path, &engine_name, NULL, NULL) == TABLE_TYPE_NORMAL) + if (dd_frm_type(thd, path, &engine_name, NULL) == TABLE_TYPE_NORMAL) tl->option= engine_name.str; } } @@ -4974,8 +4974,7 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables, handlerton *hton; bool is_sequence; - if (ha_table_exists(thd, db_name, table_name, NULL, NULL, - &hton, &is_sequence)) + if (ha_table_exists(thd, db_name, table_name, NULL, &hton, &is_sequence)) { if (hton == view_pseudo_hton) table->field[3]->store(STRING_WITH_LEN("VIEW"), cs); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 877bd24c912..6e87d529c83 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1564,7 +1564,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, */ char engine_buf[NAME_CHAR_LEN + 1]; LEX_CSTRING engine= { engine_buf, 0 }; - table_type= dd_frm_type(thd, path, &engine, NULL, &version); + table_type= dd_frm_type(thd, path, &engine, &version); if (table_type == TABLE_TYPE_NORMAL || table_type == TABLE_TYPE_SEQUENCE) { plugin_ref p= plugin_lock_by_name(thd, &engine, @@ -4476,7 +4476,7 @@ int create_table_impl(THD *thd, handlerton *db_type; if (!internal_tmp_table && ha_table_exists(thd, &db, &table_name, - &create_info->org_tabledef_version, NULL, &db_type)) + &create_info->org_tabledef_version, &db_type)) { if (ha_check_if_updates_are_ignored(thd, db_type, "CREATE")) { diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index f0a8e876e79..6c1a41f994f 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -574,7 +574,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_ASSERT(tables->next_global == 0); build_table_filename(path, sizeof(path) - 1, tables->db.str, tables->alias.str, ".frm", 0); - tables->required_type= dd_frm_type(NULL, path, NULL, NULL, NULL); + tables->required_type= dd_frm_type(NULL, path, NULL, NULL); /* We do not allow creation of triggers on temporary tables or sequence. */ if (tables->required_type == TABLE_TYPE_SEQUENCE || diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index e73d586f5d2..895f51811a6 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -3801,7 +3801,7 @@ bool Rdb_validate_tbls::check_frm_file(const std::string &fullpath, char eng_type_buf[NAME_CHAR_LEN+1]; LEX_CSTRING eng_type_str = {eng_type_buf, 0}; enum Table_type type = dd_frm_type(nullptr, fullfilename.c_ptr(), - &eng_type_str, nullptr, nullptr); + &eng_type_str, nullptr); if (type == TABLE_TYPE_UNKNOWN) { // NO_LINT_DEBUG sql_print_warning("RocksDB: Failed to open/read .from file: %s",