Bug #117567 mysql_stmt_execute doesn't set the PARAMETER_COUNT_AVAILABLE flag
Submitted: 25 Feb 14:44 Modified: 25 Feb 15:00
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:9.2.0 OS:Any
Assigned to: CPU Architecture:Any

[25 Feb 14:44] Daniël van Eeden
Description:
From libmysql/libmysql.cc

  bool can_deal_with_flags =
      mysql->server_version && mysql_get_server_version(mysql) >= 80026;

This results in a 0 flag instead of a PARAMETER_COUNT_AVAILABLE flag being sent to the server if the server announces a lower version than 80026. But then the client still sends the query attributes which seems like a protocol violation to me.

- https://github.com/mysql/mysql-server/blob/6b6d3ed3d5c6591b446276184642d7d0504ecc86/libmys...
- https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_stmt_execute.html

This might break things for
- Proxies, Routers, etc that may announce a version that might be different from the actual backend sever(s).
- Third party server implementations of the MySQL protocol

How to repeat:
Test with a server and client that both set CLIENT_QUERY_ATTRIBUTES but where the server version is set to a version of 8.0.25 or below.

I would expect a PARAMETER_COUNT_AVAILABLE flag and query attributes. It doesn't set the flag, but does send the attributes.

Test with a server and client that both set CLIENT_QUERY_ATTRIBUTES but where the server version is set to a version of 8.0.26 or newer.

I would expect a PARAMETER_COUNT_AVAILABLE flag and query attributes. And the actual behavior matches the expectations.
[25 Feb 15:00] Daniël van Eeden
Note that doing this via Connector/Python with use_pure=False/True and cursor(prepared=True/False) seems to show inconsistencies:

1. With pure Python it does send the query attrs and set the flag. Without checking the version.

2. With C Extension it does send the query attrs and it sets the flag based on the version (the issue described in this bug)