Skip to content

Commit 63a69ab

Browse files
committed
cleanup: remote automatic conversion char* -> Lex_ident
considered harmful, see e.g. changes in check_period_fields()
1 parent 588f7a5 commit 63a69ab

File tree

6 files changed

+12
-24
lines changed

6 files changed

+12
-24
lines changed

sql/handler.cc

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8253,16 +8253,6 @@ int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info)
82538253
VERSIONING functions
82548254
******************************************************************************/
82558255

8256-
bool Vers_parse_info::is_start(const char *name) const
8257-
{
8258-
DBUG_ASSERT(name);
8259-
return as_row.start && as_row.start.streq(name);
8260-
}
8261-
bool Vers_parse_info::is_end(const char *name) const
8262-
{
8263-
DBUG_ASSERT(name);
8264-
return as_row.end && as_row.end.streq(name);
8265-
}
82668256
bool Vers_parse_info::is_start(const Create_field &f) const
82678257
{
82688258
return f.flags & VERS_ROW_START;
@@ -8317,8 +8307,8 @@ bool Vers_parse_info::create_sys_field(THD *thd, const char *field_name,
83178307
return false;
83188308
}
83198309

8320-
const Lex_ident Vers_parse_info::default_start= "row_start";
8321-
const Lex_ident Vers_parse_info::default_end= "row_end";
8310+
const Lex_ident Vers_parse_info::default_start= { STRING_WITH_LEN("row_start")};
8311+
const Lex_ident Vers_parse_info::default_end= { STRING_WITH_LEN("row_end")};
83228312

83238313
bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info)
83248314
{
@@ -8577,7 +8567,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
85778567

85788568
if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)
85798569
{
8580-
if (check_sys_fields(table_name, share->db, alter_info))
8570+
if (check_sys_fields(share->table_name, share->db, alter_info))
85818571
return true;
85828572
}
85838573

@@ -8883,8 +8873,8 @@ bool Table_scope_and_contents_source_st::check_period_fields(
88838873
}
88848874
}
88858875

8886-
bool res= period_info.check_field(row_start, period.start.str)
8887-
|| period_info.check_field(row_end, period.end.str);
8876+
bool res= period_info.check_field(row_start, period.start)
8877+
|| period_info.check_field(row_end, period.end);
88888878
if (res)
88898879
return true;
88908880

sql/handler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,8 +2117,6 @@ struct Vers_parse_info: public Table_period_info
21172117
}
21182118

21192119
protected:
2120-
bool is_start(const char *name) const;
2121-
bool is_end(const char *name) const;
21222120
bool is_start(const Create_field &f) const;
21232121
bool is_end(const Create_field &f) const;
21242122
bool fix_implicit(THD *thd, Alter_info *alter_info);

sql/lex_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Lex_cstring : public LEX_CSTRING
110110
class Lex_cstring_strlen: public Lex_cstring
111111
{
112112
public:
113-
Lex_cstring_strlen(const char *from)
113+
explicit Lex_cstring_strlen(const char *from)
114114
:Lex_cstring(from, from ? strlen(from) : 0)
115115
{ }
116116
};

sql/sql_table.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6235,7 +6235,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info,
62356235
}
62366236
else if (drop->type == Alter_drop::PERIOD)
62376237
{
6238-
if (table->s->period.name.streq(drop->name))
6238+
if (table->s->period.name.streq(Lex_ident(drop->name)))
62396239
remove_drop= FALSE;
62406240
}
62416241
else /* Alter_drop::KEY and Alter_drop::FOREIGN_KEY */
@@ -9227,7 +9227,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
92279227
for (bool found= false; !found && (drop= drop_it++); )
92289228
{
92299229
found= drop->type == Alter_drop::PERIOD &&
9230-
table->s->period.name.streq(drop->name);
9230+
table->s->period.name.streq(Lex_ident(drop->name));
92319231
}
92329232

92339233
if (drop)
@@ -9270,7 +9270,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
92709270
}
92719271
}
92729272

9273-
if (share->period.constr_name.streq(check->name.str))
9273+
if (share->period.constr_name.streq(check->name))
92749274
{
92759275
if (!drop_period && !keep)
92769276
{

sql/table.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ struct vers_select_conds_t
21922192
void init(vers_system_time_t _type,
21932193
Vers_history_point _start= Vers_history_point(),
21942194
Vers_history_point _end= Vers_history_point(),
2195-
Lex_ident _name= "SYSTEM_TIME")
2195+
Lex_ident _name= { STRING_WITH_LEN("SYSTEM_TIME") })
21962196
{
21972197
type= _type;
21982198
orig_type= _type;
@@ -2207,7 +2207,7 @@ struct vers_select_conds_t
22072207
void set_all()
22082208
{
22092209
type= SYSTEM_TIME_ALL;
2210-
name= "SYSTEM_TIME";
2210+
name= { STRING_WITH_LEN("SYSTEM_TIME") };
22112211
}
22122212

22132213
void print(String *str, enum_query_type query_type) const;

sql/vers_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct Lex_cstring_with_compare : public Lex_cstring
6262
{ }
6363
Lex_cstring_with_compare(const LEX_CSTRING src) : Lex_cstring(src.str, src.length)
6464
{ }
65-
Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str))
65+
explicit Lex_cstring_with_compare(const char *_str) : Lex_cstring(_str, strlen(_str))
6666
{ }
6767
bool streq(const Lex_cstring_with_compare& b) const
6868
{

0 commit comments

Comments
 (0)