MDEV-33214 Table is getting rebuild with ALTER TABLE ADD COLUMN

Problem:
======
- InnoDB fail to do instant operation while adding the variable
length column. Problem is that InnoDB wrongly assumes that
variable character length can never part of externally stored
page.

Solution:
========
instant_alter_column_possible(): Variable length
character field can be stored as externally stored page.
parent ef7abc88
......@@ -256,3 +256,16 @@ select * from t1;
check table t1;
drop database best;
--echo #
--echo # MDEV-33214 Table is getting rebuild with
--echo # ALTER TABLE ADD COLUMN
--echo #
use test;
CREATE TABLE t1(f1 INT, f2 VARCHAR(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
INSERT INTO t1 VALUES(1,'abc'),(2,'def');
ALTER TABLE t1 ADD (f3 VARCHAR(5000), f4 VARCHAR(20)), ALGORITHM=instant;
ALTER TABLE t1 ADD f5 TEXT, ALGORITHM=INSTANT;
DROP TABLE t1;
--echo # End of 10.4 tests
......@@ -1581,11 +1581,9 @@ instant_alter_column_possible(
ut_ad(!is_null || nullable);
n_nullable += nullable;
n_add++;
uint l;
uint l = (*af)->pack_length();
switch ((*af)->type()) {
case MYSQL_TYPE_VARCHAR:
l = reinterpret_cast<const Field_varstring*>
(*af)->get_length();
variable_length:
if (l >= min_local_len) {
max_size += blob_prefix
......@@ -1599,7 +1597,6 @@ instant_alter_column_possible(
if (!is_null) {
min_size += l;
}
l = (*af)->pack_length();
max_size += l;
lenlen += l > 255 ? 2 : 1;
}
......@@ -1613,7 +1610,6 @@ instant_alter_column_possible(
((*af))->get_length();
goto variable_length;
default:
l = (*af)->pack_length();
if (l > 255 && ib_table.not_redundant()) {
goto variable_length;
}
......
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