Bug #81468 MySQL server fails to rewrite batch insert when column name contains word select
Submitted: 17 May 2016 16:31 Modified: 5 Nov 2022 2:03
Reporter: Xander Garbett Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.36 and 6.0.2 tested OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[17 May 2016 16:31] Xander Garbett
Description:
When testing for whether a statement is rewriteable or not, the Prepared Statement canRewrite method will return false if any of the columns contain the substring "select".

This leads to statements that should be rewritten and batchable to being inserted one by one.

How to repeat:
Create a Prepared Statement with a query that includes a column with substring "select" in one of the columns.

Suggested fix:
Changing the parsing strategy not to simply check for the existence of 'select' but parse more carefully to, possibly by ignoring strings between parentheses.
[17 May 2016 16:34] Xander Garbett
Having looked at the Connector/J source, it appears that the bug is on line 5077 in PreparedStatement source for release 5.1.

Link is: https://github.com/mysql/mysql-connector-j/blob/release/5.1/src/com/mysql/jdbc/PreparedSta...
[19 May 2016 11:09] Chiranjeevi Battula
Hello Xander Garbett,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.
[16 Oct 2017 8:36] Alexander Soklakov
Bug#88105 is marked as duplicate of this one. Please look there for possible workaround.
[1 Apr 2022 21:17] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 8.0.29 changelog:

"A PreparedStatement could not be rewritten for batch insert if any table column involved contained "select" as a substring in the column name."