summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/backup_log.inc
blob: f553a3b9527434317eb1f8e54bddee3d1faa554d (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# This file is used for common DDL log test for both partiotioned
# and non-partitioned tables.
# Parameters:
# $part_int  - partition definition for int field, must be empty for
#              non-partitioned testing
# $part_date - partition definition for date field, must be empty for
#              non-partitioned testing

--echo #
--echo # Testing with normal tables
--echo #

eval create table t1 (a int) engine=myisam $part_int;
insert into t1 values (1),(2);
alter table t1 add column b int;
alter table t1 rename as t2;
rename table t2 to t1;
truncate table t1;
repair table t1;
optimize table t1;
drop table t1;

eval create table t1_innodb (a int) engine=innodb $part_int;
insert into t1_innodb values (1),(2);
alter table t1_innodb add column b int;
alter table t1_innodb rename as t2_innodb;
rename table t2_innodb to t1_innodb;
truncate table t1_innodb;
repair table t1_innodb;
optimize table t1_innodb;
drop table t1_innodb;

--echo #
--echo # Testing with temporary tables (should not be logged)
--echo #

create temporary table tmp_t10 (a int) engine=myisam;
alter table tmp_t10 add column b int;
alter table tmp_t10 rename as tmp_t11;
rename table tmp_t11 to tmp_t10;
truncate table tmp_t10;
drop table tmp_t10;

--echo #
--echo # Testing with mix of normal and temporary tables
--echo #

create temporary table tmp_t20 (a int);
eval create table t20 (a int) $part_int;
drop table tmp_t20,t20;

create temporary table tmp_t21 (a int);
eval create table t21 (a int) $part_int;
drop temporary table if exists tmp_t21,t21;
drop table if exists tmp_t21,t21;

--echo #
--echo # Testing create select
--echo #

eval create table t30 (a int) $part_int;
insert into t30 values (1),(1);
eval create table t31 (a int primary key) $part_int select * from t30 limit 1;
create or replace table t31 select * from t30 limit 1;
create or replace temporary table t30_dup select * from t30 limit 1;
--error ER_DUP_ENTRY
eval create or replace table t31 (a int primary key) $part_int select * from t30;
eval create table t32 (a int) $part_int;
drop table if exists t30,t31,t32,tmp_t30;

--echo #
--echo # Testing create LIKE
--echo #
eval create table t40 (a int) engine=myisam $part_int;
eval create table t41 (a int, b int) engine=innodb $part_int;
create table t42 like t40;
if (!$part_int) {
create temporary table t43_tmp like t40;
}
create or replace table t42 like t41;
show create table t42;
drop table t40, t41, t42;

--echo #
--echo # Testing rename
--echo #

eval create table t50 (a int) $part_int;
eval create table t51 (a int, b int) $part_int;
rename table t50 to t52, t51 to t53;
rename table t52 to tmp, t53 to t52, tmp to t53;
drop table t52,t53;

--echo #
--echo # Testing enable/disable keys
--echo #

eval CREATE TABLE t60 (a int(10), index(a) ) ENGINE=Aria $part_int;
INSERT INTO t60 VALUES(1),(2),(3);
ALTER TABLE t60 DISABLE KEYS;
INSERT INTO t60 VALUES(4),(5),(6);
ALTER TABLE t60 ENABLE KEYS;
DROP TABLE t60;

CREATE TEMPORARY TABLE t61 (i int(10), index(i) ) ENGINE=Aria;
INSERT INTO t61 VALUES(1),(2),(3);
ALTER TABLE t61 DISABLE KEYS;
DROP TABLE t61;

--echo #
--echo # Testing load data
--echo #

eval create table t70 (a date, b date, c date not null, d date) engine=aria $part_date;
--disable_warnings
load data infile '../../std_data/loaddata1.dat' ignore into table t70 fields terminated by ',';
load data infile '../../std_data/loaddata1.dat' ignore into table t70 fields terminated by ',';
truncate table t70;
lock table t70 write;
load data infile '../../std_data/loaddata1.dat' ignore into table t70 fields terminated by ',';
load data infile '../../std_data/loaddata1.dat' ignore into table t70 fields terminated by ',';
unlock tables;
--enable_warnings

eval create table t71 (a date, b date, c date not null, d date) engine=aria $part_date;
lock tables t71 write, t70 read;
insert into t71 select * from t70;
unlock tables;
drop table t70,t71;

--echo #
--echo # Testing strange table names
--echo #

eval create table `t 1` (a int) $part_int;
drop table `t 1`;

--echo #
--echo # Testing views and triggers
--echo #

eval create table t80 (a int, b int) engine=myisam $part_int;
create view v1 as select * from t80;
create trigger trg before insert on t80 for each row set @b:=1;
drop trigger trg;
drop view v1;
drop table t80;

--echo #
--echo # Testing alter to a new storage engine
--echo #

eval create table t85 (a int primary key, b int) engine=myisam $part_int;
alter table t85 engine=innodb;
drop table t85;