Browse Source

Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7

Merge a test case and a code change from MySQL 5.7.22.
There was no commit message, but a test case was included.
d3ec326bcd

There is no Bug 25899959 mentioned in the MySQL 8.0.11 history.
Based on the number, it should have been filed before August 2017.
Maybe it was initially fixed in a not-yet-public MySQL 9.0 branch?

The code change differs from MySQL 5.7, because the mbminmaxlen
were split in MariaDB in MDEV-7049.
bb-10.2-mdev-13626
Marko Mäkelä 8 years ago
parent
commit
2b24b04220
  1. 13
      mysql-test/suite/gcol/r/innodb_virtual_index.result
  2. 8
      mysql-test/suite/gcol/t/innodb_virtual_index.test
  3. 9
      storage/innobase/handler/handler0alter.cc

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

@ -198,3 +198,16 @@ VIRTUAL, ADD UNIQUE index idx (col1), algorithm=inplace;
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
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
#
# Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7
#
CREATE TABLE t1 (col1 int(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE t1 ADD col2 char(21) AS (col1 * col1), ADD INDEX n (col2);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`col1` int(10) DEFAULT NULL,
`col2` char(21) GENERATED ALWAYS AS (`col1` * `col1`) VIRTUAL,
KEY `n` (`col2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
DROP TABLE t1;

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

@ -224,3 +224,11 @@ VIRTUAL, ADD UNIQUE index idx (col1), algorithm=inplace;
DROP TABLE t1;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
--echo #
--echo # Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7
--echo #
CREATE TABLE t1 (col1 int(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE t1 ADD col2 char(21) AS (col1 * col1), ADD INDEX n (col2);
SHOW CREATE TABLE t1;
DROP TABLE t1;

9
storage/innobase/handler/handler0alter.cc

@ -4385,6 +4385,15 @@ prepare_inplace_alter_table_dict(
if (ha_alter_info->handler_flags
& Alter_inplace_info::ADD_INDEX) {
for (ulint i = 0; i < ctx->num_to_add_vcol; i++) {
/* Set mbminmax for newly added column */
dict_col_t& col = ctx->add_vcol[i].m_col;
ulint mbminlen, mbmaxlen;
dtype_get_mblen(col.mtype, col.prtype,
&mbminlen, &mbmaxlen);
col.mbminlen = mbminlen;
col.mbmaxlen = mbmaxlen;
}
add_v = static_cast<dict_add_v_col_t*>(
mem_heap_alloc(ctx->heap, sizeof *add_v));
add_v->n_v_col = ctx->num_to_add_vcol;

Loading…
Cancel
Save