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.
This commit is contained in:
Alexander Barkov 2023-08-23 09:53:14 +04:00
parent 21218d3c9e
commit b5418521cc
3 changed files with 7 additions and 21 deletions

View file

@ -126,7 +126,7 @@ static int show_create_db(THD *thd, LEX *lex);
static bool alter_routine(THD *thd, LEX *lex);
static bool drop_routine(THD *thd, LEX *lex);
const LEX_CSTRING any_db= {STRING_WITH_LEN("*any*")};
const Lex_ident_db any_db(STRING_WITH_LEN("*any*"));
const LEX_CSTRING command_name[257]={
{ STRING_WITH_LEN("Sleep") }, //0

View file

@ -129,7 +129,7 @@ bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
/* Variables */
extern const LEX_CSTRING any_db;
extern const Lex_ident_db any_db;
extern uint sql_command_flags[];
extern uint server_command_flags[];
extern const LEX_CSTRING command_name[];

View file

@ -5258,27 +5258,17 @@ bool Lex_ident_fs::check_body(const char *name, size_t length,
size_t char_length= 0;
const char *end= name + length;
#if defined(USE_MB) && defined(USE_MB_IDENT)
bool last_char_is_space= FALSE;
#else
if (name[length-1]==' ')
return 1;
#endif
for ( ; name != end ; char_length++)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
last_char_is_space= my_isspace(system_charset_info, *name);
if (system_charset_info->use_mb())
int len= my_ismbchar(&my_charset_utf8mb3_general_ci, name, end);
if (len)
{
int len=my_ismbchar(system_charset_info, name, end);
if (len)
{
name+= len;
continue;
}
name+= len;
continue;
}
#endif
if (disallow_path_chars &&
(*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR))
return 1;
@ -5299,11 +5289,7 @@ bool Lex_ident_fs::check_body(const char *name, size_t length,
return 1;
name++;
}
#if defined(USE_MB) && defined(USE_MB_IDENT)
return last_char_is_space || (char_length > NAME_CHAR_LEN);
#else
return FALSE;
#endif
return char_length > NAME_CHAR_LEN;
}