postgresql/src/include/access
Peter Geoghegan cac37c1a1b Fix btmarkpos/btrestrpos array key wraparound bug.
nbtree's mark/restore processing failed to correctly handle an edge case
involving array key advancement and related search-type scan key state.
Scans with ScalarArrayScalarArrayOpExpr quals requiring mark/restore
processing (for a merge join) could incorrectly conclude that an
affected array/scan key must not have advanced during the time between
marking and restoring the scan's position.

As a result of all this, array key handling within btrestrpos could skip
a required call to _bt_preprocess_keys().  This confusion allowed later
primitive index scans to overlook tuples matching the true current array
keys.  The scan's search-type scan keys would still have spurious values
corresponding to the final array element(s) -- not values matching the
first/now-current array element(s).

To fix, remember that "array key wraparound" has taken place during the
ongoing btrescan in a flag variable stored in the scan's state, and use
that information at the point where btrestrpos decides if another call
to _bt_preprocess_keys is required.

Oversight in commit 70bc5833, which taught nbtree to handle array keys
during mark/restore processing, but missed this subtlety.  That commit
was itself a bug fix for an issue in commit 9e8da0f7, which taught
nbtree to handle ScalarArrayOpExpr quals natively.

Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WzkgP3DDRJxw6DgjCxo-cu-DKrvjEv_ArkP2ctBJatDCYg@mail.gmail.com
Backpatch: 11- (all supported branches).
2023-09-28 16:29:32 -07:00
..
amapi.h Revert changes in HOT handling of BRIN indexes 2022-06-16 15:02:49 +02:00
amvalidate.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
attmap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
attnum.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
brin.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
brin_internal.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
brin_page.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
brin_pageops.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
brin_revmap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
brin_tuple.h Fix handling of empty ranges and NULLs in BRIN 2023-05-19 00:15:13 +02:00
brin_xlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
bufmask.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
clog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
commit_ts.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
detoast.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
genam.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
generic_xlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
gin.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
gin_private.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ginblock.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ginxlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
gist.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
gist_private.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
gistscan.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
gistxlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
hash.h Add macros in hash and btree AMs to get the special area of their pages 2022-04-01 13:24:50 +09:00
hash_xlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
heapam.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
heapam_xlog.h Set relfrozenxid to oldest extant XID seen by VACUUM. 2022-04-03 09:57:21 -07:00
heaptoast.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
hio.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
htup.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
htup_details.h Change one AssertMacro to Assert 2022-04-06 09:10:24 +02:00
itup.h Overload index_form_tuple to allow the memory context to be supplied 2022-07-07 08:14:32 +12:00
multixact.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
nbtree.h Fix btmarkpos/btrestrpos array key wraparound bug. 2023-09-28 16:29:32 -07:00
nbtxlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
parallel.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
printsimple.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
printtup.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
relation.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
reloptions.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
relscan.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
rewriteheap.h Add missing 'extern' to function prototypes. 2022-05-12 12:39:33 -07:00
rmgr.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
rmgrlist.h Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
sdir.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
session.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
skey.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
slru.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
spgist.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
spgist_private.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
spgxlog.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
stratnum.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
subtrans.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
syncscan.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sysattr.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
table.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
tableam.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
timeline.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
toast_compression.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
toast_helper.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
toast_internals.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
transam.h Fix visibility check when XID is committed in CLOG but not in procarray. 2022-06-27 08:21:08 +03:00
tsmapi.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
tupconvert.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
tupdesc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
tupdesc_details.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
tupmacs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
twophase.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
twophase_rmgr.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
valid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
visibilitymap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
visibilitymapdefs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
xact.h Rethink handling of [Prevent|Is]InTransactionBlock in pipeline mode. 2022-12-13 14:23:59 -05:00
xlog.h Remove unused-and-misspelled function extern declaration. 2022-05-21 13:26:08 -04:00
xlog_internal.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
xlogarchive.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
xlogdefs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
xloginsert.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
xlogprefetcher.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
xlogreader.h Fix recovery_prefetch with low maintenance_io_concurrency. 2022-09-08 20:36:44 +12:00
xlogrecord.h Add support for zstd with compression of full-page writes in WAL 2022-03-11 12:18:53 +09:00
xlogrecovery.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
xlogstats.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
xlogutils.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00