Details
-
Task
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
1.1.8
-
None
-
Long network delay between client and server.
-
Sprint connector/j 1.3.0
Description
CONJ-99 introduced support for the rewriteBatchedStatements=true JDBC URL parameter. This rewrites batched prepared statements into a single statement, when using PreparedStatement.addBatch() & executeBatch().
This works fine for INSERT statements which do not specify an ON DUPLICATE KEY UPDATE clause. However for statements which do, the generated SQL cannot be parsed because the ON DUPLICATE ... clause is repeated for each set of values. E.g. for a prepared statement such as:
prep.sql |
INSERT INTO my_table (pkey, col1) VALUES (?, ?) ON DUPLICATE KEY UPDATE col1 = VALUES(col1)
|
after setting the parameters multiple times and calling addBatch() then executeBatch(), the generated SQL looks like this:
gen.sql |
INSERT INTO my_table (pkey, col1) VALUES (1, 'a') ON DUPLICATE KEY UPDATE col1 = VALUES(col1),(2,'b') ON DUPLICATE KEY UPDATE col1 = VALUES(col1), ...
|
I've written a small patch with a test case to duplicate the issue, along with a suggested fix. The test will fail against 1.1.8 but should pass with the suggested fix.