summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mysql.com>2002-11-05 00:00:51 +0100
committerunknown <serg@sergbook.mysql.com>2002-11-05 00:00:51 +0100
commit3fbb70294662f3bc604c68d25d44d802c9835c8e (patch)
treec0328212efe7c722b0154253a487ad341625ce2a
parent195aa6c98f94254b33b3d2423833275485de6eca (diff)
downloadmariadb-git-3fbb70294662f3bc604c68d25d44d802c9835c8e.tar.gz
TEMPORARY MERGE tables are allowed
-rw-r--r--mysql-test/r/merge.result6
-rw-r--r--mysql-test/t/merge.test19
-rw-r--r--sql/ha_myisammrg.cc23
3 files changed, 47 insertions, 1 deletions
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 653e25af799..bdde202b335 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -130,3 +130,9 @@ a
a b
1 1
1 2
+a
+1
+2
+a
+1
+2
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 238dd599664..6ea9ecc269f 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -114,3 +114,22 @@ insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
flush tables;
select * from t3 where a=1 order by b limit 2;
drop table t3,t1,t2;
+
+#
+# temporary merge tables
+#
+drop table if exists t1, t2, t3, t4, t5, t6;
+create table t1 (a int not null);
+create table t2 (a int not null);
+insert into t1 values (1);
+insert into t2 values (2);
+create temporary table t3 (a int not null) TYPE=MERGE UNION=(t1,t2);
+select * from t3;
+create temporary table t4 (a int not null);
+create temporary table t5 (a int not null);
+insert into t4 values (1);
+insert into t5 values (2);
+create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
+select * from t6;
+drop table if exists t1, t2, t3, t4, t5, t6;
+
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index e5fb0310a36..e9b6a048264 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -264,7 +264,28 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
sizeof(char*))))
DBUG_RETURN(1);
for (pos=table_names ; tables ; tables=tables->next)
- *pos++= tables->real_name;
+ {
+ char *table_name;
+ if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
+ {
+ TABLE **tbl=find_temporary_table(current_thd,
+ tables->db, tables->real_name);
+ if (!tbl)
+ {
+ table_name=sql_alloc(1+
+ my_snprintf(buff,FN_REFLEN,"%s/%s/%s",mysql_real_data_home,
+ tables->db, tables->real_name));
+ if (!table_name)
+ DBUG_RETURN(1);
+ strcpy(table_name, buff);
+ }
+ else
+ table_name=(*tbl)->path;
+ }
+ else
+ table_name=tables->real_name;
+ *pos++= table_name;
+ }
*pos=0;
DBUG_RETURN(myrg_create(fn_format(buff,name,"","",2+4+16),
(const char **) table_names, (my_bool) 0));