pgsql: Add static assertions about pg_control fitting into one disk sec

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add static assertions about pg_control fitting into one disk sec
Date: 2017-07-19 20:17:08
Message-ID: E1dXvPA-0003Rf-JD@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add static assertions about pg_control fitting into one disk sector.

When pg_control was first designed, sizeof(ControlFileData) was small
enough that a comment seemed like plenty to document the assumption that
it'd fit into one disk sector. Now it's nearly 300 bytes, raising the
possibility that somebody would carelessly add enough stuff to create
a problem. Let's add a StaticAssertStmt() to ensure that the situation
doesn't pass unnoticed if it ever occurs.

While at it, rename PG_CONTROL_SIZE to PG_CONTROL_FILE_SIZE to make it
clearer what that symbol means, and convert the existing runtime
comparisons of sizeof(ControlFileData) vs. PG_CONTROL_FILE_SIZE to be
static asserts --- we didn't have that technology when this code was
first written.

Discussion: https://postgr.es/m/9192.1500490591@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3cb29c42f990522131535eea75c691fb23191685

Modified Files
--------------
src/backend/access/transam/xlog.c | 22 ++++++++++++++--------
src/bin/pg_resetwal/pg_resetwal.c | 31 ++++++++++++++++---------------
src/bin/pg_rewind/pg_rewind.c | 23 ++++++++++++++++-------
src/include/catalog/pg_control.h | 19 ++++++++++++-------
4 files changed, 58 insertions(+), 37 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-07-20 15:29:53 pgsql: Fix dumping of outer joins with empty qual lists.
Previous Message Tom Lane 2017-07-19 16:59:35 pgsql: Doc: add missing note about permissions needed to change log_loc