Bug #81468 MySQL server fails to rewrite batch insert when column name contains word select
Submitted: 17 May 2016 16:31 Modified: 19 May 2016 11:09
Reporter: Xander Garbett Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.36 and 6.0.2 tested OS:Any
Assigned to: Alexander Soklakov 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.