Skip to content

Honor JDBC getMoreResults result lifecycle - #906

Merged
staticlibs merged 2 commits into
duckdb:mainfrom
hutiefang76:frank/nextten-dd-results-20261009-01a11186
Oct 10, 2026
Merged

staticlibs merged 2 commits into
duckdb:mainfrom
hutiefang76:frank/nextten-dd-results-20261009-01a11186

Conversation

@hutiefang76

Copy link
Copy Markdown
Contributor

getMoreResults() currently returns false while leaving the current ResultSet open and the previous update count visible. A normal JDBC result loop can therefore see a spurious update count after reaching the end of the results. Move the statement to the end-of-results state, close results according to the requested flag, and reject invalid flags.

KEEP_CURRENT_RESULT leaves the returned object usable; a subsequent CLOSE_CURRENT_RESULT does not close that kept object, while CLOSE_ALL_RESULTS and statement close release it. State is detached before closing so closeOnCompletion can safely close the statement.

Regression coverage includes result sets, update counts, all three flags, rejected calls, statement reuse, kept-result cleanup and closeOnCompletion on Statement and PreparedStatement. Five regressions failed against the original source. An incremental build and the official TestPrepare (37 tests) and TestClosure (32 tests) runners passed on JDK 17. This is focused validation, not a full-suite result; the independent writable-vector validity race is addressed in #904.

AI assistance: DeepSeek assisted implementation and initial review. The full patch and actual regression output were checked before submission.

Signed-off-by: hutiefang76 <137664623+hutiefang76@users.noreply.github.com>

@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.

Thanks for the PR! It looks good to me, just please change the exception creation bit.

Comment thread src/main/java/org/duckdb/DuckDBPreparedStatement.java Outdated
Signed-off-by: hutiefang76 <137664623+hutiefang76@users.noreply.github.com>
@staticlibs
staticlibs merged commit bc16ad5 into duckdb:main Oct 10, 2026
43 of 45 checks passed
staticlibs added a commit that referenced this pull request Oct 10, 2026
This is a baclport of the PR #906 to `v2.0-variegata` branch.

Co-Authored-By: hutiefang76 <137664623+hutiefang76@users.noreply.github.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