1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

A fix and a test case for Bug#36171 "CREATE TEMPORARY TABLE and

MERGE engine".
Backport the patch from 6.0 by Ingo Struewing:
revid:ingo.struewing@sun.com-20091028183659-6kmv1k3gdq6cpg4d
Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine

In former MySQL versions, up to 5.1.23/6.0.4 it was possible to create
temporary MERGE tables with non-temporary MyISAM tables.
        
This has been changed in the mentioned version due to Bug 19627
(temporary merge table locking). MERGE children were locked through
the parent table. If the parent was temporary, it was not locked and
so the children were not locked either. Parallel use of the MyISAM
tables corrupted them.
       
Since 6.0.6 (WL 4144 - Lock MERGE engine children), the children are
locked independently from the parent. Now it is possible to allow
non-temporary children with a temporary parent. Even though the
temporary MERGE table itself is not locked, each non-temporary
MyISAM table is locked anyway.
        
NOTE: Behavior change: In 5.1.23/6.0.4 we prohibited non-temporary
children with a temporary MERGE table. Now we re-allow it.
An important side-effect is that temporary tables, which overlay
non-temporary MERGE children, overlay the children in the MERGE table.


mysql-test/r/merge.result:
  Update results (Bug#36171).
mysql-test/r/merge_mmap.result:
  Update results (Bug#36171).
mysql-test/t/merge.test:
  Add tests for Bug#36171
mysql-test/t/merge_mmap.test:
  Add tests for Bug#36171.
storage/myisammrg/ha_myisammrg.cc:
  Changed constraint for temporary state of tables.
This commit is contained in:
Konstantin Osipov
2010-07-02 20:07:57 +04:00
parent 1afe6ff03a
commit 05617af025
5 changed files with 1291 additions and 22 deletions

View File

@ -1,3 +1,5 @@
set global storage_engine=myisam;
set session storage_engine=myisam;
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
create table t1 (a int not null primary key auto_increment, message char(20));
@ -584,7 +586,9 @@ INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t1,t2);
SELECT * FROM t3;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
c1
1
2
CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL);
CREATE TEMPORARY TABLE t5 (c1 INT NOT NULL);
INSERT INTO t4 VALUES (4);
@ -613,7 +617,9 @@ ERROR HY000: Unable to open underlying table which is differently defined or of
drop table t3;
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
select * from t3;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
a
1
2
drop table t3, t2, t1;
# CREATE...SELECT is not implemented for MERGE tables.
CREATE TEMPORARY TABLE t1 (c1 INT NOT NULL);
@ -1196,12 +1202,13 @@ ERROR HY000: Table 't4' was not locked with LOCK TABLES
# it can even be used.
CREATE TEMPORARY TABLE t4 LIKE t3;
SHOW CREATE TABLE t4;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
Table Create Table
t4 CREATE TEMPORARY TABLE `t4` (
`c1` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
INSERT INTO t4 VALUES (4);
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
UNLOCK TABLES;
INSERT INTO t4 VALUES (4);
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t4;
#
# Rename child.
@ -1229,6 +1236,8 @@ c1
2
3
4
4
4
RENAME TABLE t2 TO t5;
SELECT * FROM t3 ORDER BY c1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
@ -1239,6 +1248,8 @@ c1
2
3
4
4
4
#
# 3. Normal rename with locked tables.
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
@ -1248,6 +1259,8 @@ c1
2
3
4
4
4
RENAME TABLE t2 TO t5;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@ -1256,6 +1269,8 @@ c1
2
3
4
4
4
RENAME TABLE t5 TO t2;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@ -1264,6 +1279,8 @@ c1
2
3
4
4
4
UNLOCK TABLES;
#
# 4. Alter table rename.
@ -1277,6 +1294,8 @@ c1
2
3
4
4
4
#
# 5. Alter table rename with locked tables.
LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
@ -1293,6 +1312,8 @@ c1
2
3
4
4
4
#
# Rename parent.
#
@ -1304,6 +1325,8 @@ c1
2
3
4
4
4
RENAME TABLE t3 TO t5;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@ -1312,6 +1335,8 @@ c1
2
3
4
4
4
RENAME TABLE t5 TO t3;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
SELECT * FROM t3 ORDER BY c1;
@ -1320,6 +1345,8 @@ c1
2
3
4
4
4
#
# 5. Alter table rename with locked tables.
ALTER TABLE t3 RENAME TO t5;
@ -1335,6 +1362,8 @@ c1
2
3
4
4
4
DROP TABLE t1, t2, t3;
#
# Drop locked tables.
@ -2650,6 +2679,705 @@ test.t1 optimize Error Unable to open underlying table which is differently defi
test.t1 optimize note The storage engine for the table doesn't support optimize
DROP TABLE t1;
#
# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
# More tests with TEMPORARY MERGE table and permanent children.
# First without locked tables.
#
DROP TABLE IF EXISTS t1, t2, t3, t4, m1, m2;
#
CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
INSERT_METHOD=LAST;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m1;
c1 c2
INSERT INTO t1 VALUES (111, 121);
INSERT INTO m1 VALUES (211, 221);
SELECT * FROM m1;
c1 c2
111 121
211 221
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
#
ALTER TABLE m1 RENAME m2;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m2;
c1 c2
111 121
211 221
#
CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
INSERT_METHOD=LAST;
ALTER TABLE m2 RENAME m1;
ERROR 42S01: Table 'm1' already exists
DROP TABLE m1;
ALTER TABLE m2 RENAME m1;
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m1;
c1 c2
111 121
211 221
#
ALTER TABLE m1 ADD COLUMN c3 INT;
INSERT INTO m1 VALUES (212, 222, 232);
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
ALTER TABLE t1 ADD COLUMN c3 INT;
ALTER TABLE t2 ADD COLUMN c3 INT;
INSERT INTO m1 VALUES (212, 222, 232);
SELECT * FROM m1;
c1 c2 c3
111 121 NULL
211 221 NULL
212 222 232
#
ALTER TABLE m1 DROP COLUMN c3;
INSERT INTO m1 VALUES (213, 223);
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
ALTER TABLE t1 DROP COLUMN c3;
ALTER TABLE t2 DROP COLUMN c3;
INSERT INTO m1 VALUES (213, 223);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
#
CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
ALTER TABLE m1 UNION=(t1,t2,t3);
INSERT INTO m1 VALUES (311, 321);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
311 321
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
212 222
213 223
SELECT * FROM t3;
c1 c2
311 321
#
CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
ALTER TABLE m1 UNION=(t1,t2,t3,t4);
INSERT INTO m1 VALUES (411, 421);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
311 321
411 421
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
212 222
213 223
SELECT * FROM t3;
c1 c2
311 321
SELECT * FROM t4;
c1 c2
411 421
#
ALTER TABLE m1 ENGINE=MyISAM;
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO m1 VALUES (511, 521);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
311 321
411 421
511 521
#
ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
INSERT_METHOD=LAST;
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
212 222
213 223
#
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (611, 621);
SELECT * FROM m1;
c1 c2
611 621
211 221
212 222
213 223
DROP TABLE t1;
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
#
#
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
#
CREATE TABLE m2 SELECT * FROM m1;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
DROP TABLE m2;
#
CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
DROP TABLE m2;
#
CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST;
SELECT * FROM m2;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE m2;
#
CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST SELECT * FROM m1;
ERROR HY000: 'test.m2' is not BASE TABLE
#
CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST SELECT * FROM m1;
ERROR HY000: 'test.m2' is not BASE TABLE
#
CREATE TABLE m2 LIKE m1;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
INSERT INTO m2 SELECT * FROM m1;
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
DROP TABLE m2;
#
CREATE TEMPORARY TABLE m2 LIKE m1;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
INSERT INTO m2 SELECT * FROM m1;
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
DROP TABLE m2;
#
CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST;
INSERT INTO m2 SELECT * FROM m1;
SELECT * FROM m2;
c1 c2
311 321
411 421
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
#
#
LOCK TABLE m1 WRITE, m2 WRITE;
SELECT * FROM m1,m2 WHERE m1.c1=m2.c1;
c1 c2 c1 c2
111 121 111 121
111 121 111 121
111 121 111 121
111 121 111 121
211 221 211 221
211 221 211 221
211 221 211 221
211 221 211 221
212 222 212 222
212 222 212 222
212 222 212 222
212 222 212 222
213 223 213 223
213 223 213 223
213 223 213 223
213 223 213 223
111 121 111 121
111 121 111 121
111 121 111 121
111 121 111 121
211 221 211 221
211 221 211 221
211 221 211 221
211 221 211 221
212 222 212 222
212 222 212 222
212 222 212 222
212 222 212 222
213 223 213 223
213 223 213 223
213 223 213 223
213 223 213 223
111 121 111 121
111 121 111 121
111 121 111 121
111 121 111 121
211 221 211 221
211 221 211 221
211 221 211 221
211 221 211 221
212 222 212 222
212 222 212 222
212 222 212 222
212 222 212 222
213 223 213 223
213 223 213 223
213 223 213 223
213 223 213 223
111 121 111 121
111 121 111 121
111 121 111 121
111 121 111 121
211 221 211 221
211 221 211 221
211 221 211 221
211 221 211 221
212 222 212 222
212 222 212 222
212 222 212 222
212 222 212 222
213 223 213 223
213 223 213 223
213 223 213 223
213 223 213 223
UNLOCK TABLES;
DROP TABLE t1, t2, t3, t4, m1, m2;
#
# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
# More tests with TEMPORARY MERGE table and permanent children.
# (continued) Now the same with locked table.
#
CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
INSERT_METHOD=LAST;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m1;
c1 c2
INSERT INTO t1 VALUES (111, 121);
INSERT INTO m1 VALUES (211, 221);
SELECT * FROM m1;
c1 c2
111 121
211 221
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
#
LOCK TABLE m1 WRITE, t1 WRITE, t2 WRITE;
#
ALTER TABLE m1 RENAME m2;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m2;
c1 c2
111 121
211 221
#
CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
INSERT_METHOD=LAST;
ALTER TABLE m2 RENAME m1;
ERROR 42S01: Table 'm1' already exists
DROP TABLE m1;
ALTER TABLE m2 RENAME m1;
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m1;
c1 c2
111 121
211 221
#
ALTER TABLE m1 ADD COLUMN c3 INT;
INSERT INTO m1 VALUES (212, 222, 232);
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
ALTER TABLE t1 ADD COLUMN c3 INT;
ALTER TABLE t2 ADD COLUMN c3 INT;
INSERT INTO m1 VALUES (212, 222, 232);
SELECT * FROM m1;
c1 c2 c3
111 121 NULL
211 221 NULL
212 222 232
#
ALTER TABLE m1 DROP COLUMN c3;
INSERT INTO m1 VALUES (213, 223);
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
ALTER TABLE t1 DROP COLUMN c3;
ALTER TABLE t2 DROP COLUMN c3;
INSERT INTO m1 VALUES (213, 223);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
#
UNLOCK TABLES;
CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
ALTER TABLE m1 UNION=(t1,t2,t3);
LOCK TABLE m1 WRITE;
INSERT INTO m1 VALUES (311, 321);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
311 321
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
212 222
213 223
SELECT * FROM t3;
c1 c2
311 321
#
CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
ALTER TABLE m1 UNION=(t1,t2,t3,t4);
INSERT INTO m1 VALUES (411, 421);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
311 321
411 421
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
212 222
213 223
SELECT * FROM t3;
c1 c2
311 321
SELECT * FROM t4;
c1 c2
411 421
#
ALTER TABLE m1 ENGINE=MyISAM;
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO m1 VALUES (511, 521);
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
311 321
411 421
511 521
#
ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
INSERT_METHOD=LAST;
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
SELECT * FROM t1;
c1 c2
111 121
SELECT * FROM t2;
c1 c2
211 221
212 222
213 223
#
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (611, 621);
SELECT * FROM m1;
c1 c2
611 621
211 221
212 222
213 223
DROP TABLE t1;
SELECT * FROM m1;
c1 c2
111 121
211 221
212 222
213 223
#
#
SHOW CREATE TABLE m1;
Table Create Table
m1 CREATE TEMPORARY TABLE `m1` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
CREATE TABLE m2 SELECT * FROM m1;
ERROR HY000: Table 'm2' was not locked with LOCK TABLES
#
CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
DROP TABLE m2;
#
CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST;
SELECT * FROM m2;
c1 c2
311 321
411 421
LOCK TABLE m1 WRITE, m2 WRITE;
UNLOCK TABLES;
DROP TABLE m2;
LOCK TABLE m1 WRITE;
#
# ER_TABLE_NOT_LOCKED is returned in ps-protocol
CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST SELECT * FROM m1;
Got one of the listed errors
#
CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST SELECT * FROM m1;
ERROR HY000: 'test.m2' is not BASE TABLE
#
CREATE TEMPORARY TABLE m2 LIKE m1;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
LOCK TABLE m1 WRITE, m2 WRITE;
SHOW CREATE TABLE m2;
Table Create Table
m2 CREATE TEMPORARY TABLE `m2` (
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
INSERT INTO m2 SELECT * FROM m1;
SELECT * FROM m2;
c1 c2
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
DROP TABLE m2;
#
CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
INSERT_METHOD=LAST;
LOCK TABLE m1 WRITE, m2 WRITE;
INSERT INTO m2 SELECT * FROM m1;
SELECT * FROM m2;
c1 c2
311 321
411 421
111 121
211 221
212 222
213 223
111 121
211 221
212 222
213 223
#
UNLOCK TABLES;
DROP TABLE t1, t2, t3, t4, m1, m2;
#
# Bug47098 assert in MDL_context::destroy on HANDLER
# <damaged merge table> OPEN
#