Test query:
select if(true,get_paper_real_amount(11),'абвгд');
where get_paper_real_amount(int(11))
is stored function returning int(11)
and 'абвгд'
as cp1251 string.
On mysql 5.0 and 5.1 everything works charming. On mysql 5.5 and 5.6 (doesn't tested on other versions) there are issue, getting error:
Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1251_general_ci,COERCIBLE) for operator if
Manual says:
IF(expr1,expr2,expr3)
....
If expr2 or expr3 produce a string, the result is a string.
Obviously get_paper_real_amount(11)
result converted to char using latin1
character set and latin1_swedish_ci
collation, whereas show variables like '%character%'
reports:
character_set_client cp1251
character_set_connection cp1251
character_set_database cp1251
character_set_filesystem binary
character_set_results cp1251
character_set_server cp1251
character_set_system utf8
character_sets_dir /usr/local/mysql/share/charsets/
Furthermore, I compiled both 5.5 and 5.6 with
cmake . -DDEFAULT_CHARSET=cp1251 -DDEFAULT_COLLATION=cp1251_general_ci
and still has no success.
I have app developed in the 5.0 era, now gonna update to modern mysql version, but that issue making me to update alot of code... Is there any walkaround?