Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e85b20

Browse files
Avoid nbtree index scan SAOP scanBehind confusion.
Consistently reset so->scanBehind at the beginning of nbtree arrayadvancement, even during sktrig_required=false calls (calls where arrayadvancement is triggered by an unsatisfied non-required array scan key).Otherwise, it's possible for queries to fail to return all relevanttuples to the scan given a low-order required scan key that waspreviously deemed "satisfied" by a truncated high key attribute value.This only happened at the point where a later non-required array scankey needed to be "advanced" once on the next leaf page (that is, oncethe right sibling of the truncated high key page was reached).The underlying issue was that later code within _bt_advance_array_keysassumed that the so->scanBehind flag must have been set using thecurrent page's high key (not the previous page's high key). Any latersuccessful recheck call to _bt_check_compare would therefore spuriouslybe prevented from making _bt_advance_array_keys return true, based onthe faulty belief that the truncated attribute must be from the scan'scurrent tuple (i.e. the non-pivot tuple at the start of the next page)._bt_advance_array_keys would return false for the tuple, ultimatelyresulting in _bt_checkkeys failing to return a matching tuple.Oversight in commit5bf748b, which enhanced nbtree ScalarArrayOpexecution.Author: Peter Geoghegan <pg@bowt.ie>Discussion:https://postgr.es/m/CAH2-WzkJKncfqyAUTeuB5GgRhT1vhsWO2q11dbZNqKmvjopP_g@mail.gmail.comBackpatch: 17-, where commit5bf748b first appears.
1 parent7b8d45d commit9e85b20

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/backend/access/nbtree/nbtutils.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,12 @@ _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate,
18001800
all_required_satisfied= true,
18011801
all_satisfied= true;
18021802

1803+
/*
1804+
* Unset so->scanBehind in case it is still set from back when we dealt
1805+
* with the previous page's high key/finaltup
1806+
*/
1807+
so->scanBehind= false;
1808+
18031809
if (sktrig_required)
18041810
{
18051811
/*
@@ -1808,8 +1814,6 @@ _bt_advance_array_keys(IndexScanDesc scan, BTReadPageState *pstate,
18081814
Assert(!_bt_tuple_before_array_skeys(scan,dir,tuple,tupdesc,
18091815
tupnatts, false,0,NULL));
18101816

1811-
so->scanBehind= false;/* reset */
1812-
18131817
/*
18141818
* Required scan key wasn't satisfied, so required arrays will have to
18151819
* advance. Invalidate page-level state that tracks whether the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp