Repository navigation
Conversation
JDBC defines a maxRows value of zero as unlimited. The client-side row limiting introduced in spring-projectsgh-34709 instead treats it as a limit of zero, discarding all rows when processing results through a RowMapper, RowCallbackHandler, or Stream. Apply client-side limits only for positive maxRows values. See spring-projectsgh-34709 Signed-off-by: Hyunwoo Jung <hyunwoojung@kakao.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
JDBC defines a
maxRowsvalue of zero as unlimited, but the client-side row limiting introduced in #34709 treats it as a limit of zero. As a result, queries usingJdbcTemplateandJdbcClientcan discard all rows returned by the driver whenmaxRowsis set to 0. This appears to be a regression from the behavior in 6.2.x.Problem
JdbcTemplatecorrectly passes zero to the driver throughStatement#setMaxRows(0). However, the client-side row limiting added in #34709 only bypasses the limit whenmaxRowsis -1.For zero, the condition
rowNum < maxRowsis false before the first row is processed, so the affected result-processing paths stop before handling any of the rows returned by the driver.These checks exist in
RowMapperResultSetExtractorand in theRowCallbackHandlerand stream adapters withinJdbcTemplate.JdbcClientoperations that delegate to these paths are also affected when usingwithMaxRows(0).Fix
Apply client-side limits only for positive
maxRowsvalues inRowMapperResultSetExtractorand in theRowCallbackHandlerand stream adapters withinJdbcTemplate.Preserve the driver-side handling of -1 (not passed on) and 0 (passed on as no limit), and clarify the meaning of zero in the Javadoc.
Tests
Add regression tests for
maxRows=0acrossRowMapper,RowCallbackHandler, and stream-based result processing. The tests verify that all expected rows are returned. An H2 integration test also verifies thatwithMaxRows(0)onJdbcClientreturns all matching rows.Related Issues
Reference