From 6fe234af4d358df529082b0a897debeefd1d2250 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Mon, 5 Oct 2009 14:59:10 +0100 Subject: [PATCH] Apply 0009-Use-ereport-rather-than-elog-for-user-facing-errors..patch. Prevents non-normal xids from being specified during recovery, which is still allowed for recovery_target_xid. --- src/backend/access/transam/xlog.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index b5a7f66701..68456e1da0 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5656,11 +5656,13 @@ pg_recovery_pause_xid(PG_FUNCTION_ARGS) RequiresWALControlPermissions(); - if (xid < 3) - elog(ERROR, "cannot specify special values for transaction id"); + if (xid < FirstNormalTransactionId) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("cannot specify special values for transaction id"))); SetRecoveryTargetMode(RECOVERY_TARGET_PAUSE_XID, - xid, 0, InvalidXLogRecPtr, 0); + xid, 0, InvalidXLogRecPtr, 0); PG_RETURN_VOID(); } @@ -5727,10 +5729,12 @@ pg_recovery_advance(PG_FUNCTION_ARGS) RequiresWALControlPermissions(); if (adv < 1) - elog(ERROR, "recovery advance must be greater than or equal to 1"); + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("recovery advance must be greater than or equal to 1"))); SetRecoveryTargetMode(RECOVERY_TARGET_ADVANCE, - InvalidTransactionId, 0, InvalidXLogRecPtr, adv); + InvalidTransactionId, 0, InvalidXLogRecPtr, adv); PG_RETURN_VOID(); } @@ -5925,11 +5929,11 @@ SetMaxStandbyDelay(int delay) /* * 2E6 seconds is about 23 days. Allows us to measure delay in - * milliseconds when we perform timing. maxStandbyDelay is + * milliseconds when we perform timing. maxStandbyDelay is * specified here in seconds. */ if (delay > INT_MAX || delay < -1) - ereport(FATAL, + ereport(ERROR, (errmsg("max_standby_delay must be between -1 (wait forever) and 2 000 000 secs"))); SpinLockAcquire(&xlogctl->info_lck); -- 2.39.5