[MDEV-12497] Wrong data type for LEAST(latin1_expr, utf8_expr) Created: 2017-04-13  Updated: 2017-04-22  Resolved: 2017-04-22

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.3.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed
Relates
relates to MDEV-12506 Split Item_func_min_max::fix_length_a... Closed

 Description   

CREATE OR REPLACE TABLE t1 AS SELECT
  LEAST(_latin1'aaa',_utf8 0xC39F) AS c1,
  COALESCE(_latin1'aaa',_utf8 0xC39F) AS c2;
SHOW WARNINGS;
SHOW CREATE TABLE t1;
SELECT * FROM t1;

returns a warning:

+---------+------+-----------------------------------------+
| Level   | Code | Message                                 |
+---------+------+-----------------------------------------+
| Warning | 1265 | Data truncated for column 'c1' at row 1 |
+---------+------+-----------------------------------------+

and this result:

+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                  |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `c1` varchar(1) CHARACTER SET utf8 NOT NULL DEFAULT '',
  `c2` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+----+-----+
| c1 | c2  |
+----+-----+
| a  | aaa |
+----+-----+

Notice:

  • The data type for column c1 is wrong. It should be varchar(3)), similar to c2
  • The result for column c1 is wrong. It should be aaa.

Generated at Thu Feb 08 07:58:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.