Skip to content

Conversation

knoxg
Copy link
Contributor

@knoxg knoxg commented Sep 14, 2025

Ticket in CONJ issue tracker: https://jira.mariadb.org/browse/CONJ-1283

Earlier ticket: https://jira.mariadb.org/browse/CONJ-1238

It appears that this commit introduced a bug on the newly-reinstated rewriteBatchedStatements connection property. The commit landed between the 3.5.5 and 3.5.6 releases.

When the following query is rewritten, only the initial (?,?) block should be repeated in the rewritten SQL:

INSERT INTO b VALUES (?,?) AS v ON DUPLICATE KEY UPDATE b.a=(v.a)

but it looks like we're repeating from the first parenthesis to the very last parenthesis

I think this might be an intentional change in order to handle multiple VALUES blocks; e.g.

INSERT INTO b VALUES (?,?), (?,?)

which has been added as a test case in ClientRewritableParserTest here: https://github.com/mariadb-corporation/mariadb-connector-j/blob/main/src/test/java/org/mariadb/jdbc/unit/util/ClientParserRewritableTest.java#L93

but the original rewriteBatchedStatements code didn't rewrite those statements, so I've reverted back to that behaviour in the fix.

The fix in this PR reverts back to the previous parenthesis-handling behaviour in ClientParser, but keeps the other changes on that commit. I've kept the fix simple as I think we'd want to get this merged ASAP to fix the bug in the main branch.

Let me know if we need to include multiple VALUES blocks in the repeating section. Should be able to do that and still support brackets in the DUPLICATE KEY UPDATE clause, but it will be a more complicated fix in the ClientParser code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant