forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit41486c4
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 parent9d6d8d7 commit41486c4
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 | |
---|---|---|---|
| |||
360 | 360 |
| |
361 | 361 |
| |
362 | 362 |
| |
| 363 | + | |
363 | 364 |
| |
364 | 365 |
| |
365 | 366 |
| |
|
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 | |
---|---|---|---|
| |||
1029 | 1029 |
| |
1030 | 1030 |
| |
1031 | 1031 |
| |
1032 |
| - | |
| 1032 | + | |
1033 | 1033 |
| |
| 1034 | + | |
| 1035 | + | |
1034 | 1036 |
| |
1035 | 1037 |
| |
1036 | 1038 |
| |
|
0 commit comments
Comments
(0)