From: Daniel Gustafsson Date: Thu, 30 Apr 2026 11:41:41 +0000 (+0200) Subject: Prevent pg_enable/disable_data_checksums() on standby X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b120358c612dce62b493da7682b4df90a10783c9;p=thirdparty%2Fpostgresql.git Prevent pg_enable/disable_data_checksums() on standby These functions missed a RecoveryInProgress() check, allowing them to be called on a hot standby. Enabling, or disabling, checksums on the standby only would cause the cluster to get out of sync and replaying checksum transitions to fail. Author: Satyanarayana Narlapuram Reviewed-by: Ayush Tiwari Reviewed-by: Tomas Vondra Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAHg+QDfRk4-S7DMmdbXJnQ-xF=sUpMAKuh8b83ObLqYVKx5QLA@mail.gmail.com --- diff --git a/src/backend/postmaster/datachecksum_state.c b/src/backend/postmaster/datachecksum_state.c index 5556a9ca893..ea102086144 100644 --- a/src/backend/postmaster/datachecksum_state.c +++ b/src/backend/postmaster/datachecksum_state.c @@ -487,6 +487,8 @@ AbsorbDataChecksumsBarrier(ProcSignalBarrierType barrier) Datum disable_data_checksums(PG_FUNCTION_ARGS) { + PreventCommandDuringRecovery("pg_disable_data_checksums()"); + if (!superuser()) ereport(ERROR, errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), @@ -507,6 +509,8 @@ enable_data_checksums(PG_FUNCTION_ARGS) int cost_delay = PG_GETARG_INT32(0); int cost_limit = PG_GETARG_INT32(1); + PreventCommandDuringRecovery("pg_enable_data_checksums()"); + if (!superuser()) ereport(ERROR, errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),