Commit 7430fc2e authored by unknown's avatar unknown
Browse files

extra correction of check_db_name, check_table_name and check_column_name

parent 8550c7ab
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -1140,7 +1140,7 @@ char *get_field(MEM_ROOT *mem, TABLE *table, uint fieldnr)
bool check_db_name(char *name)
{
  char *start=name;
  bool space= false;
  bool last_char_is_space= FALSE;

  if (lower_case_table_names)
    casedn_str(name);
@@ -1148,7 +1148,7 @@ bool check_db_name(char *name)
  while (*name)
  {
#if defined(USE_MB) && defined(USE_MB_IDENT)
    space= my_isspace(default_charset_info, *name);
    last_char_is_space= my_isspace(default_charset_info, *name);
    if (use_mb(default_charset_info))
    {
      int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN);
@@ -1159,16 +1159,14 @@ bool check_db_name(char *name)
      }
    }
#else
    space= *name==' ';
    last_char_is_space= *name==' ';
#endif
    if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR ||
	*name == FN_EXTCHAR)
      return 1;
    name++;
  }
  if (space)
    return 1;
  return name[-1]==' ' || (uint) (name - start) > NAME_LEN;
  return last_char_is_space || (uint) (name - start) > NAME_LEN;
}


@@ -1186,7 +1184,7 @@ bool check_table_name(const char *name, uint length)
  if (!length || length > NAME_LEN)
    return 1;
#if defined(USE_MB) && defined(USE_MB_IDENT)
  bool space= false;
  bool last_char_is_space= FALSE;
#else
  if (name[length-1]==' ')
    return 1;
@@ -1195,7 +1193,7 @@ bool check_table_name(const char *name, uint length)
  while (name != end)
  {
#if defined(USE_MB) && defined(USE_MB_IDENT)
    space= my_isspace(default_charset_info, *name);
    last_char_is_space= my_isspace(default_charset_info, *name);
    if (use_mb(default_charset_info))
    {
      int len=my_ismbchar(default_charset_info, name, end);
@@ -1211,21 +1209,21 @@ bool check_table_name(const char *name, uint length)
    name++;
  }
#if defined(USE_MB) && defined(USE_MB_IDENT)
  if (space)
    return 1;
#endif
  return last_char_is_space;
#else
  return 0;
#endif
}

bool check_column_name(const char *name)
{
  const char *start= name;
  bool space= false;
  bool last_char_is_space= false;
  
  while (*name)
  {
#if defined(USE_MB) && defined(USE_MB_IDENT)
    space= my_isspace(default_charset_info, *name);
    last_char_is_space= my_isspace(default_charset_info, *name);
    if (use_mb(default_charset_info))
    {
      int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN);
@@ -1236,16 +1234,14 @@ bool check_column_name(const char *name)
      }
    }
#else
    space= *name==' ';
    last_char_is_space= *name==' ';
#endif
    if (*name == NAMES_SEP_CHAR)
      return 1;
    name++;
  }
  if (space)
    return 1;
  /* Error if empty or too long column name */
  return (name == start || (uint) (name - start) > NAME_LEN);
  return last_char_is_space || (name == start || (uint) (name - start) > NAME_LEN);
}

/*