Skip to content

Commit

Permalink
MDEV-23499 Assertion c.same_type(*o) failed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Aug 18, 2020
1 parent 5c8a124 commit 064bfba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions mysql-test/suite/innodb/r/instant_alter_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,10 @@ CREATE TABLE t (i INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t SET i=1;
ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32 FIRST, ALGORITHM=INSTANT;
DROP TABLE t;
#
# MDEV-23499 Assertion c.same_type(*o) failed
#
CREATE TABLE t (pk SERIAL, b TEXT CHARACTER SET utf8) ENGINE=InnoDB;
ALTER TABLE t MODIFY b TEXT CHARACTER SET utf8mb4 FIRST;
DROP TABLE t;
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
7 changes: 7 additions & 0 deletions mysql-test/suite/innodb/t/instant_alter_bugs.test
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,11 @@ INSERT INTO t SET i=1;
ALTER TABLE t ADD e CHAR(255) CHARACTER SET UTF32 FIRST, ALGORITHM=INSTANT;
DROP TABLE t;

--echo #
--echo # MDEV-23499 Assertion c.same_type(*o) failed
--echo #
CREATE TABLE t (pk SERIAL, b TEXT CHARACTER SET utf8) ENGINE=InnoDB;
ALTER TABLE t MODIFY b TEXT CHARACTER SET utf8mb4 FIRST;
DROP TABLE t;

SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
2 changes: 1 addition & 1 deletion storage/innobase/dict/dict0mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ bool dict_col_t::same_encoding(uint16_t a, uint16_t b)
{
if (const CHARSET_INFO *acs= get_charset(a, MYF(MY_WME)))
if (const CHARSET_INFO *bcs= get_charset(b, MYF(MY_WME)))
return Charset(acs).same_encoding(bcs);
return Charset(bcs).encoding_allows_reinterpret_as(acs);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/dict0mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ struct dict_col_t{
bool same_format(const dict_col_t &other) const
{
return same_type(other) && len >= other.len &&
mbminlen == other.mbminlen && mbmaxlen == other.mbmaxlen &&
mbminlen == other.mbminlen && mbmaxlen >= other.mbmaxlen &&
!((prtype ^ other.prtype) & ~(DATA_NOT_NULL | DATA_VERSIONED |
CHAR_COLL_MASK << 16 |
DATA_LONG_TRUE_VARCHAR));
Expand Down

0 comments on commit 064bfba

Please sign in to comment.