Bug #101891 ERROR 1267 (HY000): Illegal mix of collations (ascii_general_ci,IMPLICIT)
Submitted: 7 Dec 2020 12:33 Modified: 23 Feb 2021 20:56
Reporter: Chandan Kumar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.22 OS:Oracle Linux (6.0.20 64 bit)
Assigned to: CPU Architecture:x86
Tags: regression

[7 Dec 2020 12:33] Chandan Kumar
Description:
In MySQL latest version 8.0.22 , below select statement against system tables performance_schema.replication_group_members throw error while lower sub-versions like (8.0.21,8.0.20 etc) was working fine.

mysql> select version();
+-------------------+
| version()         |
+-------------------+
| 8.0.22-commercial |
+-------------------+
1 row in set (0.00 sec)

mysql> select member_role from performance_schema.replication_group_members where member_host = @@hostname and member_role='PRIMARY';
ERROR 1267 (HY000): Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,SYSCONST) for operation '='
mysql>

How to repeat:

Running the below commands works fine with 8.0.20.
=====MySQL Version- 8.0.20=============

mysql> select version();
+-------------------+
| version()         |
+-------------------+
| 8.0.20-commercial |
+-------------------+
1 row in set (0.00 sec)

mysql> select member_role from performance_schema.replication_group_members where member_host = @@hostname and member_role='PRIMARY';
Empty set (0.00 sec)

mysql>

======= In MySQL Version 8.0.18======
mysql> select @@version;
+-------------------+
| @@version         |
+-------------------+
| 8.0.18-commercial |
+-------------------+
1 row in set (0.00 sec)

mysql> select member_role from performance_schema.replication_group_members where member_host = @@hostname and member_role='PRIMARY';
Empty set (0.00 sec)

mysql>
=============In MySQL Version 8.0.22===========
mysql> select version();
+-------------------+
| version()         |
+-------------------+
| 8.0.22-commercial |
+-------------------+
1 row in set (0.00 sec)

mysql> select member_role from performance_schema.replication_group_members where member_host = @@hostname and member_role='PRIMARY';
ERROR 1267 (HY000): Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,SYSCONST) for operation '='
mysql>
============

Suggested fix:

Using CAST operator works fine.

mysql> select member_role from performance_schema.replication_group_members where member_host = CAST(@@hostname as char) and member_role='PRIMARY';
Empty set (0.01 sec)

mysql>
[7 Dec 2020 12:34] Chandan Kumar
Error Screenshot with 8.0.22

Attachment: Error_8.0.22.png (image/png, text), 113.54 KiB.

[7 Dec 2020 12:35] Chandan Kumar
Without Error 8.0.20 version

Attachment: NoError_8.0.20.png (image/png, text), 71.01 KiB.

[8 Dec 2020 6:12] MySQL Verification Team
Hello Chandan,

Thank you for the report and feedback.

regards,
Umesh
[8 Dec 2020 6:15] MySQL Verification Team
- 8.0.22 standalone instance

rm -rf 101891/
bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/101891 --log-error-verbosity=3
bin/mysqld --no-defaults --basedir=$PWD --datadir=$PWD/101891 --core-file --socket=/tmp/mysql_ushastry.sock  --port=3333 --log-error=$PWD/101891/log.err --mysqlx-port=33330 --mysqlx-socket=/tmp/mysql_x_ushastry.sock --log-error-verbosity=3  --secure-file-priv=/tmp/ 2>&1 &

 bin/mysql -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select member_role from performance_schema.replication_group_members where member_host = @@hostname and member_role='PRIMARY';
ERROR 1267 (HY000): Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,SYSCONST) for operation '='
[24 Feb 2021 23:09] Jon Stephens
Documented fix as follows in the MySQL 8.0.24 changelog:

    Selecting from the Performace Schema replication_group_members
    table raised error 1267 -Illegal mix of collations ...-. This
    was due to a change in MySQL 8.0.22 in the handling of
    comparisons between a column value and a system variable.

Closed.
[23 Jul 2021 4:16] MySQL Verification Team
Bug #102500 marked as duplicate of this one