pg_stop_backup_on_standby.patch

application/octet-stream

Filename: pg_stop_backup_on_standby.patch
Type: application/octet-stream
Part: 0
Message: pg_stop_backup(wait_for_archive := true) on standby server

Patch

Format: unified
File+
src/backend/access/transam/xlogfuncs.c 5 0
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index f9b49ba..81f4e32 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -208,6 +208,11 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
 				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 				 errmsg("materialize mode required, but it is not " \
 						"allowed in this context")));
+	if (waitforarchive && RecoveryInProgress())
+		ereport(ERROR,
+				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+				 errmsg("cannot wait for WAL archiving during recovery"),
+				 errhint("Use pg_stop_backup() with wait_for_archive = false")));
 
 	/* Build a tuple descriptor for our result type */
 	if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)