[MDEV-23250] User variable loses its character set Created: 2020-07-22  Updated: 2020-07-22

Status: Open
Project: MariaDB Server
Component/s: Data types, Variables
Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.5

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 1
Labels: None

Issue Links:
Relates
relates to MDEV-23246 Illegal mix of collations Open

 Description   

SET @x=_utf8'ß';
SELECT IF (0,@x:=10,@x), CHARSET(@x), @x;

+------------------+-------------+------+
| IF (0,@x:=10,@x) | CHARSET(@x) | @x   |
+------------------+-------------+------+
| ß               | latin1      | ß   |
+------------------+-------------+------+

Notice, the variable @x changed its character set from utf8 to latin1 and therefore returns a wrong value.

The problem happens because Item_func_set_user_val::fix_length_and_dec(), performed for @x:=10, changes the character set of @x from utf8 to latin1.
But the assignment of @x to 10 does not actually happen, because of the 0 in the first argument of IF.

So the underlying code erroneously changes the variable character set separately from the value, which looks wrong.


Generated at Thu Feb 08 09:21:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.