-
Notifications
You must be signed in to change notification settings - Fork 614
[JDBC] StatementImpl #2591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JDBC] StatementImpl #2591
Conversation
… specific parameters.
|
/windsurf review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issues with the JDBC StatementImpl related to maxRows handling and adds comprehensive test coverage. The main purpose is to replace the problematic max_result_rows server setting approach with a client-side row limiting mechanism that provides more reliable behavior.
- Implements client-side row limiting in
ResultSetImplto honormaxRowswithout relying on server settings - Adds feature management for unsupported JDBC operations with configurable behavior
- Enhances test coverage for
maxRows, unsupported operations, and fetch size functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| StatementTest.java | Comprehensive test suite for maxRows behavior, unsupported operations, and fetch size validation |
| JdbcConfiguration.java | Added utility methods for feature flag management and max result rows configuration |
| StatementImpl.java | Enhanced with feature manager integration and improved maxRows handling with server setting fallback |
| ResultSetImpl.java | Client-side maxRows enforcement and improved fetch direction handling |
| DriverProperties.java | New configuration properties for unsupported value handling and max result rows usage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return false; | ||
| } | ||
|
|
||
| if (maxRows > 0 && rowPos == maxRows) { |
Copilot
AI
Sep 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition rowPos == maxRows will prevent fetching the last allowed row. If maxRows is 5, this will stop at row 4 instead of row 5. The condition should be rowPos >= maxRows to correctly limit to the specified number of rows.
| if (maxRows > 0 && rowPos == maxRows) { | |
| if (maxRows > 0 && rowPos >= maxRows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rows start with 1. 0 is before we do any next() call.
Lets say maxRows = 2
rowPos = 0
next() - ( rowPos < maxRows)
rowPos = 1 - we got first row
next() (rowPos < maxRows)
rowPos = 2 - we got second row
at this point should return isLast true
so it will not prevent reading row, but will make state not accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other comments (1)
- jdbc-v2/src/test/java/com/clickhouse/jdbc/StatementTest.java (854-854) The expected count should use the `expectedRows` variable (100001) instead of the hardcoded value 1001 for consistency with the rest of the test and to make it more maintainable.
💡 To request another review, post a new comment with "/windsurf-review".
| // https://clickhouse.com/docs/en/operations/settings/query-complexity#result-overflow-mode | ||
| assertTrue(count > 0 && count < 100001); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is checking the count but not verifying that lastRow matches the count. For consistency, you should add an assertion to verify that lastRow == count since both should be equal when processing all rows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion not applicable because no exact match expected.
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
|



Summary
maxRowsproblem usingmax_result_rowssetting that doesn't guarantee hard limit and may cause exception if user is not allowed to change settingsmaxRowsaddedCloses #2532
Closes #2582
Checklist
Delete items not relevant to your PR: