1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#
# Check CREATE OR REPLACE TABLE for test that requires DEBUG
#
--source include/have_debug.inc
--source include/have_binlog_format_row.inc
--source include/have_innodb.inc
--source include/master-slave.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
SET @old_debug= @@session.debug;
#
# MDEV-5854
# Interrupted CREATE OR REPLACE is written into binlog, and in a wrong format
#
CREATE TABLE t1 (i INT, KEY(i)) ENGINE=InnoDB;
CREATE OR REPLACE TEMPORARY TABLE tmp (a int, b int, key(a)) engine=myisam;
SET debug_dbug='+d,send_kill_after_delete';
CREATE OR REPLACE TABLE t1 LIKE tmp;
SET debug_dbug=@old_debug;
SHOW TABLES;
show create table t1;
--sync_slave_with_master
SHOW TABLES;
show create table t1;
--connection master
--disable_warnings
drop temporary table if exists tmp;
--enable_warnings
drop table t1;
--source include/rpl_end.inc
--echo #
--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE
--echo #
set @saved_debug_dbug= @@session.debug_dbug;
create table t1 (a int primary key) engine innodb;
insert t1 values (1), (2);
create table t2 (c int, a int constraint t1_a references t1 (a)) engine innodb;
insert into t2 values (2, 2);
lock tables t2 write, t1 write;
set session debug_dbug= '+d,atomic_replace_external_lock_fail';
--error ER_LOCK_TABLE_FULL
create or replace table t2 (y int) as select * from t1;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--list_files $MYSQLD_DATADIR/test *sql*
show create table t1;
show create table t2;
select * from t2;
unlock tables;
drop tables t2, t1;
set session debug_dbug= @saved_debug_dbug;
--echo # Test entry_pos in higher position, so drop chain executes before create chain
--echo # (see commit message: On linking two chains together)
create table t1 (c int);
--error ER_DUP_KEYNAME
create or replace table t1 (a int, b int, key k (a), key k (b));
--error ER_DUP_KEYNAME
create or replace table t1 (a int, b int, key k (a), key k (b));
drop table t1;
--echo #
--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES
--echo #
--echo # Non-atomic CREATE OR REPLACE part:
--echo #
set @saved_debug_dbug= @@session.debug_dbug;
set @@debug_dbug="+d,ddl_log_expensive_rename";
create table t1 (pk int primary key) engine=innodb;
create or replace table t2 (a int primary key references t1 (pk)) engine=innodb;
lock tables t1 write, t2 write;
--error ER_DUP_FIELDNAME
create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb;
select * from t1;
--error ER_TABLE_NOT_LOCKED
select * from t2;
unlock tables;
drop tables t1;
set @@debug_dbug= @saved_debug_dbug;
|