Bug #101389 getwarnings should check warning count before sending SHOW
Submitted: 30 Oct 2020 0:30 Modified: 11 Dec 2021 18:23
Reporter: Trey Raymond Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0, 5.1 OS:Any
Assigned to: CPU Architecture:Any

[30 Oct 2020 0:30] Trey Raymond
Description:
refs
https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/user-impl/java/com/my...

https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/protocol-impl/java/co...

https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/protocol-impl/java/co...

specifically this line
https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/protocol-impl/java/co...

this function will send a 'show warnings' statement to the server even if the statement returned warningcount=0, which is quite expensive.  it should only send the SHOW query if count>0, else it already knows there are zero results.

How to repeat:
call getwarnings after any zero-warning statement, it will still run SHOW.
or use one of the popular libs like hibernate, jooq, etc which all suffer terribly from this.

Suggested fix:
wrap an if around that SHOW call.  easy fix!
[30 Oct 2020 5:23] MySQL Verification Team
Hello Trey Raymond,

Thank you for the report and feedback.

regards,
Umesh
[11 Dec 2021 18:23] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 8.0.28 changelog: 

"getWarnings() always sent a SHOW WARNINGS query to the server. With this fix, the query is sent only if there really are warnings to be shown, in order to save resources."
[24 Jan 2022 12:29] Alexander Soklakov
Bug#77394 is marked as a duplicate of this one.