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
|
SET GLOBAL innodb_stats_persistent = 0;
FLUSH TABLES;
#
# MDEV-11369: Instant ADD COLUMN for InnoDB
# MDEV-15562: Instant DROP COLUMN or changing the order of columns
#
connect to_be_killed, localhost, root;
SET @old_instant=
(SELECT variable_value FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column');
CREATE TABLE empty (id INT PRIMARY KEY, c2 INT UNIQUE) ENGINE=InnoDB;
CREATE TABLE once LIKE empty;
CREATE TABLE twice LIKE empty;
CREATE TABLE thrice LIKE empty;
INSERT INTO once SET id=1,c2=1;
INSERT INTO twice SET id=1,c2=1;
INSERT INTO thrice SET id=1,c2=1;
ALTER TABLE empty ADD COLUMN (d1 INT DEFAULT 15);
ALTER TABLE once ADD COLUMN (d1 INT DEFAULT 20);
ALTER TABLE twice ADD COLUMN (d1 INT DEFAULT 20);
ALTER TABLE thrice ADD COLUMN (d1 INT DEFAULT 20);
ALTER TABLE twice ADD COLUMN
(d2 INT NOT NULL DEFAULT 10,
d3 VARCHAR(15) NOT NULL DEFAULT 'var och en char');
ALTER TABLE thrice ADD COLUMN
(d2 INT NOT NULL DEFAULT 10,
d3 TEXT NOT NULL DEFAULT 'con');
ALTER TABLE thrice DROP c2, DROP d3, CHANGE d2 d3 INT NOT NULL FIRST;
SELECT variable_value-@old_instant instants
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
7
BEGIN;
INSERT INTO empty set id=0,c2=42;
UPDATE once set c2=c2+1;
UPDATE twice set c2=c2+1;
UPDATE thrice set d3=d3+1;
INSERT INTO twice SET id=2,c2=0,d3='';
INSERT INTO thrice SET id=2,d3=0;
DELETE FROM empty;
DELETE FROM once;
DELETE FROM twice;
DELETE FROM thrice;
connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
CREATE TABLE foo(a INT PRIMARY KEY) ENGINE=InnoDB;
# Kill the server
disconnect to_be_killed;
# restart
DROP TABLE foo;
InnoDB 0 transactions not purged
SELECT * FROM empty;
id c2 d1
SELECT * FROM once;
id c2 d1
1 1 20
SELECT * FROM twice;
id c2 d1 d2 d3
1 1 20 10 var och en char
SELECT * FROM thrice;
d3 id d1
10 1 20
DROP TABLE empty, once, twice, thrice;
|