[MDEV-9407] Illegal mix of collation when using GROUP_CONCAT in a VIEW Created: 2016-01-13  Updated: 2017-01-24  Resolved: 2017-01-24

Status: Closed
Project: MariaDB Server
Component/s: Views
Affects Version/s: 5.5, 10.0, 10.1
Fix Version/s: 10.2.0

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: 10.2-rc

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

SET NAMES utf8;
DROP TABLE IF EXISTS t1;
DROP VIEW IF EXISTS v1;
CREATE TABLE t1 (col1 VARCHAR(12) CHARACTER SET utf8 COLLATE utf8_unicode_ci);
INSERT INTO t1 VALUES ('a'),('b');
CREATE VIEW v1 AS SELECT group_concat('f') AS col1;
SELECT col1 FROM v1 UNION SELECT col1 FROM t1;

returns

ERROR 1271 (HY000) at line 7: Illegal mix of collations for operation 'UNION'

This is very similar to:
MySQL Bug#21505 Create view - illegal mix of collation for operation 'UNION'
https://bugs.mysql.com/bug.php?id=21505
which was fixed in 2006, but now for an aggregate function GROUP_CONCAT.

The problem is that create_tmp_field_from_item() in sql_select.cc and Item_sum::create_tmp_field() are exactly the same 40 lines of the code.
create_tmp_field_from_item() was fixed by Bug#21505, while Item_sum::create_tmp_field() was not.
The code in create_tmp_field_from_item() should be moved as a method in Item, and Item_sum::create_tmp_field() should just reuse it.



 Comments   
Comment by Elena Stepanova [ 2016-12-26 ]

Has it been fixed? Doesn't seem to be happening on current 10.2 ("current" being 08f79bdeda of Dec 22).

Comment by Alexander Barkov [ 2017-01-24 ]

This problem was earlier fixed in 2016-01-16 in 10.2.0. I forgot to close the issue. Closing now.

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