pgsql: pg_controldata: Prevent division-by-zero errors - Mailing list pgsql-committers

From Peter Eisentraut
Subject pgsql: pg_controldata: Prevent division-by-zero errors
Date
Msg-id E1eygUl-0001da-LG@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
pg_controldata: Prevent division-by-zero errors

If the control file is corrupted and specifies the WAL segment size
to be 0 bytes, calculating the latest checkpoint's REDO WAL file
will fail with a division-by-zero error.  Show it as "???" instead.

Also reword the warning message a bit and send it to stdout, like the
other pre-existing warning messages.

Add some tests for dealing with a corrupted pg_control file.

Author: Nathan Bossart <bossartn@amazon.com>, tests by me

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4731d848f23e08a9396b4831d13fbb6dd460faf2

Modified Files
--------------
src/bin/pg_controldata/pg_controldata.c        | 26 ++++++++++++++++++--------
src/bin/pg_controldata/t/001_pg_controldata.pl | 21 ++++++++++++++++++++-
2 files changed, 38 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Fix relcache handling of the 'default' partition
Next
From: Tom Lane
Date:
Subject: pgsql: Change oddly-chosen OID allocation.