Skip to content

Commit b541852

Browse files
committed
MDEV-31989 Cleanup Lex_ident_fs::check_body()
- Changing the data type of the global variable any_db from LEX_CSTRING to Lex_ident_db - Removing the dependency on system_charset_info from Lex_ident_fs::check_body(), using my_charset_utf8mb3_general_ci directly, because system_charset_info is initialized much later than any_db. system_charset_info cannot be changed dynamically any way. - Removing the unsed old code from Lex_ident_fs::check_body(). This code was last used in MySQL-4.0 and won't be used in the future.
1 parent 21218d3 commit b541852

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

sql/sql_parse.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int show_create_db(THD *thd, LEX *lex);
126126
static bool alter_routine(THD *thd, LEX *lex);
127127
static bool drop_routine(THD *thd, LEX *lex);
128128

129-
const LEX_CSTRING any_db= {STRING_WITH_LEN("*any*")};
129+
const Lex_ident_db any_db(STRING_WITH_LEN("*any*"));
130130

131131
const LEX_CSTRING command_name[257]={
132132
{ STRING_WITH_LEN("Sleep") }, //0

sql/sql_parse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
129129

130130
/* Variables */
131131

132-
extern const LEX_CSTRING any_db;
132+
extern const Lex_ident_db any_db;
133133
extern uint sql_command_flags[];
134134
extern uint server_command_flags[];
135135
extern const LEX_CSTRING command_name[];

sql/table.cc

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5258,27 +5258,17 @@ bool Lex_ident_fs::check_body(const char *name, size_t length,
52585258
size_t char_length= 0;
52595259
const char *end= name + length;
52605260

5261-
#if defined(USE_MB) && defined(USE_MB_IDENT)
5262-
bool last_char_is_space= FALSE;
5263-
#else
52645261
if (name[length-1]==' ')
52655262
return 1;
5266-
#endif
52675263

52685264
for ( ; name != end ; char_length++)
52695265
{
5270-
#if defined(USE_MB) && defined(USE_MB_IDENT)
5271-
last_char_is_space= my_isspace(system_charset_info, *name);
5272-
if (system_charset_info->use_mb())
5266+
int len= my_ismbchar(&my_charset_utf8mb3_general_ci, name, end);
5267+
if (len)
52735268
{
5274-
int len=my_ismbchar(system_charset_info, name, end);
5275-
if (len)
5276-
{
5277-
name+= len;
5278-
continue;
5279-
}
5269+
name+= len;
5270+
continue;
52805271
}
5281-
#endif
52825272
if (disallow_path_chars &&
52835273
(*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR))
52845274
return 1;
@@ -5299,11 +5289,7 @@ bool Lex_ident_fs::check_body(const char *name, size_t length,
52995289
return 1;
53005290
name++;
53015291
}
5302-
#if defined(USE_MB) && defined(USE_MB_IDENT)
5303-
return last_char_is_space || (char_length > NAME_CHAR_LEN);
5304-
#else
5305-
return FALSE;
5306-
#endif
5292+
return char_length > NAME_CHAR_LEN;
53075293
}
53085294

53095295

0 commit comments

Comments
 (0)