summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorDmitry Lenev <Dmitry.Lenev@oracle.com>2011-06-09 16:54:12 +0400
committerDmitry Lenev <Dmitry.Lenev@oracle.com>2011-06-09 16:54:12 +0400
commit600647c7d8647dc31025146896a671619d73d97f (patch)
treeed0d4c5d18718a81385afad3ba485cb28f02c165 /mysql-test
parent34baff7743df3f6fb67c8e4bffa58e9758b0c86b (diff)
downloadmariadb-git-600647c7d8647dc31025146896a671619d73d97f.tar.gz
Fix for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... '
STATEMENTS FAIL". Attempt to execute CREATE TABLE LIKE statement on a MyISAM table with INDEX or DATA DIRECTORY options specified as a source resulted in "MyISAM table '...' is in use..." error. According to our documentation such a statement should create a copy of source table with DATA/INDEX DIRECTORY options omitted. The problem was that new implementation of CREATE TABLE LIKE statement in 5.5 tried to copy value of INDEX and DATA DIRECTORY parameters from the source table. Since in description of source table this parameters also included name of this table, attempt to create target table with these parameter led to file name conflict and error. This fix addresses the problem by preserving documented and backward-compatible behavior. I.e. by ensuring that contents of DATA/INDEX DIRECTORY clauses for the source table is ignored when target table is created. mysql-test/r/symlink.result: Added test for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... ' STATEMENTS FAIL". mysql-test/t/symlink.test: Added test for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... ' STATEMENTS FAIL". sql/sql_table.cc: Changed CREATE TABLE LIKE implementation to ignore contents of DATA/INDEX DIRECTORY clauses for source table when target table is created. This is documented and backward-compatible behavior.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/symlink.result25
-rw-r--r--mysql-test/t/symlink.test21
2 files changed, 46 insertions, 0 deletions
diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result
index e7ee871b55b..20736aec47f 100644
--- a/mysql-test/r/symlink.result
+++ b/mysql-test/r/symlink.result
@@ -188,3 +188,28 @@ DROP TABLE user;
FLUSH TABLE mysql.user;
SELECT * FROM mysql.user;
End of 5.1 tests
+#
+# Test for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... '
+# STATEMENTS FAIL".
+#
+drop table if exists t1, t2;
+create table t1 (a int primary key) engine=myisam
+data directory="MYSQLTEST_VARDIR/tmp"
+ index directory="MYSQLTEST_VARDIR/run";
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' INDEX DIRECTORY='MYSQLTEST_VARDIR/run/'
+# CREATE TABLE LIKE statement on table with INDEX/DATA DIRECTORY
+# options should not fail. Per documentation newly created table
+# should not inherit value of these options from the original table.
+create table t2 like t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop tables t1, t2;
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index 87b874bc81f..5109137e564 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -277,3 +277,24 @@ SELECT * FROM mysql.user;
--remove_file $MYSQL_TMP_DIR/mysql
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Test for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... '
+--echo # STATEMENTS FAIL".
+--echo #
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval create table t1 (a int primary key) engine=myisam
+ data directory="$MYSQLTEST_VARDIR/tmp"
+ index directory="$MYSQLTEST_VARDIR/run";
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+show create table t1;
+--echo # CREATE TABLE LIKE statement on table with INDEX/DATA DIRECTORY
+--echo # options should not fail. Per documentation newly created table
+--echo # should not inherit value of these options from the original table.
+create table t2 like t1;
+show create table t2;
+drop tables t1, t2;