Bug #89733 mysqlclient does not return correct warning_count after ping()
Description:
This behaves differently with 5.6 and 5.7 client libraries:
mysql_real_query(mysql, "FOOBAR", strlen("FOOBAR"));
printf("Got %u warnings\n", mysql_warning_count(mysql));
mysql_ping(mysql);
printf("Got %u warnings\n", mysql_warning_count(mysql));
With 5.6: this returns zero warnings both times.
With 5.7: this returns zero warnings the first time and 1 the second time.
Closely related to:
Bug #89139 mysqlclient does not return correct mysql_insert_id after ping()
How to repeat:
======================================================
#include <mysql.h>
#include <stdio.h>
#include <string.h>
int main()
{
MYSQL *mysql, *conn;
mysql = mysql_init(NULL);
conn = mysql_real_connect(mysql, "127.0.0.1", "msandbox", "msandbox",
"test", 5720, NULL, 0);
if (conn == NULL)
{
printf("Uhoh: %s\n", mysql_error(mysql));
}
printf("Client compile version: %d\n", MYSQL_VERSION_ID);
printf("Client runtime version: %s\n", mysql_get_client_info());
printf("Server version: %lu\n", mysql_get_server_version(mysql));
printf("Query result: %d\n", mysql_real_query(mysql, "FOOBAR", strlen("FOOBAR")));
printf("Got %u warnings\n", mysql_warning_count(mysql));
printf("Sending ping\n");
mysql_ping(mysql);
printf("Got %u warnings\n", mysql_warning_count(mysql));
mysql_close(mysql);
}
======================================================
Output against different version:
+ ./mysql_bug_warningcount_57
Client compile version: 50721
Client runtime version: 5.7.21
Server version: 50720
Query result: 1
Got 0 warnings
Sending ping
Got 1 warnings
+ LD_LIBRARY_PATH=/opt/mysql/5.7.20/lib
+ ./mysql_bug_warningcount_57_fixed
Client compile version: 50720
Client runtime version: 5.7.20
Server version: 50720
Query result: 1
Got 0 warnings
Sending ping
Got 0 warnings
+ LD_LIBRARY_PATH=/opt/mysql/5.6.38/lib
+ ./mysql_bug_warningcount_56
Client compile version: 50638
Client runtime version: 5.6.38
Server version: 50720
Query result: 1
Got 0 warnings
Sending ping
Got 0 warnings
+ LD_LIBRARY_PATH=/opt/mysql/8.0.3/lib
+ ./mysql_bug_warningcount_80
Client compile version: 80003
Client runtime version: 8.0.3-rc
Server version: 50720
Query result: 1
Got 0 warnings
Sending ping
Got 1 warnings
The 57_fixed one has the patch from Bug #89139 applied.
Suggested fix:
Apply the patch from the linked bug.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: This behaves differently with 5.6 and 5.7 client libraries: mysql_real_query(mysql, "FOOBAR", strlen("FOOBAR")); printf("Got %u warnings\n", mysql_warning_count(mysql)); mysql_ping(mysql); printf("Got %u warnings\n", mysql_warning_count(mysql)); With 5.6: this returns zero warnings both times. With 5.7: this returns zero warnings the first time and 1 the second time. Closely related to: Bug #89139 mysqlclient does not return correct mysql_insert_id after ping() How to repeat: ====================================================== #include <mysql.h> #include <stdio.h> #include <string.h> int main() { MYSQL *mysql, *conn; mysql = mysql_init(NULL); conn = mysql_real_connect(mysql, "127.0.0.1", "msandbox", "msandbox", "test", 5720, NULL, 0); if (conn == NULL) { printf("Uhoh: %s\n", mysql_error(mysql)); } printf("Client compile version: %d\n", MYSQL_VERSION_ID); printf("Client runtime version: %s\n", mysql_get_client_info()); printf("Server version: %lu\n", mysql_get_server_version(mysql)); printf("Query result: %d\n", mysql_real_query(mysql, "FOOBAR", strlen("FOOBAR"))); printf("Got %u warnings\n", mysql_warning_count(mysql)); printf("Sending ping\n"); mysql_ping(mysql); printf("Got %u warnings\n", mysql_warning_count(mysql)); mysql_close(mysql); } ====================================================== Output against different version: + ./mysql_bug_warningcount_57 Client compile version: 50721 Client runtime version: 5.7.21 Server version: 50720 Query result: 1 Got 0 warnings Sending ping Got 1 warnings + LD_LIBRARY_PATH=/opt/mysql/5.7.20/lib + ./mysql_bug_warningcount_57_fixed Client compile version: 50720 Client runtime version: 5.7.20 Server version: 50720 Query result: 1 Got 0 warnings Sending ping Got 0 warnings + LD_LIBRARY_PATH=/opt/mysql/5.6.38/lib + ./mysql_bug_warningcount_56 Client compile version: 50638 Client runtime version: 5.6.38 Server version: 50720 Query result: 1 Got 0 warnings Sending ping Got 0 warnings + LD_LIBRARY_PATH=/opt/mysql/8.0.3/lib + ./mysql_bug_warningcount_80 Client compile version: 80003 Client runtime version: 8.0.3-rc Server version: 50720 Query result: 1 Got 0 warnings Sending ping Got 1 warnings The 57_fixed one has the patch from Bug #89139 applied. Suggested fix: Apply the patch from the linked bug.