postgresql/contrib
Michael Paquier 2275d044d0 pageinspect: Fix handling of all-zero pages
Getting from get_raw_page() an all-zero page is considered as a valid
case by the buffer manager and it can happen for example when finding a
corrupted page with zero_damaged_pages enabled (using zero_damaged_pages
to look at corrupted pages happens), or after a crash when a relation
file is extended before any WAL for its new data is generated (before a
vacuum or autovacuum job comes in to do some cleanup).

However, all the functions of pageinspect, as of the index AMs (except
hash that has its own idea of new pages), heap, the FSM or the page
header have never worked with all-zero pages, causing various crashes
when going through the page internals.

This commit changes all the pageinspect functions to be compliant with
all-zero pages, where the choice is made to return NULL or no rows for
SRFs when finding a new page.  get_raw_page() still works the same way,
returning a batch of zeros in the bytea of the page retrieved.  A hard
error could be used but NULL, while more invasive, is useful when
scanning relation files in full to get a batch of results for a single
relation in one query.  Tests are added for all the code paths
impacted.

Reported-by: Daria Lepikhova
Author: Michael Paquier
Discussion: https://postgr.es/m/561e187b-3549-c8d5-03f5-525c14e65bd0@postgrespro.ru
Backpatch-through: 10
2022-04-14 15:09:36 +09:00
..
adminpack
amcheck Introduce PG_TEST_TIMEOUT_DEFAULT for TAP suite non-elapsing timeouts. 2022-03-04 18:53:17 -08:00
auth_delay
auto_explain Fix ancient memory leak in contrib/auto_explain. 2021-02-02 13:49:08 -05:00
bloom Fix instability in contrib/bloom TAP tests. 2021-09-28 17:34:31 -04:00
bool_plperl Fix broken ruleutils support for function TRANSFORM clauses. 2021-01-25 13:03:11 -05:00
btree_gin Fix failure of btree_gin indexscans with "char" type and </<= operators. 2021-08-10 18:10:30 -04:00
btree_gist Fix results of index-only scans on btree_gist char(N) indexes. 2022-01-08 14:54:39 -05:00
citext
cube
dblink postgres_fdw: Fix unexpected reporting of empty message. 2021-12-03 17:37:14 +09:00
dict_int
dict_xsyn
earthdistance
file_fdw
fuzzystrmatch
hstore
hstore_plperl
hstore_plpython Fix broken ruleutils support for function TRANSFORM clauses. 2021-01-25 13:03:11 -05:00
intagg
intarray
isn
jsonb_plperl
jsonb_plpython
lo
ltree Fix default signature length for gist_ltree_ops 2022-03-16 11:41:34 +03:00
ltree_plpython
oid2name Report the true database name on connection errors 2021-01-26 16:42:13 -03:00
pageinspect pageinspect: Fix handling of all-zero pages 2022-04-14 15:09:36 +09:00
passwordcheck
pg_buffercache
pg_freespacemap
pg_prewarm
pg_standby
pg_stat_statements Don't try to read a multi-GB pg_stat_statements file in one call. 2021-10-31 19:13:48 -04:00
pg_trgm Avoid some other O(N^2) hazards in list manipulation. 2021-11-01 16:24:40 -04:00
pg_visibility
pgcrypto Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
pgrowlocks
pgstattuple
postgres_fdw Fix postgres_fdw to check shippability of sort clauses properly. 2022-03-31 14:29:24 -04:00
seg Stabilize contrib/seg regression test. 2021-06-07 14:52:56 -04:00
sepgsql
spi
sslinfo
start-scripts
tablefunc
tcn
test_decoding WAL log unchanged toasted replica identity key attributes. 2022-02-14 08:24:44 +05:30
tsm_system_rows
tsm_system_time Mark some contrib modules as "trusted". 2020-02-13 15:02:35 -05:00
unaccent
uuid-ossp
vacuumlo Report the true database name on connection errors 2021-01-26 16:42:13 -03:00
xml2
contrib-global.mk
Makefile
README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.