1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Make all #sql temporary table names uniform

The reason for this is to make all temporary file names similar and
also to be able to figure out from where a #sql-xxx name orginates.

New format is for most cases:
'#sql-name-current_pid-thread_id[-increment]'
Where name is one of subselect, alter, exchange, temptable or backup

The exceptions are:
ALTER PARTITION shadow files:
'#sql-shadow-thread_id-'original_table_name'

Names used with temp pool:
'#sql-name-current_pid-pool_number'
This commit is contained in:
Monty
2020-04-09 16:52:59 +03:00
parent eca5c2c67f
commit f40ca33bbc
16 changed files with 140 additions and 119 deletions

View File

@ -594,7 +594,7 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen)
DBUG_ENTER("build_tmptable_filename");
char *p= strnmov(buff, mysql_tmpdir, bufflen);
my_snprintf(p, bufflen - (p - buff), "/%s%lx_%llx_%x",
my_snprintf(p, bufflen - (p - buff), "/%s-temptable-%lx-%llx-%x",
tmp_file_prefix, current_pid,
thd->thread_id, thd->tmp_table++);
@ -1762,8 +1762,8 @@ uint build_table_shadow_filename(char *buff, size_t bufflen,
ALTER_PARTITION_PARAM_TYPE *lpt)
{
char tmp_name[FN_REFLEN];
my_snprintf(tmp_name, sizeof (tmp_name), "%s-%s", tmp_file_prefix,
lpt->table_name.str);
my_snprintf(tmp_name, sizeof (tmp_name), "%s-shadow-%lx-%s", tmp_file_prefix,
(ulong) current_thd->thread_id, lpt->table_name.str);
return build_table_filename(buff, bufflen, lpt->db.str, tmp_name, "",
FN_IS_TMP);
}
@ -10720,8 +10720,8 @@ do_continue:;
if (!alter_ctx.is_table_renamed())
{
backup_name.length= my_snprintf(backup_name_buff, sizeof(backup_name_buff),
"%s2-%lx-%lx", tmp_file_prefix,
current_pid, (long) thd->thread_id);
"%s-backup-%lx-%llx", tmp_file_prefix,
current_pid, thd->thread_id);
if (lower_case_table_names)
my_casedn_str(files_charset_info, backup_name_buff);
if (mysql_rename_table(old_db_type, &alter_ctx.db, &alter_ctx.table_name,