postgresql/src/backend
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
..
access Fix bitmapheapscan incorrect recheck of NULL tuples 2025-03-24 16:40:59 -04:00
archive Update copyright for 2025 2025-01-01 11:21:55 -05:00
backup pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
bootstrap Remove unnecessary (char *) casts [mem] 2025-02-12 08:50:13 +01:00
catalog Detect and Log multiple_unique_conflicts type conflict. 2025-03-24 12:30:44 +05:30
commands Change one loop in ATRewriteTable to use 1-based attnums 2025-03-21 10:55:06 +01:00
executor Detect and Log multiple_unique_conflicts type conflict. 2025-03-24 12:30:44 +05:30
foreign Update copyright for 2025 2025-01-01 11:21:55 -05:00
jit Add special case fast-paths for strict functions 2025-03-11 12:02:42 +01:00
lib Update copyright for 2025 2025-01-01 11:21:55 -05:00
libpq Modularize log_connections output 2025-03-12 11:35:21 -04:00
main Update copyright for 2025 2025-01-01 11:21:55 -05:00
nodes Introduce squashing of constant lists in query jumbling 2025-03-18 18:56:11 +01:00
optimizer Allow plugins to set a 64-bit plan identifier in PlannedStmt 2025-03-24 13:23:42 +09:00
parser Update a code comment 2025-03-19 10:39:06 +01:00
partitioning Fix bug in cbc127917 to handle nested Append correctly 2025-02-25 09:24:42 +09:00
po Update copyright for 2025 2025-01-01 11:21:55 -05:00
port Update copyright for 2025 2025-01-01 11:21:55 -05:00
postmaster Introduce squashing of constant lists in query jumbling 2025-03-18 18:56:11 +01:00
regex Support PG_UNICODE_FAST locale in the builtin collation provider. 2025-01-17 15:56:30 -08:00
replication Detect and Log multiple_unique_conflicts type conflict. 2025-03-24 12:30:44 +05:30
rewrite Fix incorrect handling of subquery pullup 2025-03-13 16:36:03 +09:00
snowball Update to latest Snowball sources. 2025-02-18 21:13:54 -05:00
statistics Address stats import review comments. 2025-03-05 23:07:25 -08:00
storage Fix rare assertion failure in standby, if primary is restarted 2025-03-23 20:41:16 +02:00
tcop Allow plugins to set a 64-bit plan identifier in PlannedStmt 2025-03-24 13:23:42 +09:00
tsearch Clear errno before calling strtol() in spell.c. 2025-03-08 11:24:25 -05:00
utils Detect and Log multiple_unique_conflicts type conflict. 2025-03-24 12:30:44 +05:30
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Update copyright for 2025 2025-01-01 11:21:55 -05:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
nls.mk Return yyparse() result not via global variable 2025-01-24 06:55:39 +01:00