Bug #83472 Connection Attributes were not correctly read after change user command
Submitted: 20 Oct 2016 21:39 Modified: 21 Oct 2016 4:49
Reporter: Tian Xia Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.6.27, 5.6.34, 5.7.16 OS:Linux
Assigned to: Marc ALFF CPU Architecture:Any
Tags: connection attributes, perfschema, session_connect_attrs

[20 Oct 2016 21:39] Tian Xia
Description:
MySQL server reads connection attributes incorrectly after changing user (com_change_user). See how to repeat.

How to repeat:
You can repeat the bug using performance schema table performance_schema.session_connect_attrs.

(1) add the following lines to "mysql-test/suite/perfschema/t/connect_attrs.test"

change_user root;
--echo # must return 0, 6
SELECT SUM(ISNULL(ATTR_VALUE)), COUNT(*)
  FROM performance_schema.session_connect_attrs
  WHERE ATTR_NAME IN ('_os', '_client_name', '_pid',
                      '_client_version', '_platform', 'program_name')
    AND PROCESSLIST_ID = CONNECTION_ID();

(2) run the test "perfschema.connect_attrs"

(3) see the incorrect result as follows:

# must return 0, 6
SELECT SUM(ISNULL(ATTR_VALUE)), COUNT(*)
FROM performance_schema.session_connect_attrs
WHERE ATTR_NAME IN ('_os', '_client_name', '_pid',
'_client_version', '_platform', 'program_name')
AND PROCESSLIST_ID = CONNECTION_ID();
SUM(ISNULL(ATTR_VALUE))        COUNT(*)
NULL   0

Suggested fix:
Function parse_com_change_user_packet() needs to be fixed which didn't pass the correct read position when calling read_client_connect_attrs().
[21 Oct 2016 4:49] MySQL Verification Team
Hello Tian Xia,

Thank you for the report.
Observed this with 5.6.34.

Thanks,
Umesh