[MDEV-23246] Illegal mix of collations Created: 2020-07-21 Updated: 2020-07-22 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Character Sets, Variables |
| Affects Version/s: | 10.5 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Todd Michael | Assignee: | Alexander Barkov |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 10 Pro 64 bit |
||
| Issue Links: |
|
||||||||||||
| Description |
|
Inconsistent collation treatment for some function for user variables when comparing values. Receiving error Error Code: 1267. Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' for some operations that previously worked on 10.3.23, but now fails on 10.5 (10.5.1 ... 10.5.4). Comparisons for functions tested so far that fail with the above error:
Importantly, this will work if the first line is SET @x:=1;. Also, if @x = is removed, they also work. I suspect that this has to do with the collation of user variables acting differently in v10.5, and may be related to |
| Comments |
| Comment by Alexander Barkov [ 2020-07-22 ] | ||||||
|
Note, in a statement like this:
the data type for @x (in the right part) is detected by the value of @x as of start of the entire query.
So for example, in this script:
The data type of @x in @x=BIN(@x) is considered to be VARCHAR, as of the start of the statement. It's also true the other way around:
The data type of @x in @x=BIN(@x) is considered as INT, as of the start of the statement. We cannot fix it in the way so it takes into account variable data type change inside the query, like in the assignment to the left of the comparison in this example. The current implementation to use the variable data type as of start of the entire statement is intentional. We can only try to fix the illegal mix of collations error because the result of BIN() contains only ASCII characters and therefore can be converted to latin1 without a data loss. But please analyse your script. It might perform the comparison in the way that you don't expect. | ||||||
| Comment by Todd Michael [ 2020-07-22 ] | ||||||
|
Thanks, but this does not really answer the problem at hand. These statements used to work in 10.3, and now don't in 10.5, despite your explanation. Also, if the variable is completely uninitiated in the query, then it also fails in 10.5, but works fine in 10.3:
The dummy value was just used in the example to cause it to always fail (ie just in case your session was already using an initialised @x value). The pattern works for some functions, and not others in no consistent manner in 10.5, but have no problems in 10.3. |