Commit 3228a2be authored by Sergey Vojtovich's avatar Sergey Vojtovich

BUG#45638 - Create temporary table with engine innodb fails

Create temporary InnoDB table fails on case insensitive
filesystems, when lower_case_table_names is 2 (e.g. OS X)
and temporary directory path contains upper case letters.

The problem was that tmpdir prefix was converted to lower
case when table was created, but was passed as is when
table was opened.

Fixed by leaving tmpdir prefix part intact.

mysql-test/r/lowercase_mixed_tmpdir_innodb.result:
  A test case for BUG#45638.
mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt:
  A test case for BUG#45638.
mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh:
  A test case for BUG#45638.
mysql-test/t/lowercase_mixed_tmpdir_innodb.test:
  A test case for BUG#45638.
sql/handler.cc:
  Fixed get_canonical_filename() to not lowercase filesystem
  path prefix for temporary tables.
parent a00ba9eb
drop table if exists t1;
create table t1 (id int) engine=InnoDB;
insert into t1 values (1);
create temporary table t2 engine=InnoDB select * from t1;
drop temporary table t2;
drop table t1;
--lower-case-table-names=2
--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_lowercase2.inc
--source include/have_innodb.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (id int) engine=InnoDB;
insert into t1 values (1);
create temporary table t2 engine=InnoDB select * from t1;
drop temporary table t2;
drop table t1;
...@@ -1885,12 +1885,42 @@ bool ha_flush_logs(handlerton *db_type) ...@@ -1885,12 +1885,42 @@ bool ha_flush_logs(handlerton *db_type)
return FALSE; return FALSE;
} }
/**
@brief make canonical filename
@param[in] file table handler
@param[in] path original path
@param[out] tmp_path buffer for canonized path
@details Lower case db name and table name path parts for
non file based tables when lower_case_table_names
is 2 (store as is, compare in lower case).
Filesystem path prefix (mysql_data_home or tmpdir)
is left intact.
@note tmp_path may be left intact if no conversion was
performed.
@retval canonized path
@todo This may be done more efficiently when table path
gets built. Convert this function to something like
ASSERT_CANONICAL_FILENAME.
*/
const char *get_canonical_filename(handler *file, const char *path, const char *get_canonical_filename(handler *file, const char *path,
char *tmp_path) char *tmp_path)
{ {
uint i;
if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED)) if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED))
return path; return path;
for (i= 0; i <= mysql_tmpdir_list.max; i++)
{
if (is_prefix(path, mysql_tmpdir_list.list[i]))
return path;
}
/* Ensure that table handler get path in lower case */ /* Ensure that table handler get path in lower case */
if (tmp_path != path) if (tmp_path != path)
strmov(tmp_path, path); strmov(tmp_path, path);
......
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