MDEV-40479 SELECT, order by desc, on partitioned table leads to incorrect results - #5708
Conversation
dda1238 to
9389c55
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
Please squash your two commits. And avoid excess lines in .test files.
a01daed to
0d885fc
Compare
gkodinov
left a comment
There was a problem hiding this comment.
mostly looks good. but there's an extra file changed that shouldn't be a part of this.
…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
0d885fc to
4f2166e
Compare
gkodinov
left a comment
There was a problem hiding this comment.
LGTM. An optional suggestion below. Please stand by for the final review.
| # | ||
| # MDEV-40479: Reverse prefix scan across partitions | ||
| # | ||
| CREATE TABLE t1 (a INT,b INT,c INT,PRIMARY KEY(a,c),KEY(b,c)) PARTITION BY RANGE(c) (PARTITION p1 VALUES LESS THAN(10),PARTITION p2 VALUES LESS THAN(20)); |
There was a problem hiding this comment.
just a suggestion: I'd split the line at around column 80. Ideally, to improve visibility, I would try to make a "nice display" and split by logical parts, e.g.:
CREATE TABLE t1 (a INT, b INT, c INT,
PRIMARY KEY(a, c),
KEY(b, c))
PARTITION BY RANGE(c)
(PARTITION p1 VALUES LESS THAN(10),
PARTITION p2 VALUES LESS THAN(20));
|
claude: Review of 0a4bf82 (MDEV-40479)The fix is correct. In the test, key 0 is the PK Suggestions:
Existing issue, not caused by this commit: |
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
Changes
ha_partition::handle_unordered_prev()compared the unordered prefix using key number 0 rather than the active index. Useactive_indexso the comparison matches the index that produced the row.Regression coverage
The regression is integrated into the existing
main.partition_ordertest. It scans a RANGE-partitioned table using a secondary(b,c)index and checks thatORDER BY c DESCreturns all three values: 15, 11, and 6.mysql-test/main/partition_order.testmysql-test/main/partition_order.resultValidation
On
12.3at881b64e8add374802e1871814dd0a3a673a9b3e6:main.partition_orderandmain.selectpassed, with no test-state cleanup failures.main.partition_orderalso passed with--ps-protocol.git diff --checkpassed.