Bug #87813 Incorrect autocommit status bit in server_status at connection startup
Submitted: 20 Sep 2017 9:02 Modified: 21 Sep 2017 10:51
Reporter: Wei Zhao (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Connection Handling Severity:S3 (Non-critical)
Version:mysql-5.7.17, 8.0.2 OS:Any
Assigned to: CPU Architecture:Any

[20 Sep 2017 9:02] Wei Zhao
Description:
When the global 'autocommit' variable is 0, and client connects to server, the client gets a wrong server status --- the 'SERVER_STATUS_AUTOCOMMIT' bit is always set, even when it should not at this situation. This wrong status can affect how client handles transaction status.

This bug is very subtle and has been there for a long time, since most client apps won't rely on the server status, but it's very halmful when they do.

How to repeat:
in an existing connection, do this:
set global autocommit=0;

start a new connection with raw protocol code, and see the packet returned by mysqld, the server_status field has SERVER_STATUS_AUTOCOMMIT bit set when it shouldn't.

Suggested fix:
in mysqld, set session server status according to session status (thd->variables.option_bits). see my patch for details.
[20 Sep 2017 9:03] Wei Zhao
this patch fixes the bug

Attachment: thd_server_status_autocommit.diff (application/octet-stream, text), 506 bytes.

[21 Sep 2017 10:51] MySQL Verification Team
Hello Wei Zhao,

Thank you for the report and supplying patch along with the report.

Thanks,
Umesh
[17 Nov 2017 1:59] Wei Zhao
adding the patch as contribution

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: thd_server_status_autocommit.diff (application/octet-stream, text), 506 bytes.