[MDEV-6666] Malformed result for CONCAT(utf8_column, binary_string) Created: 2014-08-30  Updated: 2015-01-17  Resolved: 2014-09-02

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.3.12, 5.5.38, 10.0.13
Fix Version/s: 10.0.14

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


 Description   

This script:

drop table if exists t1;
create table t1 (a varchar(10) character set utf8);
insert into t1 values ('aaa');
select concat(a, 0xFF), charset(concat(a, 0xFF)) from t1;

returns a badly formed result:

+-----------------+--------------------------+
| concat(a, 0xFF) | charset(concat(a, 0xFF)) |
+-----------------+--------------------------+
| aaa�             | utf8                     |
+-----------------+--------------------------+

Notice, character set of the result is utf8, but the returned string
is not a valid utf8 string.

The correct behaviour would be to return an error, as 0xFF is a bad utf8 string.

A similar problem happens with UNION:

drop table if exists t1;
create table t1 (a varchar(10) character set utf8);
insert into t1 values ('aaa');
select a from t1 union select 0xFF;
show warnings;

returns:

+------+
| a    |
+------+
| aaa  |
|      |
+------+
2 rows in set, 1 warning (0.00 sec)
 
+---------+------+--------------------------------------------------------+
| Level   | Code | Message                                                |
+---------+------+--------------------------------------------------------+
| Warning | 1366 | Incorrect string value: '\xFF' for column 'a' at row 2 |
+---------+------+--------------------------------------------------------+
1 row in set (0.00 sec)

The correct behaviour would be to return an error.


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