summaryrefslogtreecommitdiff
path: root/src/backend/access/heap/heapam.c
diff options
context:
space:
mode:
authorMelanie Plageman <melanieplageman@gmail.com>2024-05-16 10:37:07 -0400
committerMelanie Plageman <melanieplageman@gmail.com>2024-05-16 11:00:43 -0400
commita3e6c6f929912f928fa405909d17bcbf0c1b03ee (patch)
tree305e58032e2c03b69a17a1f67b17f6e31b51d5e3 /src/backend/access/heap/heapam.c
parentfb5718f35ff667104ab0b9dace3a238113666237 (diff)
BitmapHeapScan: Remove incorrect assert and reset field
04e72ed617be pushed the skip fetch optimization (allowing bitmap heap scans to operate like index-only scans if none of the underlying data is needed) into heap AM implementations of bitmap table scan callbacks. 04e72ed617be added an assert that all tuples in blocks eligible for the optimization had been NULL-filled and emitted by the end of the scan. This assert is incorrect when not all tuples need be scanned to execute the query; for example: a join in which not all inner tuples need to be scanned before skipping to the next outer tuple. Remove the assert and reset the field on which it previously asserted to avoid incorrectly emitting NULL-filled tuples from a previous scan on rescan. Author: Melanie Plageman Reviewed-by: Tomas Vondra, Michael Paquier, Alvaro Herrera Reported-by: Melanie Plageman Reproduced-by: Tomas Vondra, Richard Guo Discussion: https://postgr.es/m/CAMbWs48orzZVXa7-vP9Nt7vQWLTE04Qy4PePaLQYsVNQgo6qRg%40mail.gmail.com
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r--src/backend/access/heap/heapam.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 4be0dee4de0..82bb9cb33b6 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -1184,7 +1184,12 @@ heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params,
scan->rs_vmbuffer = InvalidBuffer;
}
- Assert(scan->rs_empty_tuples_pending == 0);
+ /*
+ * Reset rs_empty_tuples_pending, a field only used by bitmap heap scan,
+ * to avoid incorrectly emitting NULL-filled tuples from a previous scan
+ * on rescan.
+ */
+ scan->rs_empty_tuples_pending = 0;
/*
* The read stream is reset on rescan. This must be done before
@@ -1216,8 +1221,6 @@ heap_endscan(TableScanDesc sscan)
if (BufferIsValid(scan->rs_vmbuffer))
ReleaseBuffer(scan->rs_vmbuffer);
- Assert(scan->rs_empty_tuples_pending == 0);
-
/*
* Must free the read stream before freeing the BufferAccessStrategy.
*/