Skip to content

Commit 064bfba

Browse files
committed
MDEV-23499 Assertion c.same_type(*o) failed
dict_col_t::same_encoding(), dict_col_t::same_format(): Allow an instantaneous change of a column to a compatible encoding, just like ha_innobase::can_convert_string() and similar functions do.
1 parent 5c8a124 commit 064bfba

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

mysql-test/suite/innodb/r/instant_alter_bugs.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,4 +407,10 @@ CREATE TABLE t (i INT PRIMARY KEY) ENGINE=InnoDB;
407407
INSERT INTO t SET i=1;
408408
ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32 FIRST, ALGORITHM=INSTANT;
409409
DROP TABLE t;
410+
#
411+
# MDEV-23499 Assertion c.same_type(*o) failed
412+
#
413+
CREATE TABLE t (pk SERIAL, b TEXT CHARACTER SET utf8) ENGINE=InnoDB;
414+
ALTER TABLE t MODIFY b TEXT CHARACTER SET utf8mb4 FIRST;
415+
DROP TABLE t;
410416
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;

mysql-test/suite/innodb/t/instant_alter_bugs.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,11 @@ INSERT INTO t SET i=1;
429429
ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32 FIRST, ALGORITHM=INSTANT;
430430
DROP TABLE t;
431431

432+
--echo #
433+
--echo # MDEV-23499 Assertion c.same_type(*o) failed
434+
--echo #
435+
CREATE TABLE t (pk SERIAL, b TEXT CHARACTER SET utf8) ENGINE=InnoDB;
436+
ALTER TABLE t MODIFY b TEXT CHARACTER SET utf8mb4 FIRST;
437+
DROP TABLE t;
438+
432439
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;

storage/innobase/dict/dict0mem.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool dict_col_t::same_encoding(uint16_t a, uint16_t b)
120120
{
121121
if (const CHARSET_INFO *acs= get_charset(a, MYF(MY_WME)))
122122
if (const CHARSET_INFO *bcs= get_charset(b, MYF(MY_WME)))
123-
return Charset(acs).same_encoding(bcs);
123+
return Charset(bcs).encoding_allows_reinterpret_as(acs);
124124
return false;
125125
}
126126

storage/innobase/include/dict0mem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ struct dict_col_t{
728728
bool same_format(const dict_col_t &other) const
729729
{
730730
return same_type(other) && len >= other.len &&
731-
mbminlen == other.mbminlen && mbmaxlen == other.mbmaxlen &&
731+
mbminlen == other.mbminlen && mbmaxlen >= other.mbmaxlen &&
732732
!((prtype ^ other.prtype) & ~(DATA_NOT_NULL | DATA_VERSIONED |
733733
CHAR_COLL_MASK << 16 |
734734
DATA_LONG_TRUE_VARCHAR));

0 commit comments

Comments
 (0)