forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb36d72c
committed
Fix btmarkpos/btrestrpos array key wraparound bug.
nbtree's mark/restore processing failed to correctly handle an edge caseinvolving array key advancement and related search-type scan key state.Scans with ScalarArrayScalarArrayOpExpr quals requiring mark/restoreprocessing (for a merge join) could incorrectly conclude that anaffected array/scan key must not have advanced during the time betweenmarking and restoring the scan's position.As a result of all this, array key handling within btrestrpos could skipa required call to _bt_preprocess_keys(). This confusion allowed laterprimitive index scans to overlook tuples matching the true current arraykeys. The scan's search-type scan keys would still have spurious valuescorresponding to the final array element(s) -- not values matching thefirst/now-current array element(s).To fix, remember that "array key wraparound" has taken place during theongoing btrescan in a flag variable stored in the scan's state, and usethat information at the point where btrestrpos decides if another callto _bt_preprocess_keys is required.Oversight in commit70bc583, which taught nbtree to handle array keysduring mark/restore processing, but missed this subtlety. That commitwas itself a bug fix for an issue in commit9e8da0f, which taughtnbtree to handle ScalarArrayOpExpr quals natively.Author: Peter Geoghegan <pg@bowt.ie>Discussion:https://postgr.es/m/CAH2-WzkgP3DDRJxw6DgjCxo-cu-DKrvjEv_ArkP2ctBJatDCYg@mail.gmail.comBackpatch: 11- (all supported branches).1 parentd642598 commitb36d72c
File tree
3 files changed
+20
-2
lines changed- src
- backend/access/nbtree
- include/access
3 files changed
+20
-2
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
366 | 366 |
| |
367 | 367 |
| |
368 | 368 |
| |
| 369 | + | |
369 | 370 |
| |
370 | 371 |
| |
371 | 372 |
| |
|
Lines changed: 16 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
534 | 534 |
| |
535 | 535 |
| |
536 | 536 |
| |
| 537 | + | |
| 538 | + | |
537 | 539 |
| |
538 | 540 |
| |
539 | 541 |
| |
| |||
593 | 595 |
| |
594 | 596 |
| |
595 | 597 |
| |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
596 | 606 |
| |
597 | 607 |
| |
598 | 608 |
| |
| |||
646 | 656 |
| |
647 | 657 |
| |
648 | 658 |
| |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
649 | 664 |
| |
650 |
| - | |
| 665 | + | |
651 | 666 |
| |
652 | 667 |
| |
653 | 668 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
628 | 628 |
| |
629 | 629 |
| |
630 | 630 |
| |
631 |
| - | |
| 631 | + | |
632 | 632 |
| |
| 633 | + | |
| 634 | + | |
633 | 635 |
| |
634 | 636 |
| |
635 | 637 |
| |
|
0 commit comments
Comments
(0)