pgsql: Record initial state of data checksums in controlfile

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Record initial state of data checksums in controlfile
Date: 2026-08-18 20:41:16
Message-ID: E1wwQcV-000000016sr-02yk@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Record initial state of data checksums in controlfile

The controlfile records the current state of data checksums, which
also used to be the initial state from initdb when checksums could
not be altered after initialization. pg_control_init is documented
to return information about cluster initialization state, which it
no longer will if data checksums have been changed either using the
offline tool or with online processing.

Fix by adding a new field in the control file which tracks the init
value of data checksums, and is left read only after initialization.

While this is a regression dating back to when changing checksum
state was made possible offline with pg_checksums, it is a control
file change so it cannot be backpatched.

Backpatch to v19 where online checksums were introduced.

Author: Daniel Gustafsson <daniel(at)yesql(dot)se>
Reviewed-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Discussion: https://postgr.es/m/B87ABFBE-A304-4839-8706-C80D73E6BF5C@yesql.se
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/aaf8b9989f7aaeb6594122caee1eea6c87e10655

Modified Files
--------------
src/backend/access/transam/xlog.c | 1 +
src/backend/utils/misc/pg_controldata.c | 2 +-
src/include/catalog/pg_control.h | 10 ++++++++--
src/test/modules/test_checksums/t/001_basic.pl | 23 ++++++++++++++++-------
src/test/modules/test_checksums/t/002_restarts.pl | 12 +++++++++++-
src/test/modules/test_checksums/t/004_offline.pl | 14 ++++++++++++--
6 files changed, 49 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-08-18 20:57:40 pgsql: test_decoding: Don't print virtual generated columns.
Previous Message Daniel Gustafsson 2026-08-18 20:40:39 pgsql: Minor test suite cleanup