mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
b5615eff0d
Idea comes from MySQL which does something similar
66 lines
2 KiB
Text
66 lines
2 KiB
Text
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
|
|
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
|
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
|
|
DROP TABLE foo;
|
|
InnoDB 0 transactions not purged
|
|
SET GLOBAL innodb_purge_rseg_truncate_frequency=@saved_frequency;
|
|
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;
|