Repository navigation
fix: maintain covering secondary indexes - #25342
Merged
XuPeng-SH merged 8 commits intoJul 2, 2026
Merged
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
commented
Jul 2, 2026
XuPeng-SH
left a comment
Contributor
Author
There was a problem hiding this comment.
Re-reviewing the latest head: the earlier blockers look resolved now.
- The NULL-semantics problem on covering index-only scans is fixed: the latest
tryIndexOnlyScan()keeps the original leading predicate as a residual recheck whenserial_fullis involved and the lookup can compare against runtime NULL. - The missing regular-index guard in the join/runtime-filter path is also fixed:
applyIndicesForJoins()now excludes non-regular and spatial/rtree indexes from the generic hidden-index rewrite path.
At this point I don’t see a remaining substantive correctness issue. The remaining gaps are at most nice-to-have extra coverage, not blockers.
LGTM.
ghost
approved these changes
Jul 2, 2026
3 of 7 tasks
This was referenced Jul 2, 2026
Closed
Closed
1 task done
Closed
1 task done
This branch was previously 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.
What type of PR is this?
Which issue(s) this PR fixes:
fixes #25341
What this PR does / why we need it:
This fixes the inconsistent secondary-index path for tables whose regular secondary index covers the full composite primary key.
The root invariant is: if a regular hidden index table exists and the optimizer can read it, DML must maintain it. Previously
getValidIndexesskipped some regular indexes when the index parts covered the full primary key, but the optimizer could still choose the existing hidden index table for predicates such asstatus = 'active'orstatus IN (...), producing empty results from a stale index table.Changes:
serial_fullfor non-unique multi-part regular indexes, andserialfor unique or single-part lookups.serial_fulllookup rewrites, equality/IN/range predicates, and unique-index behavior.ON DUPLICATE KEY UPDATE.Local validation:
git diff --checkmake cgoCGO_CFLAGS="-I$(pwd)/cgo -I$(pwd)/thirdparties/install/include" CGO_LDFLAGS="-L$(pwd)/thirdparties/install/lib -lusearch_c" DYLD_LIBRARY_PATH="$(pwd)/cgo:$(pwd)/thirdparties/install/lib" go test -ldflags="-extldflags '-L$(pwd)/cgo -lmo -L$(pwd)/thirdparties/install/lib -Wl,-rpath,@executable_path/lib'" -count=1 -timeout 180s ./pkg/sql/planCGO_CFLAGS="-I$(pwd)/cgo -I$(pwd)/thirdparties/install/include" CGO_LDFLAGS="-L$(pwd)/thirdparties/install/lib -lusearch_c" DYLD_LIBRARY_PATH="$(pwd)/cgo:$(pwd)/thirdparties/install/lib" go test -ldflags="-extldflags '-L$(pwd)/cgo -lmo -L$(pwd)/thirdparties/install/lib -Wl,-rpath,@executable_path/lib'" -count=1 -timeout 120s ./pkg/sql/colexec/multi_updateCGO_CFLAGS="-I$(pwd)/cgo -I$(pwd)/thirdparties/install/include" CGO_LDFLAGS="-L$(pwd)/thirdparties/install/lib -lusearch_c" DYLD_LIBRARY_PATH="$(pwd)/cgo:$(pwd)/thirdparties/install/lib" go build -ldflags="-extldflags '-L$(pwd)/cgo -lmo -L$(pwd)/thirdparties/install/lib -Wl,-rpath,@executable_path/lib'" ./pkg/sql/planCGO_CFLAGS="-I$(pwd)/cgo -I$(pwd)/thirdparties/install/include" CGO_LDFLAGS="-L$(pwd)/thirdparties/install/lib -lusearch_c" DYLD_LIBRARY_PATH="$(pwd)/cgo:$(pwd)/thirdparties/install/lib" go vet -ldflags="-extldflags '-L$(pwd)/cgo -lmo -L$(pwd)/thirdparties/install/lib -Wl,-rpath,@executable_path/lib'" ./pkg/sql/plan