pgsql: pg_controldata: Prevent division-by-zero errors

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_controldata: Prevent division-by-zero errors
Date: 2018-03-21 16:21:47
Message-ID: E1eygUl-0001da-LG@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)amazon(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-03-21 18:57:19 pgsql: Change oddly-chosen OID allocation.
Previous Message Alvaro Herrera 2018-03-21 15:07:57 Re: pgsql: Fix CommandCounterIncrement in partition-related DDL