Description:
mysql.plugin does not work with utf8mb3 character set.
This is a regression caused by the patch for Bug#33731.
In that patch, column data types were changed from 'char'
to 'varchar'. Since WL#1213 was already pushed, everything
worked well with default utf8mb4 character set.
The thing is:
- if the data type is char, then MyISAM keys are constructed
in a form of simple string, like 'this is a key value'.
_mi_pack_key(), which is used to prepare a key for search
in MyISAM tables works well with such strings.
- if the data type is varchar MyISAM keys are constructed
in a form of length-coded-string, like '<key value length><key value>'.
- if utf8mb4 is used for mysql.plugin, then 2 bytes are used
to encode the length. This is what _mi_pack_key() expects of
length-coded-strings.
- if utf8mb3 is used for mysql.plugin, then 1 byte is used
to encode the length. This is _not_ what _mi_pack_key() expects,
so it creates invalid key, which can not be used to obtain a row.
- the difference 1 byte / 2 bytes comes from this:
- the mysql.plugin.name column has length of 64 symbols
- for utf8mb4 that means, the length in bytes is 64 * 4 = 256
- for utf8mb3 that means, the length in bytes is 64 * 3 = 192
- the HA_VARCHAR_PACKLENGTH() macro reserves 2 bytes for lengths
longer than 255 bytes, thus 1 byte for utf8mb3 and 2 bytes
for utf8mb4.
How to repeat:
1. Change mysql.plugin definition in scripts/mysql_system_tables.sql as follows:
CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci comment='MySQL plugins';
2. Run main.plugin test case.
The following error will appear:
mysqltest: At line 15: query 'INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO' failed: 1062: Duplicate entry 'example' for key 'PRIMARY'
Suggested fix:
Either rollback the patch for Bug#33731 and fix it differently,
or change length of 'name' column to something greater than 256/3
(like 90), or something else :).