MDEV-21787 Alter table failure tries to access uninitialized column

- Problem is that failure of inplace DDL tries to access the
uninitialized column. This is caused by MDEV-19606 (commit 0274ab1d).
Fix is that InnoDB should use column while freeing the index when index
is completely initialized.
parent 3ad1af93
--- instant_alter_limit.result
+++ instant_alter_limit.result
@@ -42,5 +42,5 @@
--- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530
+++ instant_alter_limit,32k.reject 2020-05-26 19:59:19.743877366 +0530
@@ -43,5 +43,12 @@
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
-502
+506
DROP TABLE t;
+#
+# MDEV-21787 Alter table failure tries to access uninitialized column
+#
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 TEXT GENERATED ALWAYS AS (SUBSTR(f4, 1, 400)), f3 VARCHAR(500), f4 TEXT)ENGINE=InnoDB ROW_FORMAT=Compact;
+ALTER TABLE t1 ADD UNIQUE KEY (f2(9));
+ALTER TABLE t1 ADD COLUMN f5 TEXT, ALGORITHM=INPLACE;
+DROP TABLE t1;
--- instant_alter_limit.result
+++ instant_alter_limit.result
--- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530
+++ instant_alter_limit,4k.reject 2020-05-26 20:17:53.314736548 +0530
@@ -5,6 +5,276 @@
ENGINE=InnoDB;
INSERT INTO t VALUES(1,2,3,4,5);
......@@ -295,10 +295,19 @@
ALTER TABLE t ADD COLUMN b INT NOT NULL, ALGORITHM=INSTANT;
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
SELECT variable_value-@old_instant instants
@@ -43,5 +319,5 @@
@@ -43,5 +319,14 @@
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
-502
+474
DROP TABLE t;
+#
+# MDEV-21787 Alter table failure tries to access uninitialized column
+#
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 TEXT GENERATED ALWAYS AS (SUBSTR(f4, 1, 400)), f3 VARCHAR(500), f4 TEXT)ENGINE=InnoDB ROW_FORMAT=Compact;
+ALTER TABLE t1 ADD UNIQUE KEY (f2(9));
+ALTER TABLE t1 ADD COLUMN f5 TEXT, ALGORITHM=INPLACE;
+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.
+DROP TABLE t1;
--- instant_alter_limit.result
+++ instant_alter_limit.result
@@ -42,5 +42,5 @@
--- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530
+++ instant_alter_limit,64k.reject 2020-05-26 20:00:22.499711222 +0530
@@ -43,5 +43,12 @@
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
-502
+506
DROP TABLE t;
+#
+# MDEV-21787 Alter table failure tries to access uninitialized column
+#
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 TEXT GENERATED ALWAYS AS (SUBSTR(f4, 1, 400)), f3 VARCHAR(500), f4 TEXT)ENGINE=InnoDB ROW_FORMAT=Compact;
+ALTER TABLE t1 ADD UNIQUE KEY (f2(9));
+ALTER TABLE t1 ADD COLUMN f5 TEXT, ALGORITHM=INPLACE;
+DROP TABLE t1;
--- instant_alter_limit.result
+++ instant_alter_limit.result
--- instant_alter_limit.result 2020-05-26 18:01:27.377946439 +0530
+++ instant_alter_limit,8k.reject 2020-05-26 20:19:50.881869095 +0530
@@ -5,6 +5,28 @@
ENGINE=InnoDB;
INSERT INTO t VALUES(1,2,3,4,5);
......@@ -47,10 +47,17 @@
ALTER TABLE t ADD COLUMN b INT NOT NULL, ALGORITHM=INSTANT;
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
SELECT variable_value-@old_instant instants
@@ -43,5 +71,5 @@
@@ -43,5 +71,12 @@
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
-502
+492
DROP TABLE t;
+#
+# MDEV-21787 Alter table failure tries to access uninitialized column
+#
+CREATE TABLE t1(f1 INT PRIMARY KEY, f2 TEXT GENERATED ALWAYS AS (SUBSTR(f4, 1, 400)), f3 VARCHAR(500), f4 TEXT)ENGINE=InnoDB ROW_FORMAT=Compact;
+ALTER TABLE t1 ADD UNIQUE KEY (f2(9));
+ALTER TABLE t1 ADD COLUMN f5 TEXT, ALGORITHM=INPLACE;
+DROP TABLE t1;
......@@ -60,3 +60,17 @@ FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
DROP TABLE t;
--echo #
--echo # MDEV-21787 Alter table failure tries to access uninitialized column
--echo #
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 TEXT GENERATED ALWAYS AS (SUBSTR(f4, 1, 400)), f3 VARCHAR(500), f4 TEXT)ENGINE=InnoDB ROW_FORMAT=Compact;
ALTER TABLE t1 ADD UNIQUE KEY (f2(9));
let $error_code = 0;
let $innodb_page_size = `SELECT @@INNODB_PAGE_SIZE`;
if ($innodb_page_size == 4k) {
let $error_code= ER_TOO_BIG_ROWSIZE;
}
--error $error_code
ALTER TABLE t1 ADD COLUMN f5 TEXT, ALGORITHM=INPLACE;
DROP TABLE t1;
......@@ -1203,7 +1203,7 @@ struct dict_index_t {
@param whether to reset fields[].col */
void detach_columns(bool clear= false)
{
if (!has_virtual())
if (!has_virtual() || !cached)
return;
for (unsigned i= 0; i < n_fields; i++)
{
......
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