diff options
author | unknown <acurtis@xiphis.org> | 2006-07-05 17:18:59 -0700 |
---|---|---|
committer | unknown <acurtis@xiphis.org> | 2006-07-05 17:18:59 -0700 |
commit | 854d7c4d4f5ccc110f65dd740e304a196428b3d6 (patch) | |
tree | 399f52e407d89318f0656e4e938b4f98d202ea6d | |
parent | 8fdac9c74b0dbd7f6c8fc073b1c0e69864840245 (diff) | |
download | mariadb-git-854d7c4d4f5ccc110f65dd740e304a196428b3d6.tar.gz |
Bug#8706
"temporary table with data directory option fails"
myisam should not use user-specified table name when creating
temporary tables and use generated connection specific real name.
Test included.
myisam/mi_create.c:
Bug#8706
When creating a temporary table with directory override, ensure that
the real filename is using the hidden temporary name otherwise
multiple clients cannot have same named temporary tables without
conflict.
mysql-test/r/myisam.result:
Bug#8706
Test for bug
mysql-test/t/myisam.test:
Bug#8706
Test for bug
-rw-r--r-- | myisam/mi_create.c | 36 | ||||
-rw-r--r-- | mysql-test/r/myisam.result | 21 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 31 |
3 files changed, 81 insertions, 7 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 41c965c7c80..d15cad2840f 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -519,9 +519,20 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (ci->index_file_name) { - fn_format(filename, ci->index_file_name,"",MI_NAME_IEXT,4); - fn_format(linkname,name, "",MI_NAME_IEXT,4); - linkname_ptr=linkname; + if (options & HA_OPTION_TMP_TABLE) + { + char *path; + /* chop off the table name, tempory tables use generated name */ + if ((path= strrchr(ci->index_file_name, FN_LIBCHAR))) + *path= '\0'; + fn_format(filename, name, ci->index_file_name, MI_NAME_IEXT, + MY_REPLACE_DIR | MY_UNPACK_FILENAME); + } + else + fn_format(filename, ci->index_file_name, "", + MI_NAME_IEXT, MY_UNPACK_FILENAME); + fn_format(linkname, name, "", MI_NAME_IEXT, MY_UNPACK_FILENAME); + linkname_ptr= linkname; /* Don't create the table if the link or file exists to ensure that one doesn't accidently destroy another table. @@ -575,10 +586,21 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, { if (ci->data_file_name) { - fn_format(filename, ci->data_file_name,"",MI_NAME_DEXT,4); - fn_format(linkname, name, "",MI_NAME_DEXT,4); - linkname_ptr=linkname; - create_flag=0; + if (options & HA_OPTION_TMP_TABLE) + { + char *path; + /* chop off the table name, tempory tables use generated name */ + if ((path= strrchr(ci->data_file_name, FN_LIBCHAR))) + *path= '\0'; + fn_format(filename, name, ci->data_file_name, MI_NAME_DEXT, + MY_REPLACE_DIR | MY_UNPACK_FILENAME); + } + else + fn_format(filename, ci->data_file_name, "", + MI_NAME_DEXT, MY_UNPACK_FILENAME); + fn_format(linkname, name, "", MI_NAME_DEXT, MY_UNPACK_FILENAME); + linkname_ptr= linkname; + create_flag= 0; } else { diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index cd1bc5c34e8..ce601944f97 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -769,3 +769,24 @@ a b xxxxxxxxx bbbbbb xxxxxxxxx bbbbbb DROP TABLE t1; +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create table t1 (a int) engine=myisam select 42 a; +select * from t1; +a +9 +select * from t1; +a +99 +select * from t1; +a +42 +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index ca49db40ae4..be7bec117f3 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -726,4 +726,35 @@ UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb'; SELECT * FROM t1; DROP TABLE t1; +# +# Bug#8706 - temporary table with data directory option fails +# +connect (session1,localhost,root,,); +connect (session2,localhost,root,,); + +connection session1; +disable_query_log; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp" select 9 a; +enable_query_log; +show create table t1; + +connection session2; +disable_query_log; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp" select 99 a; +enable_query_log; +show create table t1; + +connection default; +create table t1 (a int) engine=myisam select 42 a; + +connection session1; +select * from t1; +disconnect session1; +connection session2; +select * from t1; +disconnect session2; +connection default; +select * from t1; +drop table t1; + # End of 4.1 tests |