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:40:39
Message-ID: E1wwQbu-000000016rL-2FiP@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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/514fb08f51471b47c6d4e059df70be97f61a78cc

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 Daniel Gustafsson 2026-08-18 20:41:16 pgsql: Minor test suite cleanup
Previous Message Jeff Davis 2026-08-18 20:21:18 pgsql: pg_locale.c: comment improvements.