1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

WL#1324 table name to file name encoding

- Encoding itself, implemented as a charset
  "filename". Originally planned to use '.'
  as an escape character, but now changed to '@'
  for two reasons: "ls" does not return
  file names starting with '.' considering them
  as a kind of hidden files; some platforms
  do not allow several dots in a file name.
- replacing many calls of my_snprintf() and
  strnxmov() to the new build_table_filename().
- Adding MY_APPEND_EXT mysys flag, to append
  an extention rather that replace it.
- Replacing all numeric constants in fn_format
  flag arguments to their mysys definitions, e.g.
  MY_UNPACK_FILENAME,
- Predictability in several function/methods:
  when a table name can appear with or withot .frm
  extension. Some functions/methods were changed
  so accept names strictly with .frm, other - strictly
  without .frm extensions. Several DBUG_ASSERTs were
  added to check whether an extension is passed.
Many files:
  table name to file name encoding
mysql_priv.h:
  Prototypes for new table name encoding tools.
ctype-utf8.c:
  Implementing "filename" charset for
  table name to file name encoding.
row0mysql.c:
  Fixing table name prefix.
mf_format.c:
  Adding MY_APPEND_EXT processing.
Many files:
  Fixing tests.
my_sys.h:
  Adding new flag to append rather than replace an extension.
m_ctype.h:
  Adding "filename" charset definition.
This commit is contained in:
bar@mysql.com
2005-12-31 09:01:26 +04:00
parent 83d8979ca2
commit 6ff211329f
42 changed files with 1803 additions and 269 deletions

View File

@ -413,9 +413,14 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
for (i=0 ; i < (uint) dirp->number_off_files ; i++)
{
char uname[NAME_LEN*3+1]; /* Unencoded name */
file=dirp->dir_entry+i;
if (dir)
{ /* Return databases */
if ((file->name[0] == '.' &&
((file->name[1] == '.' && file->name[2] == '\0') ||
file->name[1] == '\0')))
continue; /* . or .. */
#ifdef USE_SYMDIR
char *ext;
char buff[FN_REFLEN];
@ -432,17 +437,21 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
continue;
}
#endif
if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat->st_mode) ||
(wild && wild_compare(file->name,wild,0)))
continue;
VOID(filename_to_tablename(file->name, uname, sizeof(uname)));
if (!MY_S_ISDIR(file->mystat->st_mode) ||
(wild && wild_compare(uname, wild, 0)))
continue;
file->name= uname;
}
else
{
// Return only .frm files which aren't temp files.
if (my_strcasecmp(system_charset_info, ext=fn_ext(file->name),reg_ext) ||
if (my_strcasecmp(system_charset_info, ext=fn_rext(file->name),reg_ext) ||
is_prefix(file->name,tmp_file_prefix))
continue;
*ext=0;
VOID(filename_to_tablename(file->name, uname, sizeof(uname)));
file->name= uname;
if (wild)
{
if (lower_case_table_names)
@ -604,8 +613,7 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
}
else
{
(void) sprintf(path,"%s/%s",mysql_data_home, dbname);
length=unpack_dirname(path,path); // Convert if not unix
length= build_table_filename(path, sizeof(path), dbname, "", "");
found_libchar= 0;
if (length && path[length-1] == FN_LIBCHAR)
{
@ -883,7 +891,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
HA_CREATE_INFO *create_info_arg)
{
List<Item> field_list;
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end;
char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end, uname[NAME_LEN*3+1];
const char *alias;
String type(tmp, sizeof(tmp), system_charset_info);
Field **ptr,*field;
@ -914,8 +922,14 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
if (table_list->schema_table)
alias= table_list->schema_table->table_name;
else
alias= (lower_case_table_names == 2 ? table->alias :
share->table_name.str);
{
if (lower_case_table_names == 2)
alias= table->alias;
else
{
alias= share->table_name.str;
}
}
append_identifier(thd, packet, alias, strlen(alias));
packet->append(STRING_WITH_LEN(" (\n"));
@ -2312,8 +2326,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
}
else
{
strxmov(path, mysql_data_home, "/", base_name, NullS);
end= path + (len= unpack_dirname(path,path));
len= build_table_filename(path, sizeof(path), base_name, "", "");
end= path + len;
len= FN_LEN - len;
if (mysql_find_files(thd, &files, base_name,
path, idx_field_vals.table_value, 0))
@ -2460,8 +2474,7 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
(grant_option && !check_grant_db(thd, file_name)))
#endif
{
strxmov(path, mysql_data_home, "/", file_name, NullS);
length=unpack_dirname(path,path); // Convert if not unix
length= build_table_filename(path, sizeof(path), file_name, "", "");
found_libchar= 0;
if (length && path[length-1] == FN_LIBCHAR)
{