Skip to content

Commit 2879fb0

Browse files
committed
MDEV-16142: Merge one more fix from MySQL 5.7.22
This fix was initially missed, because there were multiple commits with an empty message.
2 parents 4d2a36e + 2b24b04 commit 2879fb0

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

mysql-test/suite/gcol/r/innodb_virtual_index.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,16 @@ VIRTUAL, ADD UNIQUE index idx (col1), algorithm=inplace;
198198
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: INPLACE ADD or DROP of virtual columns cannot be combined with other ALTER TABLE actions. Try ALGORITHM=COPY
199199
DROP TABLE t1;
200200
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
201+
#
202+
# Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7
203+
#
204+
CREATE TABLE t1 (col1 int(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
205+
ALTER TABLE t1 ADD col2 char(21) AS (col1 * col1), ADD INDEX n (col2);
206+
SHOW CREATE TABLE t1;
207+
Table Create Table
208+
t1 CREATE TABLE `t1` (
209+
`col1` int(10) DEFAULT NULL,
210+
`col2` char(21) GENERATED ALWAYS AS (`col1` * `col1`) VIRTUAL,
211+
KEY `n` (`col2`)
212+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
213+
DROP TABLE t1;

mysql-test/suite/gcol/t/innodb_virtual_index.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,11 @@ VIRTUAL, ADD UNIQUE index idx (col1), algorithm=inplace;
224224

225225
DROP TABLE t1;
226226
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
227+
228+
--echo #
229+
--echo # Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7
230+
--echo #
231+
CREATE TABLE t1 (col1 int(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
232+
ALTER TABLE t1 ADD col2 char(21) AS (col1 * col1), ADD INDEX n (col2);
233+
SHOW CREATE TABLE t1;
234+
DROP TABLE t1;

storage/innobase/handler/handler0alter.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4385,6 +4385,15 @@ prepare_inplace_alter_table_dict(
43854385

43864386
if (ha_alter_info->handler_flags
43874387
& Alter_inplace_info::ADD_INDEX) {
4388+
for (ulint i = 0; i < ctx->num_to_add_vcol; i++) {
4389+
/* Set mbminmax for newly added column */
4390+
dict_col_t& col = ctx->add_vcol[i].m_col;
4391+
ulint mbminlen, mbmaxlen;
4392+
dtype_get_mblen(col.mtype, col.prtype,
4393+
&mbminlen, &mbmaxlen);
4394+
col.mbminlen = mbminlen;
4395+
col.mbmaxlen = mbmaxlen;
4396+
}
43884397
add_v = static_cast<dict_add_v_col_t*>(
43894398
mem_heap_alloc(ctx->heap, sizeof *add_v));
43904399
add_v->n_v_col = ctx->num_to_add_vcol;

0 commit comments

Comments
 (0)