Bug #96650 SERVER_MORE_RESULTS_EXISTS is not set when response multiple BINLOG statements
Submitted: 26 Aug 2019 7:01 Modified: 30 Sep 2019 12:03
Reporter: Pengfei He Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.17 OS:Any
Assigned to: CPU Architecture:Any

[26 Aug 2019 7:01] Pengfei He
Description:
A connection with CLIENT_MULTI_STATEMENTS flag can send multiple statements to server, and server should response with the SERVER_MORE_RESULTS_EXISTS flag if it really has more results. This works well except multiple  BINLOG statements.

BINLOG statement is not different from other CUD statements on the C/S protocol layer, they should be treated equally.

How to repeat:
Create a connection with CLIENT_MULTI_STATEMENTS flag, and send multiple BINLOG statements at once, then check the response ok packet's status field.

Suggested fix:
Response multiple BINLOG statements with the SERVER_MORE_RESULTS_EXISTS flag when more results exists.
[26 Aug 2019 7:03] Pengfei He
added the server version 8.0.17
[28 Aug 2019 11:31] MySQL Verification Team
Hello Mr. He,

Thank you for your bug report.

What you are reporting is quite interesting, but we require further info.

First of all, we need a fully detailed test case, so that we could try to repeat the problem that you are experiencing. Test case should include all settings , commands, code, as well as other relevant info, so that we can repeat the problem.

Second, have you tried repeating the problem with our MySQL CLI, where CLI stands for Command Line Interface ???
[29 Sep 2019 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[9 Nov 2022 0:17] Sergei Boguslavski
The following issue has the repro steps:

https://github.com/mysql-net/MySqlConnector/issues/1237
[9 Nov 2022 12:44] MySQL Verification Team
Hi Mr. He,

First of all, we need repeatable test here, in the report, or uploaded via "Files" tab.

Also, our current release is 8.0.31, so it has to be reproducible there.
[10 Nov 2022 17:50] Sergei Boguslavski
To reproduce the issue, you just need to send multiple SQL statements as a single COM_QUERY (https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query.html) command to the server, and one of the statements should be a valid BINLOG '…' statement. The server response is expected to contain multiple OK packets (https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html). Normally, each packet contains SERVER_MORE_RESULTS_EXISTS (https://dev.mysql.com/doc/dev/mysql-server/latest/mysql__com_8h.html#a1d854e841086925be188...) flag in the server status field, unless this is the last packet. This way, the client knows that it should continue reading. However, BINLOG statement produces the OK_Packet that does not have this flag set. Since the client does not know how many results to expect, it relies on this flag. It stops reading, and the OK_Packed stays in the connection until the next query is executed, and then the client reads that wrong packet from the previous result. This is not how the protocol is supposed to work.

I will attach a C# application that reveals that issue
[10 Nov 2022 17:52] Sergei Boguslavski
Sample app to reproduce the issue

Attachment: MySqlTest.zip (application/x-zip-compressed, text), 1.22 KiB.

[11 Nov 2022 12:45] MySQL Verification Team
Hi Mr. He,

You have set a category for this report as a bug in the server. If that is so, we expect a test case consisting only of SQL queries.

If you think that a bug is in C# , then you need to set the category correct and send us also all data on the server.

If you think that a bug is in the client-server protocol, then we require tables that are involved, plus a program in C. In this case, in many cases, a test case in MySQL CLI can do the job.

All this should be repeatable on 8.0.31.

We hope that we have been clear enough.
[11 Nov 2022 20:09] Sergei Boguslavski
This is a server-side issue related to client-server protocol. If the current category is incorrect, please reassign it appropriately.

Please note that I am not Mr He. I just had the same issue, and I found that there is a bug already reported for MySQL when I was looking for a solution.
[14 Nov 2022 13:04] MySQL Verification Team
Hi Mr. Boguslavski,

We believe you that this is a bug.

However , we need a repeatable test case. If it is to be run on the client-side, then it should be in C or C++.

Then, and only then, we can try to repeat it and determine whether it is bug or not ......
[15 Nov 2022 7:06] Sergei Boguslavski
Sample app to reproduce the issue, this time in C

Attachment: mysqltest.cpp (text/plain), 3.90 KiB.

[15 Nov 2022 13:10] MySQL Verification Team
Hi Mr. Boguslavski,

Thank you for your test case.

We took a look at it and we have not noticed that you have called the appropriate function. Furthermore, the context of your code is not designed for the call of mysql_more_results() !!!!!
[15 Nov 2022 17:33] Sergei Boguslavski
Dear MySQL Verification Team,

My code is more or less copy-pasted from the sample that I found at this page https://dev.mysql.com/doc/c-api/8.0/en/c-api-multiple-queries.html. Are these samples correct?

I would really appreciate if you could you be more specific about the "appropriate function" that is not called, and why the context of my code "is not designed for the call of mysql_more_result". What is missing? CLIENT_MULTI_STATEMENTS flag is passed to the connection.

Have you tried running it? It works. You might have noticed that the first script it executes has multiple results. They are processed correctly.
[16 Nov 2022 12:00] MySQL Verification Team
Hi,

All that you need is in the documentation and in our test cases.
[21 Nov 2022 19:57] Sergei Boguslavski
mysql -h localhost -u root -p --delimiter "/*|*/"  < mysqltest.sql  # no output is produced after the second binlog statement

Attachment: mysqltest.sql (application/octet-stream, text), 612 bytes.