Bug #27653: Temp table can't be created if lower_case_table_names=1 and

            tmpdir has uppercase

Fix: don't convert mysql_tmpdir to lower case when building the path to a
temporary table
parent 5d7a264c
--require r/lowercase1.require
--disable_query_log
show variables like 'lower_case_table_names';
--enable_query_log
Variable_name Value
lower_case_table_names 1
drop table if exists t1;
create table t1 (id int) engine=myisam;
insert into t1 values (1);
create temporary table t2 select * from t1;
drop temporary table t2;
drop table t1;
--lower-case-table-names=1
--tmpdir=$MYSQLTEST_VARDIR/tmp/MixedCase
# This test requires a non-lowercase tmpdir directory on a case-sensitive
# filesystem.
d="$MYSQLTEST_VARDIR/tmp/MixedCase"
test -d "$d" || mkdir "$d"
rm -f "$d"/*
--source include/have_case_sensitive_file_system.inc
--source include/have_lowercase1.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (id int) engine=myisam;
insert into t1 values (1);
create temporary table t2 select * from t1;
drop temporary table t2;
drop table t1;
...@@ -42,6 +42,7 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, ...@@ -42,6 +42,7 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
static bool prepare_blob_field(THD *thd, create_field *sql_field); static bool prepare_blob_field(THD *thd, create_field *sql_field);
static bool check_engine(THD *thd, const char *table_name, static bool check_engine(THD *thd, const char *table_name,
enum db_type *new_engine); enum db_type *new_engine);
static void set_tmp_file_path(char *buf, size_t bufsize, THD *thd);
/* /*
...@@ -1681,11 +1682,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -1681,11 +1682,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
/* Check if table exists */ /* Check if table exists */
if (create_info->options & HA_LEX_CREATE_TMP_TABLE) if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{ {
my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s", set_tmp_file_path(path, sizeof(path), thd);
mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id,
thd->tmp_table++, reg_ext);
if (lower_case_table_names)
my_casedn_str(files_charset_info, path);
create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE;
} }
else else
...@@ -2801,11 +2798,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -2801,11 +2798,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
{ {
if (find_temporary_table(thd, db, table_name)) if (find_temporary_table(thd, db, table_name))
goto table_exists; goto table_exists;
my_snprintf(dst_path, sizeof(dst_path), "%s%s%lx_%lx_%x%s", set_tmp_file_path(dst_path, sizeof(dst_path), thd);
mysql_tmpdir, tmp_file_prefix, current_pid,
thd->thread_id, thd->tmp_table++, reg_ext);
if (lower_case_table_names)
my_casedn_str(files_charset_info, dst_path);
create_info->table_options|= HA_CREATE_DELAY_KEY_WRITE; create_info->table_options|= HA_CREATE_DELAY_KEY_WRITE;
} }
else else
...@@ -4319,3 +4312,16 @@ static bool check_engine(THD *thd, const char *table_name, ...@@ -4319,3 +4312,16 @@ static bool check_engine(THD *thd, const char *table_name,
} }
return FALSE; return FALSE;
} }
static void set_tmp_file_path(char *buf, size_t bufsize, THD *thd)
{
char *p= strnmov(buf, mysql_tmpdir, bufsize);
my_snprintf(p, bufsize - (p - buf), "%s%lx_%lx_%x%s",
tmp_file_prefix, current_pid,
thd->thread_id, thd->tmp_table++, reg_ext);
if (lower_case_table_names)
{
/* Convert all except tmpdir to lower case */
my_casedn_str(files_charset_info, p);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment