summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-12-01 20:12:19 +0100
committerSergei Golubchik <sergii@pisem.net>2013-12-01 20:12:19 +0100
commit7e431dc3794a553c9a29865f66475d1b7f49a9bc (patch)
tree64de1aac574cec344de6f9c10f60bbff6c81ca7e
parent94bef7f99f2117bd5aaa50f2bc996c7d13922e9f (diff)
parentf534708bd6637da06a0dbeb5192351072a8bbbcd (diff)
downloadmariadb-git-7e431dc3794a553c9a29865f66475d1b7f49a9bc.tar.gz
5.1 merge
-rw-r--r--mysql-test/r/merge.result7
-rw-r--r--mysql-test/t/merge.test9
-rw-r--r--storage/myisammrg/ha_myisammrg.cc43
3 files changed, 40 insertions, 19 deletions
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 937fa77a885..7b50be68281 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -2368,4 +2368,11 @@ FLUSH TABLES;
ERROR HY000: Can't reopen table: 'm1'
UNLOCK TABLES;
DROP TABLE t1, t2, t3, m1;
+create temporary table t1_temp(i int);
+create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last;
+alter table tm_temp_temp insert_method=first;
+check table tm_temp_temp;
+Table Op Msg_type Msg_text
+test.tm_temp_temp check status OK
+drop temporary table t1_temp, tm_temp_temp;
End of 5.1 tests
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index eecf892869f..cc26ba35661 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -1863,6 +1863,15 @@ FLUSH TABLES;
UNLOCK TABLES;
DROP TABLE t1, t2, t3, m1;
+#
+# MDEV-5266 MySQL:57657 - Temporary MERGE table with temporary underlying is broken by ALTER
+#
+create temporary table t1_temp(i int);
+create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last;
+alter table tm_temp_temp insert_method=first;
+check table tm_temp_temp;
+drop temporary table t1_temp, tm_temp_temp;
+
--echo End of 5.1 tests
--disable_result_log
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 274ba2fcd81..d51ca365338 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -1111,31 +1111,36 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
if (!(create_info->used_fields & HA_CREATE_USED_UNION))
{
- MYRG_TABLE *open_table;
+ TABLE_LIST *child_table;
THD *thd=current_thd;
create_info->merge_list.next= &create_info->merge_list.first;
create_info->merge_list.elements=0;
- for (open_table=file->open_tables ;
- open_table != file->end_table ;
- open_table++)
+ if (table->child_l != NULL)
{
- TABLE_LIST *ptr;
- LEX_STRING db, name;
- LINT_INIT(db.str);
-
- if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
- goto err;
- split_file_name(open_table->table->filename, &db, &name);
- if (!(ptr->table_name= thd->strmake(name.str, name.length)))
- goto err;
- if (db.length && !(ptr->db= thd->strmake(db.str, db.length)))
- goto err;
-
- create_info->merge_list.elements++;
- (*create_info->merge_list.next) = ptr;
- create_info->merge_list.next= &ptr->next_local;
+ for (child_table= table->child_l;;
+ child_table= child_table->next_global)
+ {
+ TABLE_LIST *ptr;
+
+ if (!(ptr= (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
+ goto err;
+
+ if (!(ptr->table_name= thd->strmake(child_table->table_name,
+ child_table->table_name_length)))
+ goto err;
+ if (child_table->db && !(ptr->db= thd->strmake(child_table->db,
+ child_table->db_length)))
+ goto err;
+
+ create_info->merge_list.elements++;
+ (*create_info->merge_list.next)= ptr;
+ create_info->merge_list.next= &ptr->next_local;
+
+ if (&child_table->next_global == table->child_last_l)
+ break;
+ }
}
*create_info->merge_list.next=0;
}