forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit763d65a
committed
Fix bug in nbtree array primitive scan scheduling.
A bug in nbtree's handling of primitive index scan scheduling could leadto wrong answers when a scrollable cursor was used with an index scanthat had a SAOP index qual. Wrong answers were only possible when thescan direction changed after a primitive scan was scheduled, but before_bt_next was asked to fetch the next tuple in line (i.e. for things tobreak, _bt_next had to be denied the opportunity to step off the page inthe same direction as the one used when the primscan was scheduled).Furthermore, the issue only occurred when the page in question happenedto be the first page to be visited by the entire top-level scan; theissue hinged upon the cursor backing up to the absolute beginning of thekey space that it returns tuples from (fetching in the opposite scandirection across a "primitive scan boundary" always worked correctly).To fix, make _bt_next unset the "needs primitive index scan" flag whenit detects that the current scan direction is not the one that was usedby _bt_readpage back when the primitive scan in question was scheduled.This fixes the cases that are known to be faulty, and also seems like agood idea on general robustness grounds.Affected scrollable cursor cases now avoid a spurious primitive indexscan when they fetch backwards to the absolute start of the key space tobe visited by their cursor. Fetching backwards now only returns thosetuples at the start of the scan, as expected. It'll also be okay toonce again fetch forwards from the start at that point, since the scanwill be left in a state that's exactly consistent with the state it wasin before any tuples were ever fetched, as expected.Oversight in commit5bf748b, which enhanced nbtree ScalarArrayOpexecution.Author: Peter Geoghegan <pg@bowt.ie>Discussion:https://postgr.es/m/CAH2-Wznv49bFsE2jkt4GuZ0tU2C91dEST=50egzjY2FeOcHL4Q@mail.gmail.comBackpatch: 17-, where commit5bf748b first appears.1 parent2d5fe51 commit763d65a
File tree
3 files changed
+21
-8
lines changed- src
- backend/access/nbtree
- include/access
3 files changed
+21
-8
lines changedLines changed: 13 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1568 | 1568 |
| |
1569 | 1569 |
| |
1570 | 1570 |
| |
| 1571 | + | |
1571 | 1572 |
| |
1572 | 1573 |
| |
1573 | 1574 |
| |
| |||
1594 | 1595 |
| |
1595 | 1596 |
| |
1596 | 1597 |
| |
1597 |
| - | |
1598 | 1598 |
| |
1599 | 1599 |
| |
1600 | 1600 |
| |
| |||
2088 | 2088 |
| |
2089 | 2089 |
| |
2090 | 2090 |
| |
2091 |
| - | |
| 2091 | + | |
2092 | 2092 |
| |
2093 | 2093 |
| |
2094 | 2094 |
| |
| |||
2109 | 2109 |
| |
2110 | 2110 |
| |
2111 | 2111 |
| |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
2112 | 2121 |
| |
2113 | 2122 |
| |
2114 | 2123 |
| |
| |||
2118 | 2127 |
| |
2119 | 2128 |
| |
2120 | 2129 |
| |
| 2130 | + | |
| 2131 | + | |
2121 | 2132 |
| |
2122 | 2133 |
| |
2123 | 2134 |
| |
|
Lines changed: 8 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1800 | 1800 |
| |
1801 | 1801 |
| |
1802 | 1802 |
| |
1803 |
| - | |
| 1803 | + | |
1804 | 1804 |
| |
1805 | 1805 |
| |
1806 | 1806 |
| |
| |||
2400 | 2400 |
| |
2401 | 2401 |
| |
2402 | 2402 |
| |
2403 |
| - | |
2404 |
| - | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
2405 | 2407 |
| |
2406 | 2408 |
| |
2407 | 2409 |
| |
| |||
3458 | 3460 |
| |
3459 | 3461 |
| |
3460 | 3462 |
| |
3461 |
| - | |
| 3463 | + | |
3462 | 3464 |
| |
3463 | 3465 |
| |
3464 | 3466 |
| |
| |||
4062 | 4064 |
| |
4063 | 4065 |
| |
4064 | 4066 |
| |
4065 |
| - | |
| 4067 | + | |
| 4068 | + | |
4066 | 4069 |
| |
4067 | 4070 |
| |
4068 | 4071 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1078 | 1078 |
| |
1079 | 1079 |
| |
1080 | 1080 |
| |
1081 |
| - | |
1082 | 1081 |
| |
1083 | 1082 |
| |
1084 | 1083 |
| |
|
0 commit comments
Comments
(0)