summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-08-18 15:14:12 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-08-18 15:14:12 +0300
commit064bfbaf0646f91f0a7ddc4f1e5f3c9844e7571f (patch)
tree39494a35db46e1d2deafed8f7e10b806ff28f033
parent5c8a1249ddeff70a3ffb6ce963a6eed3d55d4510 (diff)
downloadmariadb-git-064bfbaf0646f91f0a7ddc4f1e5f3c9844e7571f.tar.gz
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.
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_bugs.result6
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_bugs.test7
-rw-r--r--storage/innobase/dict/dict0mem.cc2
-rw-r--r--storage/innobase/include/dict0mem.h2
4 files changed, 15 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result
index 81d4db79be0..3da8fccd3c5 100644
--- a/mysql-test/suite/innodb/r/instant_alter_bugs.result
+++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result
@@ -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;
diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test
index b6a3aecd7da..9522a960928 100644
--- a/mysql-test/suite/innodb/t/instant_alter_bugs.test
+++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test
@@ -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;
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index e9e0d33bf9f..b72451e0f34 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -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;
}
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index ed392df3c05..e20812b862b 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -728,7 +728,7 @@ public:
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));