- Fixed the position of column reorder during drop column.

- Changed the metadata row format by adding number of null bytes in the record.
- Changed the checking condition for instant alter in check_if_supported_inplace_alter()
- Fixed the instant_alter test case
parent 4fb39f1d
--- instant_alter.result
+++ instant_alter,8k.result
--- instant_alter.result 2018-09-19 21:48:19.370042564 +0530
+++ instant_alter.reject 2018-09-19 21:53:12.050032986 +0530
@@ -240,7 +240,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+5
-5
+1
connection default;
ROLLBACK;
connection analyze;
......@@ -13,8 +13,8 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
-3
+1
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
......@@ -22,8 +22,8 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
-3
+1
connection default;
ROLLBACK;
connection analyze;
......@@ -31,161 +31,98 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -374,7 +374,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -397,7 +397,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
+13
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -410,7 +410,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -600,7 +600,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+5
connection default;
ROLLBACK;
connection analyze;
@@ -610,7 +610,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -621,7 +621,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
connection default;
ROLLBACK;
connection analyze;
@@ -631,7 +631,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
+1
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -734,7 +734,7 @@
@@ -390,7 +390,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
-5
+3
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -757,7 +757,7 @@
@@ -413,7 +413,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
+13
-13
+7
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -770,7 +770,7 @@
@@ -426,7 +426,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
-5
+3
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -960,7 +960,7 @@
DROP TABLE t1,t2,t3,t4,big;
@@ -657,7 +657,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+5
-5
+1
connection default;
ROLLBACK;
connection analyze;
@@ -970,7 +970,7 @@
@@ -667,7 +667,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
-3
+1
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -981,7 +981,7 @@
@@ -678,7 +678,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
-3
+1
connection default;
ROLLBACK;
connection analyze;
@@ -991,7 +991,7 @@
@@ -688,7 +688,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
+3
-3
+1
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -1094,7 +1094,7 @@
@@ -807,7 +807,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
-5
+3
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -1117,7 +1117,7 @@
@@ -830,7 +830,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
+13
-13
+7
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -1130,7 +1130,7 @@
@@ -843,7 +843,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
+5
-5
+3
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
DROP TABLE t1,t2,t3,t4,big;
--- instant_alter.result
+++ instant_alter,32k.result
--- instant_alter.result 2018-09-19 21:48:19.370042564 +0530
+++ instant_alter.reject 2018-09-19 21:48:32.633985253 +0530
@@ -2,7 +2,7 @@
# MDEV-11369: Instant ADD COLUMN for InnoDB
#
......@@ -30,84 +30,129 @@
DROP TABLE t;
connect analyze, localhost, root;
connection default;
@@ -374,7 +374,7 @@
@@ -240,7 +240,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-5
+1
connection default;
ROLLBACK;
connection analyze;
@@ -250,7 +250,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -397,7 +397,7 @@
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -261,7 +261,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-7
+5
-3
+1
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -410,7 +410,7 @@
connection analyze;
@@ -271,7 +271,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -734,7 +734,7 @@
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -390,7 +390,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+1
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -757,7 +757,7 @@
@@ -413,7 +413,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
-13
+5
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -770,7 +770,7 @@
@@ -426,7 +426,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+1
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -1094,7 +1094,7 @@
DROP TABLE t1,t2,t3,t4,big;
@@ -657,7 +657,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-5
+1
connection default;
ROLLBACK;
connection analyze;
@@ -667,7 +667,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -678,7 +678,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
ROLLBACK;
connection analyze;
@@ -688,7 +688,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -807,7 +807,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-5
+1
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -1117,7 +1117,7 @@
@@ -830,7 +830,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
-13
+5
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -1130,7 +1130,7 @@
@@ -843,7 +843,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+1
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
DROP TABLE t1,t2,t3,t4,big;
--- instant_alter.result
+++ instant_alter,4k.result
@@ -181,7 +181,7 @@
--- instant_alter.result 2018-09-19 21:48:19.370042564 +0530
+++ instant_alter.reject 2018-09-19 21:53:49.490207525 +0530
@@ -240,7 +240,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-5
+6
connection default;
ROLLBACK;
......@@ -13,7 +13,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-3
+4
connection default;
BEGIN;
......@@ -22,7 +22,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-3
+4
connection default;
ROLLBACK;
......@@ -31,161 +31,98 @@
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
@@ -374,7 +374,7 @@
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',
@@ -397,7 +397,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;
@@ -410,7 +410,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,big;
@@ -600,7 +600,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;
@@ -610,7 +610,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);
@@ -621,7 +621,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;
@@ -631,7 +631,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
@@ -734,7 +734,7 @@
@@ -390,7 +390,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+7
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -757,7 +757,7 @@
@@ -413,7 +413,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
-13
+23
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -770,7 +770,7 @@
@@ -426,7 +426,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+7
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -960,7 +960,7 @@
DROP TABLE t1,t2,t3,t4,big;
@@ -657,7 +657,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-5
+6
connection default;
ROLLBACK;
connection analyze;
@@ -970,7 +970,7 @@
@@ -667,7 +667,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-3
+4
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -981,7 +981,7 @@
@@ -678,7 +678,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-3
+4
connection default;
ROLLBACK;
connection analyze;
@@ -991,7 +991,7 @@
@@ -688,7 +688,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-1
-3
+4
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -1094,7 +1094,7 @@
@@ -807,7 +807,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+7
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -1117,7 +1117,7 @@
@@ -830,7 +830,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
-13
+23
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -1130,7 +1130,7 @@
@@ -843,7 +843,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+7
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
DROP TABLE t1,t2,t3,t4,big;
--- instant_alter.result
+++ instant_alter,64k.result
--- instant_alter.result 2018-09-19 21:48:19.370042564 +0530
+++ instant_alter.reject 2018-09-19 21:52:31.729867852 +0530
@@ -2,7 +2,7 @@
# MDEV-11369: Instant ADD COLUMN for InnoDB
#
......@@ -30,84 +30,129 @@
DROP TABLE t;
connect analyze, localhost, root;
connection default;
@@ -374,7 +374,7 @@
@@ -240,7 +240,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-5
+1
connection default;
ROLLBACK;
connection analyze;
@@ -250,7 +250,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -397,7 +397,7 @@
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -261,7 +261,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-7
+3
-3
+1
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -410,7 +410,7 @@
connection analyze;
@@ -271,7 +271,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -734,7 +734,7 @@
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -390,7 +390,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+1
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -757,7 +757,7 @@
@@ -413,7 +413,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
-13
+3
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -770,7 +770,7 @@
@@ -426,7 +426,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+1
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
@@ -1094,7 +1094,7 @@
DROP TABLE t1,t2,t3,t4,big;
@@ -657,7 +657,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
WHERE name = 'test/t2';
clust_index_size
-5
+1
connection default;
ROLLBACK;
connection analyze;
@@ -667,7 +667,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
BEGIN;
UPDATE t2 SET d1 = repeat(id, 200);
@@ -678,7 +678,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
ROLLBACK;
connection analyze;
@@ -688,7 +688,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/t2';
clust_index_size
-3
+1
connection default;
ALTER TABLE t2 DROP p;
affected rows: 0
@@ -807,7 +807,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-5
+1
connection default;
ALTER TABLE big ADD COLUMN
(d1 INT DEFAULT 0, d2 VARCHAR(20) DEFAULT 'abcde',
@@ -1117,7 +1117,7 @@
@@ -830,7 +830,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-7
-13
+3
connection default;
ROLLBACK;
CHECKSUM TABLE big;
@@ -1130,7 +1130,7 @@
@@ -843,7 +843,7 @@
SELECT clust_index_size FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE name = 'test/big';
clust_index_size
-3
-5
+1
connection default;
InnoDB 0 transactions not purged
DROP TABLE t1,t2,t3,big;
DROP TABLE t1,t2,t3,t4,big;
......@@ -614,15 +614,6 @@ dtuple_convert_big_rec(
ut_ad(index->n_uniq > 0);
if (!dict_table_has_atomic_blobs(index->table)) {
/* up to MySQL 5.1: store a 768-byte prefix locally */
local_len = BTR_EXTERN_FIELD_REF_SIZE
+ DICT_ANTELOPE_MAX_INDEX_COL_LEN;
} else {
/* new-format table: do not store any BLOB prefix locally */
local_len = BTR_EXTERN_FIELD_REF_SIZE;
}
ut_a(dtuple_check_typed_no_assert(entry));
size = rec_get_converted_size(index, entry, *n_ext);
......@@ -651,9 +642,19 @@ dtuple_convert_big_rec(
dfield = dtuple_get_nth_field(entry, longest_i);
dfield->data = index->table->construct_metadata_blob(
heap, &dfield->len);
local_len = BTR_EXTERN_FIELD_REF_SIZE;
goto ext_write;
}
if (!dict_table_has_atomic_blobs(index->table)) {
/* up to MySQL 5.1: store a 768-byte prefix locally */
local_len = BTR_EXTERN_FIELD_REF_SIZE
+ DICT_ANTELOPE_MAX_INDEX_COL_LEN;
} else {
/* new-format table: do not store any BLOB prefix locally */
local_len = BTR_EXTERN_FIELD_REF_SIZE;
}
while (page_zip_rec_needs_ext(rec_get_converted_size(index, entry,
*n_ext),
dict_table_is_comp(index->table),
......
......@@ -1364,12 +1364,10 @@ non-drop nullable fields and fill the drop columns in the vector.
@param[in] blob_data blob data which contains
drop column information
@param[out] non_pk_fields number of non-primary key fields
@param[out] non_drop_nullable_fieldsnumber of non-drop nullable fields
@param[out] dropped_col_list dropped column list */
void dict_table_t::read_metadata_blob(
byte* blob_data,
ulint* non_pk_fields,
ulint* non_drop_nullable_fields,
std::vector<ulint>& dropped_col_list)
{
*non_pk_fields = mach_read_from_4(blob_data);
......@@ -1384,13 +1382,6 @@ void dict_table_t::read_metadata_blob(
if (col_no == 0) {
dropped_col_list.push_back(i);
} else {
dict_field_t* field = dict_index_get_nth_field(
clust_index, (i + n_pk_fields));
if (field->col->is_nullable()) {
(*non_drop_nullable_fields)++;
}
}
field_data += INSTANT_FIELD_LEN;
......
......@@ -1256,6 +1256,11 @@ ha_innobase::check_if_supported_inplace_alter(
}
if (f) {
if (n_add_cols > 0) {
add_column_not_last = true;
}
/* This could be changing an existing column
from NULL to NOT NULL. */
switch ((*af)->type()) {
......@@ -1326,7 +1331,7 @@ ha_innobase::check_if_supported_inplace_alter(
}
/** Last few columns are dropped. */
while (*uf++ != NULL) {
while (uf++ < uf_end) {
n_drop_cols++;
}
......@@ -1346,6 +1351,14 @@ ha_innobase::check_if_supported_inplace_alter(
is_instant = true;
}
ulint n_exist_cols = uint(m_prebuilt->table->n_cols) - DATA_N_SYS_COLS;
n_exist_cols += n_add_cols;
n_exist_cols -= n_drop_cols;
if (is_instant && n_exist_cols != n_stored_cols) {
is_instant = false;
}
if (is_instant
|| !(ha_alter_info->handler_flags & ~(INNOBASE_ALTER_INSTANT
| INNOBASE_INPLACE_IGNORE))) {
......@@ -4433,7 +4446,12 @@ innobase_op_instant_try(
Field** uf = table->field;
Field** const uf_end = table->field + table->s->fields;
bool update_pos = false;
for (ulint i = 0; uf < uf_end; uf++) {
if (!(*uf)->stored_in_db()) {
continue;
}
if (ctx->col_map[i] == ULINT_UNDEFINED) {
/* Remove this column entry from sys_column */
......@@ -4442,13 +4460,11 @@ innobase_op_instant_try(
return true;
}
/* Update the consecutive position of the columns. */
for (ulint j = i + 1; j < ctx->old_n_cols; j++) {
if (innobase_instant_update_pos(
user_table->id, j, j-1, trx)) {
return true;
}
update_pos = true;
} else if (update_pos) {
if (innobase_instant_update_pos(
user_table->id, i, i - 1, trx)) {
return true;
}
}
......
......@@ -1686,12 +1686,10 @@ struct dict_table_t {
@param[in] blob_data blob data which contains
drop column information
@param[out] non_pk_fields number of non-primary key fields
@param[out] non_drop_nullable_fields number of non-drop nullable fields
@param[out] dropped_col_list dropped column list */
void read_metadata_blob(
byte* blob_data,
ulint* non_pk_fields,
ulint* non_drop_nullable_fields,
std::vector<ulint>& dropped_col_list);
/** Construct the blob with contains the non-primary key for
......
......@@ -581,7 +581,7 @@ rec_offs_validate(
}
#endif /* UNIV_DEBUG */
/** Determine the offsets to each field in the metadata record.
/** Determine the offsets to each field for the metadata record.
The offsets are written to a previously allocated array of
ulint, where rec_offs_n_fields(offsets) has been initialized to the
number of fields in the record. The rest of the array will be
......@@ -596,114 +596,58 @@ fields 1..n_fields+1. When the high-order bit of the offset at [i+1]
is set (REC_OFFS_SQL_NULL), the field i is NULL. When the second
high-order bit of the offset at [i+1] is set (REC_OFFS_EXTERNAL), the
field i is being stored externally.
@param[in] rec record
@param[in] index the index that the record belongs in
@param[in,out] offsets array of offsets, with valid rec_offs_n_fields() */
@param[in] rec record
@param[in] index the index that the record belongs in
@param[in] limit get offset upto this limit
@param[in] n_exist_fields number of existing fields
@param[in] dropped_cols dropped columns list
@param[in,out] offsets array of offsets, with valid rec_offs_n_fields() */
static
void
rec_init_offsets_for_metadata(
rec_init_offsets_for_metadata_low(
const rec_t* rec,
const dict_index_t* index,
ulint limit,
ulint n_exist_fields,
std::vector<ulint>* dropped_cols,
ulint* offsets)
{
ulint offs = 0;
ulint prev_offs = 0;
ulint any = 0;
ulint n_pk_fields = unsigned(index->n_uniq + DATA_ROLL_PTR);
ulint len;
const byte* nulls = rec;
const byte* lens = NULL;
dict_table_t* table = index->table;
unsigned pk_fields = index->n_uniq + DATA_ROLL_PTR + 1;
dict_field_t* field;
const dict_col_t* col;
const dict_col_t* col;
int null_mask = 1;
ulint prev_offs = 0;
ulint offs = 0;
ulint any = 0;
ulint pos = 0;
nulls -= REC_N_NEW_EXTRA_BYTES;
ut_ad(index->is_instant());
#ifdef UNIV_DEBUG
offsets[2] = (ulint) rec;
offsets[3] = (ulint) index;
#endif /* UNIV_DEBUG */
nulls -= REC_N_NEW_EXTRA_BYTES;
ulint n_null_bytes = rec_get_n_add_field(nulls);
lens = --nulls - n_null_bytes;
ulint len;
ulint i = 0;
ulint non_drop_nullable_fields = 0;
ut_ad(index->is_instant());
for (; i < rec_offs_n_fields(offsets) && i < pk_fields; i++) {
while(pos < rec_offs_n_fields(offsets) && pos < limit)
{
bool is_dropped = false;
bool is_nullable = false;
bool is_drop_null = false;
if (i == pk_fields - 1) {
if (pos == n_pk_fields) {
/* Default row blob. */
offs += FIELD_REF_SIZE;
any |= REC_OFFS_EXTERNAL;
len = offs | REC_OFFS_EXTERNAL;
} else {
field = dict_index_get_nth_field(index, i);
col = dict_field_get_col(field);
ut_ad(!col->is_dropped());
if (col->is_nullable()) {
non_drop_nullable_fields++;
}
len = offs += field->fixed_len;
goto resolved;
}
rec_offs_base(offsets)[i + 1] = len;
}
*rec_offs_base(offsets)
= ulint(rec - 1) | REC_OFFS_COMPACT | any;
if (rec_offs_n_fields(offsets) <= pk_fields) {
return;
}
const byte* field_data;
byte* blob_data;
ulint blob_len;
field_data = rec_get_nth_field(rec, offsets, (pk_fields - 1), &len);
bool is_insert_row = (memcmp(field_data, field_ref_zero, len) == 0);
ulint n_dropped_columns = 0;
ulint n_null_bytes = 0;
ulint non_pk_fields = 0;
std::vector<ulint> dropped_cols_list;
if (is_insert_row) {
non_pk_fields = index->n_fields;
n_dropped_columns = table->n_dropped_cols;
n_null_bytes = UT_BITS_IN_BYTES(
index->n_non_drop_nullable_fields + n_dropped_columns);
} else {
blob_data = btr_copy_externally_stored_field(
&blob_len, field_data,
dict_table_page_size(table),
len, table->heap);
table->read_metadata_blob(
blob_data, &non_pk_fields,
&non_drop_nullable_fields, dropped_cols_list);
n_dropped_columns = dropped_cols_list.size();
n_null_bytes = UT_BITS_IN_BYTES(
non_drop_nullable_fields + n_dropped_columns);
}
lens = --nulls - n_null_bytes;
int null_mask = 1;
while(i < rec_offs_n_fields(offsets))
{
bool is_dropped = false;
bool is_nullable = false;
bool is_drop_null = false;
if (i >= non_pk_fields + pk_fields) {
if (pos >= n_exist_fields) {
ulint dlen;
if (!index->instant_field_value(i - 1, &dlen)) {
if (!index->instant_field_value(pos - 1, &dlen)) {
len = offs | REC_OFFS_SQL_NULL;
ut_ad(dlen == UNIV_SQL_NULL);
} else {
......@@ -714,15 +658,16 @@ rec_init_offsets_for_metadata(
goto resolved;
}
field = dict_index_get_nth_field(index, i - 1);
field = dict_index_get_nth_field(
index, (pos > n_pk_fields) ? pos - 1 : pos);
col = dict_field_get_col(field);
if (is_insert_row) {
if (dropped_cols == NULL) {
is_dropped = col->is_dropped();
} else {
if (std::find(
dropped_cols_list.begin(), dropped_cols_list.end(),
i - pk_fields) != dropped_cols_list.end()) {
dropped_cols->begin(), dropped_cols->end(),
pos - n_pk_fields) != dropped_cols->end()) {
is_dropped = true;
}
}
......@@ -795,13 +740,88 @@ rec_init_offsets_for_metadata(
prev_offs = 0;
}
rec_offs_base(offsets)[++i] = len;
rec_offs_base(offsets)[++pos] = len;
}
*rec_offs_base(offsets)
= ulint(rec - (lens + 1)) | REC_OFFS_COMPACT | any;
}
/** Determine the offsets to each field in the metadata record.
The offsets are written to a previously allocated array of
ulint, where rec_offs_n_fields(offsets) has been initialized to the
number of fields in the record. The rest of the array will be
initialized by this function. rec_offs_base(offsets)[0] will be set
to the extra size (if REC_OFFS_COMPACT is set, the record is in the
new format; if REC_OFFS_EXTERNAL is set, the record contains externally
stored columns; if REC_OFFS_DROP_SQL_NULL is set, the field for the dropped
column is NULLABLE or length for the column is also maintained), and
rec_offs_base(offsets)[1..n_fields] will be set to
offsets past the end of fields 0..n_fields, or to the beginning of
fields 1..n_fields+1. When the high-order bit of the offset at [i+1]
is set (REC_OFFS_SQL_NULL), the field i is NULL. When the second
high-order bit of the offset at [i+1] is set (REC_OFFS_EXTERNAL), the
field i is being stored externally.
@param[in] rec record
@param[in] index the index that the record belongs in
@param[in,out] offsets array of offsets, with valid rec_offs_n_fields() */
static
void
rec_init_offsets_for_metadata(
const rec_t* rec,
const dict_index_t* index,
ulint* offsets)
{
unsigned pk_fields = index->n_uniq + DATA_ROLL_PTR + 1;
#ifdef UNIV_DEBUG
offsets[2] = (ulint) rec;
offsets[3] = (ulint) index;
#endif /* UNIV_DEBUG */
rec_init_offsets_for_metadata_low(rec, index, pk_fields,
(pk_fields + 1), NULL,
offsets);
if (rec_offs_n_fields(offsets) <= pk_fields) {
return;
}
const byte* field_data;
byte* blob_data;
ulint blob_len;
ulint len;
field_data = rec_get_nth_field(rec, offsets, (pk_fields - 1), &len);
bool is_insert_row = (memcmp(field_data, field_ref_zero, len) == 0);
ulint non_pk_fields = 0;
std::vector<ulint> dropped_cols_list;
dict_table_t* table = index->table;
if (is_insert_row) {
non_pk_fields = index->n_fields + 1;
} else {
blob_data = btr_copy_externally_stored_field(
&blob_len, field_data,
dict_table_page_size(table),
len, table->heap);
table->read_metadata_blob(
blob_data, &non_pk_fields,
dropped_cols_list);
non_pk_fields += pk_fields;
}
rec_init_offsets_for_metadata_low(rec, index, rec_offs_n_fields(offsets),
non_pk_fields,
is_insert_row ? NULL: &dropped_cols_list,
offsets);
}
/** Determine the offsets to each field in the record.
The offsets are written to a previously allocated array of
ulint, where rec_offs_n_fields(offsets) has been initialized to the
......@@ -1351,6 +1371,9 @@ rec_get_metadata_converted_size(
+ clust_index->n_dropped_fields);
extra_size += n_null_bytes;
extra_size += rec_get_n_add_field_len(n_null_bytes);
data_size = 0;
ulint field_no;
ulint ind_field_no = 0;
......@@ -1822,6 +1845,8 @@ rec_convert_dtuple_to_default_rec_comp(
(clust_index->n_non_drop_nullable_fields
+ clust_index->n_dropped_fields));
rec_set_n_add_field(nulls, n_null_bytes);
rec_set_heap_no_new(rec, PAGE_HEAP_NO_USER_LOW);
rec_set_status(rec, REC_STATUS_INSTANT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment