postgresql/src
Melanie Plageman aea916fe55 Fix bitmapheapscan incorrect recheck of NULL tuples
The bitmap heap scan skip fetch optimization skips fetching the heap
block when a page is set all-visible in the visibility map and no
columns from the table are needed to satisfy the query.

2b73a8cd33 and c3953226a0 changed the control flow of bitmap heap scan
to use the read stream API. The read stream API returns buffers
containing blocks to the user. To make this work with the skip fetch
optimization, we keep a count of the empty tuples we need to emit for
all the blocks skipped and only emit the empty tuples after processing
the next block fetched from the heap or at the end of the scan.

It's incorrect to recheck NULL tuples, so we must set `recheck` to false
before yielding control back to BitmapHeapNext(). This was done before
emitting any remaining empty tuples at the end of the scan but not for
empty tuples emitted during the scan. This meant that if a page fetched
from the heap did require recheck and set `recheck` to true and then we
emitted empty tuples for subsequent blocks, we would get wrong results.

Fix this by always setting `recheck` to false before emitting empty
tuples.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Tested-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/496f7acd-881c-4df3-9bd3-8f8534dfec26%40gmail.com
2025-03-24 16:40:59 -04:00
..
backend Fix bitmapheapscan incorrect recheck of NULL tuples 2025-03-24 16:40:59 -04:00
bin Allow pg_recvlogical --drop-slot to work without --dbname. 2025-03-25 00:18:27 +09:00
common Revert workarounds for -Wmissing-braces false positives on old GCC 2025-03-20 11:25:58 +01:00
fe_utils pg_rewind: Add dbname to primary_conninfo when using --write-recovery-conf. 2025-03-12 16:56:04 -07:00
include Detect and Log multiple_unique_conflicts type conflict. 2025-03-24 12:30:44 +05:30
interfaces Fix "make clean" for new TAP suite. 2025-03-23 06:12:02 -07:00
makefiles Add support for OAUTHBEARER SASL mechanism 2025-02-20 16:25:17 +01:00
pl plpgsql: make WHEN OTHERS distinct from WHEN SQLSTATE '00000'. 2025-03-22 14:17:00 -04:00
port Assert that wrapper_handler()'s argument is within expected range. 2025-03-07 15:23:09 -06:00
template thread-safety: gmtime_r(), localtime_r() 2024-08-23 07:43:04 +02:00
test Fix bitmapheapscan incorrect recheck of NULL tuples 2025-03-24 16:40:59 -04:00
timezone pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
tools Detect and Log multiple_unique_conflicts type conflict. 2025-03-24 12:30:44 +05:30
tutorial Doc: simplify the tutorial's window-function examples. 2025-01-21 14:43:21 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in extension_control_path 2025-03-19 07:03:20 +01:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00