cleanup: unused function argument

This commit is contained in:
Sergei Golubchik 2024-01-26 12:19:47 +01:00
parent aa09cb3b11
commit 07ec1a9e37
11 changed files with 12 additions and 96 deletions

View File

@ -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, Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
LEX_CSTRING *partition_engine_name,
LEX_CUSTRING *table_version) LEX_CUSTRING *table_version)
{ {
File file; File file;
@ -86,11 +85,6 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
engine_name->length= 0; engine_name->length= 0;
((char*) (engine_name->str))[0]= 0; ((char*) (engine_name->str))[0]= 0;
} }
if (partition_engine_name)
{
partition_engine_name->length= 0;
partition_engine_name->str= 0;
}
if (table_version) if (table_version)
{ {
table_version->length= 0; table_version->length= 0;
@ -133,25 +127,10 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
{ {
if (engine_name) if (engine_name)
*engine_name= hton2plugin[ht->slot]->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; goto err;
} }
} }
#ifdef WITH_PARTITION_STORAGE_ENGINE
cont:
#endif
/* read the true engine name */ /* read the true engine name */
if (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); my_free(frm_image);
} }

View File

@ -39,12 +39,11 @@ enum Table_type
*/ */
enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name, enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
LEX_CSTRING *partition_engine_name,
LEX_CUSTRING *table_version); LEX_CUSTRING *table_version);
static inline bool dd_frm_is_view(THD *thd, char *path) 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); bool dd_recreate_table(THD *thd, const char *db, const char *table_name);

View File

@ -6660,7 +6660,6 @@ static my_bool discover_existence(THD *thd, plugin_ref plugin,
bool ha_table_exists(THD *thd, const LEX_CSTRING *db, bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
const LEX_CSTRING *table_name, LEX_CUSTRING *table_id, const LEX_CSTRING *table_name, LEX_CUSTRING *table_id,
LEX_CSTRING *partition_engine_name,
handlerton **hton, bool *is_sequence) handlerton **hton, bool *is_sequence)
{ {
handlerton *dummy; handlerton *dummy;
@ -6686,21 +6685,6 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
if (!hton) if (!hton)
hton= &dummy; hton= &dummy;
*hton= element->share->db_type(); *hton= element->share->db_type();
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (partition_engine_name && element->share->db_type() == partition_hton)
{
if (!static_cast<Partition_share *>(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<Partition_share *>(element->share->ha_share)->
partition_engine_name);
}
#endif
*is_sequence= element->share->table_type == TABLE_TYPE_SEQUENCE; *is_sequence= element->share->table_type == TABLE_TYPE_SEQUENCE;
if (*hton != view_pseudo_hton && element->share->tabledef_version.length && if (*hton != view_pseudo_hton && element->share->tabledef_version.length &&
table_id && table_id &&
@ -6711,9 +6695,6 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
#ifdef WITH_PARTITION_STORAGE_ENGINE
retry_from_frm:
#endif
char path[FN_REFLEN + 1]; char path[FN_REFLEN + 1];
size_t path_len = build_table_filename(path, sizeof(path) - 1, size_t path_len = build_table_filename(path, sizeof(path) - 1,
db->str, table_name->str, "", 0); db->str, table_name->str, "", 0);
@ -6726,9 +6707,7 @@ retry_from_frm:
{ {
char engine_buf[NAME_CHAR_LEN + 1]; char engine_buf[NAME_CHAR_LEN + 1];
LEX_CSTRING engine= { engine_buf, 0 }; LEX_CSTRING engine= { engine_buf, 0 };
Table_type type= dd_frm_type(thd, path, &engine, Table_type type= dd_frm_type(thd, path, &engine, table_id);
partition_engine_name,
table_id);
switch (type) { switch (type) {
case TABLE_TYPE_UNKNOWN: case TABLE_TYPE_UNKNOWN:

View File

@ -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, bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
const LEX_CSTRING *table_name, const LEX_CSTRING *table_name,
LEX_CUSTRING *table_version= 0, LEX_CUSTRING *table_version= 0,
LEX_CSTRING *partition_engine_name= 0,
handlerton **hton= 0, bool *is_sequence= 0); handlerton **hton= 0, bool *is_sequence= 0);
bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton, bool ha_check_if_updates_are_ignored(THD *thd, handlerton *hton,
const char *op); const char *op);

View File

@ -4292,7 +4292,7 @@ static bool upgrade_lock_if_not_exists(THD *thd,
DEBUG_SYNC(thd,"create_table_before_check_if_exists"); DEBUG_SYNC(thd,"create_table_before_check_if_exists");
if (!create_info.or_replace() && if (!create_info.or_replace() &&
ha_table_exists(thd, &create_table->db, &create_table->table_name, 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()) if (create_info.if_not_exists())
{ {

View File

@ -1715,8 +1715,7 @@ int plugin_init(int *argc, char **argv, int flags)
{ {
char path[FN_REFLEN + 1]; char path[FN_REFLEN + 1];
build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0); build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0);
Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name, Table_type ttype= dd_frm_type(0, path, &plugin_table_engine_name, NULL);
NULL, NULL);
if (ttype != TABLE_TYPE_NORMAL) if (ttype != TABLE_TYPE_NORMAL)
plugin_table_engine_name=empty_clex_str; plugin_table_engine_name=empty_clex_str;
} }

View File

@ -283,8 +283,7 @@ check_rename(THD *thd, rename_param *param,
DBUG_ASSERT(param->new_alias.str); DBUG_ASSERT(param->new_alias.str);
if (!ha_table_exists(thd, &ren_table->db, &param->old_alias, if (!ha_table_exists(thd, &ren_table->db, &param->old_alias,
&param->old_version, NULL, &param->old_version, &param->from_table_hton) ||
&param->from_table_hton) ||
!param->from_table_hton) !param->from_table_hton)
{ {
my_error(ER_NO_SUCH_TABLE, MYF(if_exists ? ME_NOTE : 0), 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); DBUG_RETURN(-1);
} }
if (ha_table_exists(thd, &new_db, &param->new_alias, NULL, NULL, 0)) if (ha_table_exists(thd, &new_db, &param->new_alias))
{ {
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str); my_error(ER_TABLE_EXISTS_ERROR, MYF(0), param->new_alias.str);
DBUG_RETURN(1); // This can't be skipped DBUG_RETURN(1); // This can't be skipped

View File

@ -4735,7 +4735,7 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
char path[FN_REFLEN]; char path[FN_REFLEN];
build_table_filename(path, sizeof(path) - 1, build_table_filename(path, sizeof(path) - 1,
db->str, table->str, reg_ext, 0); 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; tl->option= engine_name.str;
} }
} }
@ -4974,8 +4974,7 @@ static int fill_schema_table_names(THD *thd, TABLE_LIST *tables,
handlerton *hton; handlerton *hton;
bool is_sequence; bool is_sequence;
if (ha_table_exists(thd, db_name, table_name, NULL, NULL, if (ha_table_exists(thd, db_name, table_name, NULL, &hton, &is_sequence))
&hton, &is_sequence))
{ {
if (hton == view_pseudo_hton) if (hton == view_pseudo_hton)
table->field[3]->store(STRING_WITH_LEN("VIEW"), cs); table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);

View File

@ -1564,7 +1564,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
*/ */
char engine_buf[NAME_CHAR_LEN + 1]; char engine_buf[NAME_CHAR_LEN + 1];
LEX_CSTRING engine= { engine_buf, 0 }; 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) if (table_type == TABLE_TYPE_NORMAL || table_type == TABLE_TYPE_SEQUENCE)
{ {
plugin_ref p= plugin_lock_by_name(thd, &engine, plugin_ref p= plugin_lock_by_name(thd, &engine,
@ -4476,7 +4476,7 @@ int create_table_impl(THD *thd,
handlerton *db_type; handlerton *db_type;
if (!internal_tmp_table && if (!internal_tmp_table &&
ha_table_exists(thd, &db, &table_name, 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")) if (ha_check_if_updates_are_ignored(thd, db_type, "CREATE"))
{ {

View File

@ -574,7 +574,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
DBUG_ASSERT(tables->next_global == 0); DBUG_ASSERT(tables->next_global == 0);
build_table_filename(path, sizeof(path) - 1, tables->db.str, tables->alias.str, ".frm", 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. */ /* We do not allow creation of triggers on temporary tables or sequence. */
if (tables->required_type == TABLE_TYPE_SEQUENCE || if (tables->required_type == TABLE_TYPE_SEQUENCE ||

View File

@ -3801,7 +3801,7 @@ bool Rdb_validate_tbls::check_frm_file(const std::string &fullpath,
char eng_type_buf[NAME_CHAR_LEN+1]; char eng_type_buf[NAME_CHAR_LEN+1];
LEX_CSTRING eng_type_str = {eng_type_buf, 0}; LEX_CSTRING eng_type_str = {eng_type_buf, 0};
enum Table_type type = dd_frm_type(nullptr, fullfilename.c_ptr(), 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) { if (type == TABLE_TYPE_UNKNOWN) {
// NO_LINT_DEBUG // NO_LINT_DEBUG
sql_print_warning("RocksDB: Failed to open/read .from file: %s", sql_print_warning("RocksDB: Failed to open/read .from file: %s",