From 63a69ab9363a749dbbfeef23b911b195885364b2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 21 Apr 2025 15:03:01 +0200 Subject: [PATCH] cleanup: remote automatic conversion char* -> Lex_ident considered harmful, see e.g. changes in check_period_fields() --- sql/handler.cc | 20 +++++--------------- sql/handler.h | 2 -- sql/lex_string.h | 2 +- sql/sql_table.cc | 6 +++--- sql/table.h | 4 ++-- sql/vers_string.h | 2 +- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 923696fe99d..85358db6f15 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -8253,16 +8253,6 @@ int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info) VERSIONING functions ******************************************************************************/ -bool Vers_parse_info::is_start(const char *name) const -{ - DBUG_ASSERT(name); - return as_row.start && as_row.start.streq(name); -} -bool Vers_parse_info::is_end(const char *name) const -{ - DBUG_ASSERT(name); - return as_row.end && as_row.end.streq(name); -} bool Vers_parse_info::is_start(const Create_field &f) const { return f.flags & VERS_ROW_START; @@ -8317,8 +8307,8 @@ bool Vers_parse_info::create_sys_field(THD *thd, const char *field_name, return false; } -const Lex_ident Vers_parse_info::default_start= "row_start"; -const Lex_ident Vers_parse_info::default_end= "row_end"; +const Lex_ident Vers_parse_info::default_start= { STRING_WITH_LEN("row_start")}; +const Lex_ident Vers_parse_info::default_end= { STRING_WITH_LEN("row_end")}; bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info) { @@ -8577,7 +8567,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) { - if (check_sys_fields(table_name, share->db, alter_info)) + if (check_sys_fields(share->table_name, share->db, alter_info)) return true; } @@ -8883,8 +8873,8 @@ bool Table_scope_and_contents_source_st::check_period_fields( } } - bool res= period_info.check_field(row_start, period.start.str) - || period_info.check_field(row_end, period.end.str); + bool res= period_info.check_field(row_start, period.start) + || period_info.check_field(row_end, period.end); if (res) return true; diff --git a/sql/handler.h b/sql/handler.h index 617050b9a6f..51c4de0003a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2117,8 +2117,6 @@ struct Vers_parse_info: public Table_period_info } protected: - bool is_start(const char *name) const; - bool is_end(const char *name) const; bool is_start(const Create_field &f) const; bool is_end(const Create_field &f) const; bool fix_implicit(THD *thd, Alter_info *alter_info); diff --git a/sql/lex_string.h b/sql/lex_string.h index 56f37706aa8..5e048b18873 100644 --- a/sql/lex_string.h +++ b/sql/lex_string.h @@ -110,7 +110,7 @@ class Lex_cstring : public LEX_CSTRING class Lex_cstring_strlen: public Lex_cstring { public: - Lex_cstring_strlen(const char *from) + explicit Lex_cstring_strlen(const char *from) :Lex_cstring(from, from ? strlen(from) : 0) { } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 89095125fe3..06501449ab7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6235,7 +6235,7 @@ drop_create_field: } else if (drop->type == Alter_drop::PERIOD) { - if (table->s->period.name.streq(drop->name)) + if (table->s->period.name.streq(Lex_ident(drop->name))) remove_drop= FALSE; } else /* Alter_drop::KEY and Alter_drop::FOREIGN_KEY */ @@ -9227,7 +9227,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, for (bool found= false; !found && (drop= drop_it++); ) { found= drop->type == Alter_drop::PERIOD && - table->s->period.name.streq(drop->name); + table->s->period.name.streq(Lex_ident(drop->name)); } if (drop) @@ -9270,7 +9270,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } } - if (share->period.constr_name.streq(check->name.str)) + if (share->period.constr_name.streq(check->name)) { if (!drop_period && !keep) { diff --git a/sql/table.h b/sql/table.h index 1aedaec8b52..137cb537587 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2192,7 +2192,7 @@ struct vers_select_conds_t void init(vers_system_time_t _type, Vers_history_point _start= Vers_history_point(), Vers_history_point _end= Vers_history_point(), - Lex_ident _name= "SYSTEM_TIME") + Lex_ident _name= { STRING_WITH_LEN("SYSTEM_TIME") }) { type= _type; orig_type= _type; @@ -2207,7 +2207,7 @@ struct vers_select_conds_t void set_all() { type= SYSTEM_TIME_ALL; - name= "SYSTEM_TIME"; + name= { STRING_WITH_LEN("SYSTEM_TIME") }; } void print(String *str, enum_query_type query_type) const; diff --git a/sql/vers_string.h b/sql/vers_string.h index c5be9c359e3..9c1730fad81 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -62,7 +62,7 @@ public: { } Lex_cstring_with_compare(const LEX_CSTRING src) : Lex_cstring(src.str, src.length) { } - Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str)) + explicit Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str)) { } bool streq(const Lex_cstring_with_compare& b) const {