[MDEV-10805] CAST to CHAR should use one of the collation settings instead of the charset's default collation Created: 2016-09-13 Updated: 2017-06-13 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Character Sets |
| Affects Version/s: | 10.1.16 |
| Fix Version/s: | 10.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Hong Dai Thanh | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
RHEL 6 |
||
| Description |
|
Given the following server options:
And the following code to create database and test tables:
Running the code with mysql client gives the following output:
We can see the output of the show table status statement shows collation mix error with the 2 views, despite the fact that all collation settings are already set to latin1_general_ci for the session. Looking at the error message, it seems that while CAST implicitly uses the character set in the setting, it doesn't use the collation settings but use the default collation of the character set instead. This increases the effort from the programmer to keep track of the collation for all the CAST operations. Is it possible to change it to use one of the collation settings (whichever makes the most sense)? |
| Comments |
| Comment by Elena Stepanova [ 2016-09-19 ] | |||||||||||||||
|
I've only gotten 'Illegal mix' for the view cond. Assigning to the charset expert bar. | |||||||||||||||
| Comment by Alexander Barkov [ 2016-09-21 ] | |||||||||||||||
|
A smaller script demonstrating the same problem:
The above SELECT correctly returns one row. Now if I do the same with a VIEW:
the SELECT query returns an error:
This query returns how the view definition was stored:
and it returns the following:
Notice, it adds an explicit charset clause inside CAST, which forces CAST use the default collation of the character set. | |||||||||||||||
| Comment by Alexander Barkov [ 2016-09-21 ] | |||||||||||||||
|
A simple workaround is not to use CAST at all:
This script correctly returns one row. |