forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit486c2ea
committed
Fix nbtree array unsatisfied inequality check.
_bt_advance_array_keys didn't take sufficient care at the point where itdecides whether to start a new primitive index scan based on a call to_bt_check_compare against finaltup (a call with the scan directionflipped around). The final decision was conditioned on rules about howthe scan key offset sktrig that initially triggered array advancement(passed to _bt_advance_array_keys from its _bt_checkkeys caller)compared to the offset set by its own _bt_check_compare finaltup call.This approach was faulty, in that it allowed _bt_advance_array_keys toincorrectly start a new primitive index scan, that landed on the sameleaf page (on assert-enabled builds it led to an assertion failure).In general, scans with array keys are expected to never have to read thesame leaf page more than once (barring cases involving cursors, andcases where the scan restores a marked position for the inner side of amerge join). This principle was established by commit5bf748b.To fix, make the final decision based on whether the scan key offset setby the _bt_check_compare finaltup call is an offset to an inequalitystrategy scan key. An unsatisfied required inequality strategy scan keyindicates that all of the scan's required equality strategy scan keysmust also be satisfied by finaltup (not just by caller's tuple), andthat there is a decent chance that _bt_first will be able to repositionthe scan to a position many leaf pages ahead of the current leaf page.Oversight in commit5bf748b.Discussion:https://postgr.es/m/CAH2-Wz=DyHbcg7o6zXqzyiin8WE8vzk4tvU8Lrnh-a=EAvO0TQ@mail.gmail.com1 parentdbca346 commit486c2ea
1 file changed
+10
-20
lines changedLines changed: 10 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2368 | 2368 |
| |
2369 | 2369 |
| |
2370 | 2370 |
| |
2371 |
| - | |
2372 |
| - | |
2373 |
| - | |
2374 |
| - | |
2375 |
| - | |
2376 |
| - | |
2377 |
| - | |
2378 |
| - | |
2379 |
| - | |
2380 |
| - | |
2381 |
| - | |
2382 |
| - | |
2383 |
| - | |
2384 |
| - | |
2385 |
| - | |
2386 |
| - | |
2387 |
| - | |
| 2371 | + | |
| 2372 | + | |
2388 | 2373 |
| |
2389 | 2374 |
| |
2390 | 2375 |
| |
2391 |
| - | |
2392 |
| - | |
| 2376 | + | |
2393 | 2377 |
| |
2394 |
| - | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
2395 | 2385 |
| |
2396 | 2386 |
| |
2397 | 2387 |
| |
|
0 commit comments
Comments
(0)