File tree 3 files changed +52
-2
lines changed
3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change
1
+ drop table if exists t1, t2;
2
+ CREATE TABLE t1 ( a int );
3
+ INSERT INTO t1 VALUES (1),(2),(1);
4
+ CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
5
+ Duplicate entry '1' for key 1
6
+ select * from t2;
7
+ Table 'test.t2' doesn't exist
8
+ CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
9
+ Duplicate entry '1' for key 1
10
+ select * from t2;
11
+ Table 'test.t2' doesn't exist
12
+ CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
13
+ Duplicate entry '1' for key 1
14
+ select * from t2;
15
+ Table 'test.t2' doesn't exist
16
+ CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
17
+ Duplicate entry '1' for key 1
18
+ select * from t2;
19
+ Table 'test.t2' doesn't exist
Original file line number Diff line number Diff line change
1
+ # Testcase for BUG#4551
2
+ # The bug was that when the table was TEMPORARY, it was not deleted if
3
+ # the CREATE SELECT failed (the code intended too, but it actually
4
+ # didn't). And as the CREATE TEMPORARY TABLE was not written to the
5
+ # binlog if it was a transactional table, it resulted in an
6
+ # inconsistency between binlog and the internal list of temp tables.
7
+
8
+ -- source include/have_innodb.inc
9
+ drop table if exists t1, t2;
10
+ CREATE TABLE t1 ( a int );
11
+ INSERT INTO t1 VALUES (1),(2),(1);
12
+ --error 1062;
13
+ CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
14
+ --error 1146;
15
+ select * from t2;
16
+ --error 1062;
17
+ CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=INNODB SELECT a FROM t1;
18
+ --error 1146;
19
+ select * from t2;
20
+ --error 1062;
21
+ CREATE TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
22
+ --error 1146;
23
+ select * from t2;
24
+ --error 1062;
25
+ CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) TYPE=MYISAM SELECT a FROM t1;
26
+ --error 1146;
27
+ select * from t2;
Original file line number Diff line number Diff line change @@ -1545,9 +1545,13 @@ void select_create::abort()
1545
1545
table->file ->extra (HA_EXTRA_NO_IGNORE_DUP_KEY);
1546
1546
enum db_type table_type=table->db_type ;
1547
1547
if (!table->tmp_table )
1548
+ {
1548
1549
hash_delete (&open_cache,(byte*) table);
1549
- if (!create_info->table_existed )
1550
- quick_rm_table (table_type,db,name);
1550
+ if (!create_info->table_existed )
1551
+ quick_rm_table (table_type, db, name);
1552
+ }
1553
+ else if (!create_info->table_existed )
1554
+ close_temporary_table (thd, db, name);
1551
1555
table=0 ;
1552
1556
}
1553
1557
VOID (pthread_mutex_unlock (&LOCK_open));
You can’t perform that action at this time.
0 commit comments