Bug #117166 show variables stmt returns empty when parsing constant str using ucs
Submitted: 9 Jan 7:48 Modified: 9 Jan 8:05
Reporter: ximin liang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Information schema Severity:S3 (Non-critical)
Version:9.1.0 OS:Any
Assigned to: CPU Architecture:Any

[9 Jan 7:48] ximin liang
Description:
Hello MySQL team:
  Here is a about charset. Can be repeated in 9.1.0.

How to repeat:
Execute sqls below:
  set names utf8mb4;
  show variables like '%character_set_connection%';
  result is: 
  +--------------------------+---------+ 
  | Variable_name            | Value   |
  +--------------------------+---------+
  | character_set_connection | utf8mb4 |
  +--------------------------+---------+
  however, if executes:
  
  mysql> set character_set_connection = utf32;
  Query OK, 0 rows affected (0.00 sec)

  mysql> show variables like '%character_set_connection%';
  Empty set (0.00 sec)

  similarly, 

  mysql> set character_set_connection = ucs2;
  Query OK, 0 rows affected, 1 warning (0.00 sec)

  mysql> show variables like '%character_set_connection%';
  Empty set (0.01 sec)

Suggested fix:
ucs2 and utf32 is fixed length. for ucs2, constant string '%character_set_connection%' after like, it is decoded as 0x00 0x63.... and stored in str_value member of Item_string although str_value is set other charset(depends on charset of table performance_schema.session_variables).
finally no result get in filter so returns empty set.
[9 Jan 8:05] MySQL Verification Team
Hello ximin liang,

Thank you for the report and test case.

regards,
Umesh