forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd4724e9
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 parent83ba050 commitd4724e9
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 | |
---|---|---|---|
| |||
371 | 371 |
| |
372 | 372 |
| |
373 | 373 |
| |
| 374 | + | |
374 | 375 |
| |
375 | 376 |
| |
376 | 377 |
| |
|
Lines changed: 16 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
532 | 532 |
| |
533 | 533 |
| |
534 | 534 |
| |
| 535 | + | |
| 536 | + | |
535 | 537 |
| |
536 | 538 |
| |
537 | 539 |
| |
| |||
591 | 593 |
| |
592 | 594 |
| |
593 | 595 |
| |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
594 | 604 |
| |
595 | 605 |
| |
596 | 606 |
| |
| |||
644 | 654 |
| |
645 | 655 |
| |
646 | 656 |
| |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
647 | 662 |
| |
648 |
| - | |
| 663 | + | |
649 | 664 |
| |
650 | 665 |
| |
651 | 666 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
903 | 903 |
| |
904 | 904 |
| |
905 | 905 |
| |
906 |
| - | |
| 906 | + | |
907 | 907 |
| |
| 908 | + | |
| 909 | + | |
908 | 910 |
| |
909 | 911 |
| |
910 | 912 |
| |
|
0 commit comments
Comments
(0)