List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:September 9 2009 9:38am
Subject:bzr commit into mysql-5.1 branch (svoj:3093) Bug#45638
View as plain text  
#At file:///home/svoj/devel/bzr-mysql/mysql-5.1-bugteam-bug45638/ based on revid:dao-gang.qu@stripped

 3093 Sergey Vojtovich	2009-09-09
      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.

    added:
      mysql-test/r/lowercase_mixed_tmpdir_innodb.result
      mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt
      mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh
      mysql-test/t/lowercase_mixed_tmpdir_innodb.test
    modified:
      sql/handler.cc
=== added file 'mysql-test/r/lowercase_mixed_tmpdir_innodb.result'
--- a/mysql-test/r/lowercase_mixed_tmpdir_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/lowercase_mixed_tmpdir_innodb.result	2009-09-09 09:38:50 +0000
@@ -0,0 +1,6 @@
+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;

=== added file 'mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt'
--- a/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.opt	2009-09-09 09:38:50 +0000
@@ -0,0 +1,2 @@
+--lower-case-table-names=2
+--tmpdir=$MYSQLTEST_VARDIR/tmp/MixedCase

=== added file 'mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh'
--- a/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh	2009-09-09 09:38:50 +0000
@@ -0,0 +1,6 @@
+# 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"/*

=== added file 'mysql-test/t/lowercase_mixed_tmpdir_innodb.test'
--- a/mysql-test/t/lowercase_mixed_tmpdir_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/lowercase_mixed_tmpdir_innodb.test	2009-09-09 09:38:50 +0000
@@ -0,0 +1,12 @@
+--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;

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2009-07-29 08:54:20 +0000
+++ b/sql/handler.cc	2009-09-09 09:38:50 +0000
@@ -1885,12 +1885,42 @@ bool ha_flush_logs(handlerton *db_type)
   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,
                                    char *tmp_path)
 {
+  uint i;
   if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED))
     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 */
   if (tmp_path != path)
     strmov(tmp_path, path);


Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20090909093850-96b789y72xu3d4xi.bundle
Thread
bzr commit into mysql-5.1 branch (svoj:3093) Bug#45638Sergey Vojtovich9 Sep