Skip to content

fix(bq jdbc): ensure getMoreResults() always moves the cursor#12353

Merged
logachev merged 2 commits intomainfrom
kirl/infinite_tcl_results_retrieval
Apr 1, 2026
Merged

fix(bq jdbc): ensure getMoreResults() always moves the cursor#12353
logachev merged 2 commits intomainfrom
kirl/infinite_tcl_results_retrieval

Conversation

@logachev
Copy link
Copy Markdown
Contributor

@logachev logachev commented Apr 1, 2026

Statement.execute() method when running single-statement that is not properly handling getMoreResults(). For these queries there is no parentJob, so it always skips any meaningful action (close current statement, try to get next job, reset fields if no next job). Moving parentJob non-null check to getNextJob() method. That way it properly resets fields.

Without that, JDBC standard way of fetching all results ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
results in infinite loop.

Added 3 tests to validate this behavior for 3 types: TCL/DDL/SELECT.

@logachev logachev requested review from a team as code owners April 1, 2026 04:59
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors BigQueryStatement by moving the null check for parentJobId into the getNextJob method and removing it from getMoreResults. It also includes a refactor of connection URI constants and adds new integration tests to verify the behavior of getMoreResults for SELECT, INSERT, and TCL statements. A review comment suggests using try-with-resources in the new test code to ensure robust resource management and prevent potential leaks.

@logachev logachev merged commit ac1f0f4 into main Apr 1, 2026
105 of 107 checks passed
@logachev logachev deleted the kirl/infinite_tcl_results_retrieval branch April 1, 2026 16:47
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