[MDEV-28323] Redundant Item_func_conv_charset on WHERE utf8mb4_field=utf8mb3_field Created: 2022-04-15  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.11

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-15564 Avoid table rebuild in ALTER TABLE on... Closed
relates to MDEV-19284 INSTANT ALTER with ucs2-to-utf16 conv... Closed
relates to MDEV-19285 INSTANT ALTER from ascii_general_ci t... Closed

 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4, b TEXT CHARACTER SET utf8mb3);
INSERT INTO t1 VALUES ('a','a');
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=b;
SHOW WARNINGS;

+-------+------+--------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                              |
+-------+------+--------------------------------------------------------------------------------------------------------------------------------------+
| Note  | 1003 | select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` = convert(`test`.`t1`.`b` using utf8mb4) |
+-------+------+--------------------------------------------------------------------------------------------------------------------------------------+

The Item_func_conv_charset behind CONVERT() is redundant here. utf8mb3 can be reinterpreted to utf8mb4 without conversion.

Note, we even allow online alter when converting an utf8mb3 column to utf8mb4 column with the same data type and size. The same optimization can be applied here.


Generated at Thu Feb 08 09:59:49 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.