postgresql/src/backend/access
Fujii Masao 3df51ca8b3 Fix CLUSTER progress reporting of number of blocks scanned.
Previously pg_stat_progress_cluster view reported the current block
number in heap scan as the number of heap blocks scanned (i.e.,
heap_blks_scanned). This reported number could be incorrect when
synchronize_seqscans is enabled, because it allowed the heap scan to
start at block in middle. This could result in wraparounds in the
heap_blks_scanned column when the heap scan wrapped around.
This commit fixes the bug by calculating the number of blocks from
the block that the heap scan starts at to the current block in scan,
and reporting that number in the heap_blks_scanned column.

Also, in pg_stat_progress_cluster view, previously heap_blks_scanned
could not reach heap_blks_total at the end of heap scan phase
if the last pages scanned were empty. This commit fixes the bug by
manually updating heap_blks_scanned to the same value as
heap_blks_total when the heap scan phase finishes.

Back-patch to v12 where pg_stat_progress_cluster view was introduced.

Reported-by: Matthias van de Meent
Author: Matthias van de Meent
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/CAEze2WjCBWSGkVfYag001Rc4+-nNLDpWM7QbyD6yPvuhKs-gYQ@mail.gmail.com
2020-11-27 20:16:44 +09:00
..
brin Remove unused and deprecated strategy numbers from BRIN code 2020-11-16 17:25:41 +01:00
common Yet more elimination of dead stores and useless initializations. 2020-09-05 13:17:32 -04:00
gin Copy editing: fix a bunch of misspellings and poor wording. 2020-09-21 12:43:42 -04:00
gist Rename the "point is strictly above/below point" comparison operators. 2020-11-23 11:38:37 -05:00
hash Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
heap Fix CLUSTER progress reporting of number of blocks scanned. 2020-11-27 20:16:44 +09:00
index snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
nbtree Deprecate nbtree's BTP_HAS_GARBAGE flag. 2020-11-17 09:45:56 -08:00
rmgrdesc Fixup some appendStringInfo and appendPQExpBuffer calls 2020-10-15 20:35:17 +13:00
spgist Rename the "point is strictly above/below point" comparison operators. 2020-11-23 11:38:37 -05:00
table Improve handling of dropped relations for REINDEX DATABASE/SCHEMA/SYSTEM 2020-09-02 09:08:12 +09:00
tablesample Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
transam Centralize logic for skipping useless ereport/elog calls. 2020-11-23 19:10:46 -05:00
Makefile Introduce access/{table.h, relation.h}, for generic functions from heapam.h. 2019-01-21 10:51:36 -08:00