]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid ERROR in recovery target GUC assign hooks
authorFujii Masao <fujii@postgresql.org>
Mon, 20 Jul 2026 12:41:14 +0000 (21:41 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 20 Jul 2026 12:42:19 +0000 (21:42 +0900)
commitd5751c33cc3e842b20dbe67545fd2c850be8fa59
tree60ce3c574ead90feaf7069647593d9e10396ec77
parent1009339b3acaf06b457a8182bf50b504847a643c
Avoid ERROR in recovery target GUC assign hooks

Recovery target parameters are postmaster-startup GUCs, but their
assign hooks previously did more than assign individual parameter
values. They also updated the global recoveryTarget state and raised
ERROR if more than one recovery target appeared to be set.

This was not a good fit for GUC assign hooks. Assign hooks should not
throw ERROR, and deriving cross-parameter state while individual GUCs
are still being assigned makes the result depend on assignment order
rather than the final configuration.

For example, setting one recovery target and then setting another
recovery_target_* parameter to an empty string could clear
recoveryTarget, causing recovery to proceed with no target even
though a valid target remained configured.

Fix this by having the assign hooks only store their own parameter
values. The effective recoveryTarget is now derived once from the
final recovery_target* settings in
validateRecoveryParameters(), which also rejects configurations that
specify more than one recovery target with FATAL. This preserves the
expected behavior for repeated assignments of the same GUC, treats empty
values as "not set", and removes cross-GUC validation from the assign
hooks.

Author: JoongHyuk Shin <sjh910805@gmail.com>
Reviewed-by: Greg Lamberson <greg@lamco.io>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Scott Ray <scott@scottray.io>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CACSdjfPUa4UvKjADgOERXoxNYmCg2mqqiqKkiJk6mX6E4qgVFw@mail.gmail.com
src/backend/access/transam/xlogrecovery.c
src/backend/utils/misc/guc_parameters.dat
src/backend/utils/misc/guc_tables.c
src/include/access/xlogrecovery.h
src/include/utils/guc_hooks.h
src/test/recovery/t/003_recovery_targets.pl