Conversation
…rect results A descending scan of a partitioned table through a secondary index can stop early and omit qualifying rows. ha_partition::handle_unordered_prev() validates the unordered prefix with key number 0 instead of the active index. If the secondary index has a different layout from the primary key, that comparison can incorrectly signal end of file. Pass active_index to key_cmp_if_same() so the prefix comparison uses the index that produced the current row. The regression scans a RANGE-partitioned table using a secondary (b,c) index and checks that ORDER BY c DESC returns all three values: 15, 11, and 6. Bug report: https://jira.mariadb.org/browse/MDEV-40479
DerZc
force-pushed
the
fix-mdev-40479
branch
from
September 21, 2026 05:56
dda1238 to
9389c55
Compare
mariadb-YuchenPei
self-requested a review
September 21, 2026 06:43
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.
A descending scan of a partitioned table through a secondary index can stop early and omit qualifying rows.
Bug report: https://jira.mariadb.org/browse/MDEV-40479
Root cause
ha_partition::handle_unordered_prev() validates the unordered prefix with key number 0 instead of the active index. If the secondary index has a different layout from the primary key, that comparison can incorrectly signal end of file.
Changes
Regression coverage
The regression scans a RANGE-partitioned table using a secondary (b,c) index and checks that ORDER BY c DESC returns all three values: 15, 11, and 6.
mysql-test/main/partition_reverse_prefix_scan.testmysql-test/main/partition_reverse_prefix_scan.resultValidation
On
12.3at881b64e8add374802e1871814dd0a3a673a9b3e6:main.partition_reverse_prefix_scanfailed on the unchanged target branch and passed with this fix.main.select.