Skip to content

Implement RETURN_GENERATED_KEYS support via DML RETURNING rewrite - #829

Merged
staticlibs merged 3 commits into
duckdb:mainfrom
rmannibucau:dev/Statement.RETURN_GENERATED_KEYS
Aug 24, 2026
Merged

Implement RETURN_GENERATED_KEYS support via DML RETURNING rewrite#829
staticlibs merged 3 commits into
duckdb:mainfrom
rmannibucau:dev/Statement.RETURN_GENERATED_KEYS

Conversation

@rmannibucau

Copy link
Copy Markdown
Contributor

Background: using JDBC API with RETURN_GENERATED_KEYS in the original application totally broke with duckdb, this provides a fallback which should work most of the time

side note: no issue to close my PR if you want to implement it totally differently, I'm not ultra proud of the string parsing

@staticlibs staticlibs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR! It looks good to me, I added just one question and a couple of nits.

The parsing code may be not elegant, but I can see no other easy ways to implement it. We don't want to introduce real Java-level SQL parsers, as in future we are going to add a native parser extension to handle date time literals like {d 'yyyy-mm-dd'}. At that point going to look into changing current ad-hoc rewriting code to use a parser extension too.

Comment thread src/main/java/org/duckdb/DuckDBPreparedStatement.java Outdated
Comment thread src/main/java/org/duckdb/DuckDBPreparedStatement.java
Comment thread src/test/java/org/duckdb/TestPrepare.java Outdated
@rmannibucau

Copy link
Copy Markdown
Contributor Author

tried to address the feedbacks

@staticlibs

Copy link
Copy Markdown
Member

Thanks for the update!

@staticlibs
staticlibs merged commit 0b1be33 into duckdb:main Aug 24, 2026
15 checks passed
@rmannibucau
rmannibucau deleted the dev/Statement.RETURN_GENERATED_KEYS branch August 24, 2026 20:11
staticlibs added a commit that referenced this pull request Aug 24, 2026
This is a backport of the PR #829 to `v1.5.5` stable branch.

Co-Authored-By: Romain Manni-Bucau <rmannibucau@gmail.com>
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.

2 participants