mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
b092d35f13
If a table is altered using the MDEV-11369/MDEV-15562/MDEV-13134 ALGORITHM=INSTANT, it can force the table to use a non-canonical format: * A hidden metadata record at the start of the clustered index is used to store each column's DEFAULT value. This makes it possible to add new columns that have default values without rebuilding the table. * Starting with MDEV-15562 in MariaDB Server 10.4, a BLOB in the hidden metadata record is used to store column mappings. This makes it possible to drop or reorder columns without rebuilding the table. This also makes it possible to add columns to any position or drop columns from any position in the table without rebuilding the table. If a column is dropped without rebuilding the table, old records will contain garbage in that column's former position, and new records will be written with NULL values, empty strings, or dummy values. This is generally not a problem. However, there may be cases where users may want to avoid putting a table into this format. For example, users may want to ensure that future UPDATE operations after an ADD COLUMN will be performed in-place, to reduce write amplification. (Instantly added columns are essentially always variable-length.) Users might also want to avoid bugs similar to MDEV-19916, or they may want to be able to export tables to older versions of the server. We will introduce the option innodb_instant_alter_column_allowed, with the following values: * never (0): Do not allow instant add/drop/reorder, to maintain format compatibility with MariaDB 10.x and MySQL 5.x. If the table (or partition) is not in the canonical format, then any ALTER TABLE (even one that does not involve instant column operations) will force a table rebuild. * add_last (1, default in 10.3): Store a hidden metadata record that allows columns to be appended to the table instantly (MDEV-11369). In 10.4 or later, if the table (or partition) is not in this format, then any ALTER TABLE (even one that does not involve column changes) will force a table rebuild. Starting with 10.4: * add_drop_reorder (2, default): Like 'add_last', but allow the metadata record to store a column map, to support instant add/drop/reorder of columns (MDEV-15562).
306 lines
10 KiB
Text
306 lines
10 KiB
Text
--- instant_alter.result
|
|
+++ instant_alter,4k.result
|
|
@@ -243,7 +243,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+6
|
|
connection default;
|
|
ROLLBACK;
|
|
connection analyze;
|
|
@@ -253,7 +253,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
BEGIN;
|
|
UPDATE t2 SET d1 = repeat(id, 200);
|
|
@@ -264,7 +264,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
ROLLBACK;
|
|
connection analyze;
|
|
@@ -274,7 +274,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
ALTER TABLE t2 DROP p;
|
|
affected rows: 0
|
|
@@ -322,8 +322,14 @@
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE t3 ADD COLUMN b BLOB NOT NULL;
|
|
+ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1979. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
|
|
+SET innodb_strict_mode = OFF;
|
|
affected rows: 0
|
|
-info: Records: 0 Duplicates: 0 Warnings: 0
|
|
+ALTER TABLE t3 ADD COLUMN b BLOB NOT NULL;
|
|
+affected rows: 0
|
|
+info: Records: 0 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1979). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
INSERT INTO t3 SET id=4;
|
|
ERROR HY000: Field 'c2' doesn't have a default value
|
|
INSERT INTO t3 SET id=4, c2=0, b=0xf09f98b1;
|
|
@@ -336,7 +342,9 @@
|
|
ALTER TABLE t3 CHANGE t phrase TEXT DEFAULT 0xc3a4c3a448,
|
|
CHANGE b b BLOB NOT NULL DEFAULT 'binary line of business';
|
|
affected rows: 4
|
|
-info: Records: 4 Duplicates: 0 Warnings: 0
|
|
+info: Records: 4 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1979). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
INSERT INTO t3 SET id=5, c2=9;
|
|
Warnings:
|
|
Note 1265 Data truncated for column 'c7' at row 1
|
|
@@ -350,7 +358,9 @@
|
|
5 9 POLYGON((1 1,2 2,3 3,1 1)) 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 03:00:42 1970-01-01 ääH binary line of business
|
|
ALTER TABLE t3 DROP c3, DROP c7;
|
|
affected rows: 0
|
|
-info: Records: 0 Duplicates: 0 Warnings: 0
|
|
+info: Records: 0 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1979). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
SELECT * FROM t3;
|
|
id c2 c4 c5 c6 c8 phrase b
|
|
1 1 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 1970-01-01 The quick brown fox jumps over the lazy dog
|
|
@@ -378,6 +388,8 @@
|
|
(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000),
|
|
p POINT NOT NULL DEFAULT ST_GeomFromText('POINT(0 0)'), SPATIAL INDEX(p))
|
|
ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1979). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
BEGIN;
|
|
INSERT INTO big
|
|
SET id=1, c1=REPEAT('a', 200), c2=REPEAT('b', 200), c3=REPEAT('c', 159);
|
|
@@ -395,13 +407,15 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-3
|
|
+8
|
|
connection default;
|
|
ALTER TABLE big ADD COLUMN
|
|
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
|
|
d3 TIMESTAMP NOT NULL DEFAULT current_timestamp ON UPDATE current_timestamp);
|
|
affected rows: 0
|
|
-info: Records: 0 Duplicates: 0 Warnings: 0
|
|
+info: Records: 0 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1979). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
CHECKSUM TABLE big;
|
|
Table Checksum
|
|
test.big 1705165209
|
|
@@ -418,7 +432,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-7
|
|
+28
|
|
connection default;
|
|
ROLLBACK;
|
|
CHECKSUM TABLE big;
|
|
@@ -431,7 +445,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-3
|
|
+8
|
|
connection default;
|
|
InnoDB 0 transactions not purged
|
|
DROP TABLE t1,t2,t3,t4,big;
|
|
@@ -730,7 +744,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+6
|
|
connection default;
|
|
ROLLBACK;
|
|
connection analyze;
|
|
@@ -740,7 +754,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
BEGIN;
|
|
UPDATE t2 SET d1 = repeat(id, 200);
|
|
@@ -751,7 +765,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
ROLLBACK;
|
|
connection analyze;
|
|
@@ -761,7 +775,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
ALTER TABLE t2 DROP p;
|
|
affected rows: 0
|
|
@@ -810,7 +824,9 @@
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE t3 ADD COLUMN b BLOB NOT NULL;
|
|
affected rows: 0
|
|
-info: Records: 0 Duplicates: 0 Warnings: 0
|
|
+info: Records: 0 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
INSERT INTO t3 SET id=4;
|
|
ERROR HY000: Field 'c2' doesn't have a default value
|
|
INSERT INTO t3 SET id=4, c2=0, b=0xf09f98b1;
|
|
@@ -823,7 +839,9 @@
|
|
ALTER TABLE t3 CHANGE t phrase TEXT DEFAULT 0xc3a4c3a448,
|
|
CHANGE b b BLOB NOT NULL DEFAULT 'binary line of business';
|
|
affected rows: 4
|
|
-info: Records: 4 Duplicates: 0 Warnings: 0
|
|
+info: Records: 4 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
INSERT INTO t3 SET id=5, c2=9;
|
|
Warnings:
|
|
Note 1265 Data truncated for column 'c7' at row 1
|
|
@@ -837,7 +855,9 @@
|
|
5 9 POLYGON((1 1,2 2,3 3,1 1)) 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 03:00:42 1970-01-01 ääH binary line of business
|
|
ALTER TABLE t3 DROP c3, DROP c7;
|
|
affected rows: 0
|
|
-info: Records: 0 Duplicates: 0 Warnings: 0
|
|
+info: Records: 0 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
SELECT * FROM t3;
|
|
id c2 c4 c5 c6 c8 phrase b
|
|
1 1 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 1970-01-01 The quick brown fox jumps over the lazy dog
|
|
@@ -865,6 +885,8 @@
|
|
(id INT PRIMARY KEY, c1 VARCHAR(4000), c2 VARCHAR(4000), c3 VARCHAR(1000),
|
|
p POINT NOT NULL DEFAULT ST_GeomFromText('POINT(0 0)'), SPATIAL INDEX(p))
|
|
ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
BEGIN;
|
|
INSERT INTO big
|
|
SET id=1, c1=REPEAT('a', 200), c2=REPEAT('b', 200), c3=REPEAT('c', 159);
|
|
@@ -882,13 +904,15 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-3
|
|
+7
|
|
connection default;
|
|
ALTER TABLE big ADD COLUMN
|
|
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
|
|
d3 TIMESTAMP NOT NULL DEFAULT current_timestamp ON UPDATE current_timestamp);
|
|
affected rows: 0
|
|
-info: Records: 0 Duplicates: 0 Warnings: 0
|
|
+info: Records: 0 Duplicates: 0 Warnings: 1
|
|
+Warnings:
|
|
+Warning 139 Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
|
|
CHECKSUM TABLE big;
|
|
Table Checksum
|
|
test.big 1705165209
|
|
@@ -905,7 +929,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-7
|
|
+23
|
|
connection default;
|
|
ROLLBACK;
|
|
CHECKSUM TABLE big;
|
|
@@ -918,7 +942,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-3
|
|
+7
|
|
connection default;
|
|
InnoDB 0 transactions not purged
|
|
DROP TABLE t1,t2,t3,t4,big;
|
|
@@ -1217,7 +1241,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+6
|
|
connection default;
|
|
ROLLBACK;
|
|
connection analyze;
|
|
@@ -1227,7 +1251,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
BEGIN;
|
|
UPDATE t2 SET d1 = repeat(id, 200);
|
|
@@ -1238,7 +1262,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
ROLLBACK;
|
|
connection analyze;
|
|
@@ -1248,7 +1272,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/t2';
|
|
clust_index_size
|
|
-1
|
|
+4
|
|
connection default;
|
|
ALTER TABLE t2 DROP p;
|
|
affected rows: 0
|
|
@@ -1369,7 +1393,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-3
|
|
+7
|
|
connection default;
|
|
ALTER TABLE big ADD COLUMN
|
|
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
|
|
@@ -1392,7 +1416,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-7
|
|
+23
|
|
connection default;
|
|
ROLLBACK;
|
|
CHECKSUM TABLE big;
|
|
@@ -1405,7 +1429,7 @@
|
|
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
|
WHERE name = 'test/big';
|
|
clust_index_size
|
|
-3
|
|
+7
|
|
connection default;
|
|
InnoDB 0 transactions not purged
|
|
DROP TABLE t1,t2,t3,t4,big;
|
|
@@ -1523,6 +1547,6 @@
|
|
FROM information_schema.global_status
|
|
WHERE variable_name = 'innodb_instant_alter_column';
|
|
instants
|
|
-60
|
|
+61
|
|
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
|
SET GLOBAL innodb_file_format = @saved_format;
|