Backport: Fix DatabaseMetaData.getIndexInfo() CachedRowSet invalid cursor position exception (#2763)#2780
Merged
Ananya2 merged 1 commit intorelease/13.2from Sep 23, 2025
Merged
Conversation
…ion exception (#2763) * Fix DatabaseMetaData.getIndexInfo() CachedRowSet invalid cursor position exception * removed unused imports * Fix ADO getIndexInfo test failures * Reverted INDEX_QUALIFIER to return table name instead of database name as per sp_statistics official documentation * Fix catalog switching in getIndexInfo to handle cross-database queries and fix ADO regression test failure * Fix Azure DW getIndexInfo to include columnstore indexes via UNION ALL * Fix getIndexInfo ORDER BY clause to match sp_statistics server implementation
muskan124947
approved these changes
Sep 23, 2025
machavan
approved these changes
Sep 23, 2025
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.
This PR backports the fix from #2763 into the release/13.2 branch.
Overview
This PR updates DatabaseMetaData.getIndexInfo() to address an issue where calling ResultSet.next() after exhaustion could throw an invalid cursor position exception.
The fix removes the use of CachedRowSet for combining sp_statistics and columnstore index results, and instead uses a
UNION ALLquery. This ensures standard JDBC cursor behavior while keeping columnstore index support intact.Problem Description
The current implementation uses
CachedRowSetto merge results fromsp_statisticsand Columnstore index queries. However,CachedRowSethas stricter cursor validation thanSQLServerResultSet:This causes SQLException: Invalid cursor position when next() is called after the ResultSet has been fully enumerated, which differs from standard JDBC behavior where such calls should simply return false.
Root Cause
Columnstore index support was first added in #2598
to address missing indexes in sp_statistics results. That implementation relied on CachedRowSet to merge sp_statistics output with additional Columnstore index query results, which in turn caused the cursor positioning issue.
Solution
This eliminates intermediate result set handling and ensures consistent behavior across environments.
Testing