Bug #101389 getwarnings should check warning count before sending SHOW
Submitted: 30 Oct 2020 0:30 Modified: 30 Oct 2020 5:23
Reporter: Trey Raymond Email Updates:
Status: Verified 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