0001-Refactor-syncrep-parsing-to-represent-bare-standby-l.patch
application/octet-stream
Filename: 0001-Refactor-syncrep-parsing-to-represent-bare-standby-l.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Refactor syncrep parsing to represent bare standby lists explicitly
| File | + | − |
|---|---|---|
| src/backend/replication/syncrep.c | 4 | 0 |
| src/backend/replication/syncrep_gram.y | 1 | 1 |
| src/include/replication/syncrep.h | 1 | 0 |
From 73b9e78a4c0930ff8adf275f5f3d4cd80b39eb9a Mon Sep 17 00:00:00 2001
From: Ashutosh Sharma <ashu.coek88@gmail.com>
Date: Wed, 13 May 2026 06:59:58 +0000
Subject: [PATCH 1/3] Refactor syncrep parsing to represent bare standby lists
explicitly
The syncrep parser currently reduces a simple list form to FIRST 1
(SYNC_REP_PRIORITY). That is acceptable for synchronous_standby_names,
but it loses information about whether FIRST was explicitly written.
Introduce SYNC_REP_DEFAULT to represent the bare list form parsed
from standby_list. This allows callers to distinguish:
- explicit priority syntax (FIRST N (...) or N (...))
- quorum syntax (ANY N (...))
- simple list syntax without FIRST/ANY
With this change:
- syncrep grammar emits SYNC_REP_DEFAULT for bare standby lists
- check_synchronous_standby_names() maps SYNC_REP_DEFAULT to
SYNC_REP_PRIORITY, preserving existing synchronous_standby_names
behavior
This is a preparatory patch for future synchronized_standby_slots
changes, where callers can directly interpret SYNC_REP_DEFAULT as
plain-list semantics, while keeping existing synchronous_standby_names
semantics intact.
Per suggestion from Zhijie Hou <houzj.fnst@fujitsu.com>
---
src/backend/replication/syncrep.c | 4 ++++
src/backend/replication/syncrep_gram.y | 2 +-
src/include/replication/syncrep.h | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index e0e30579c59..ae8ecfa0711 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -1100,6 +1100,10 @@ check_synchronous_standby_names(char **newval, void **extra, GucSource source)
return false;
}
+ /* Default to FIRST 1 (name ...) priority method if not specified */
+ if (syncrep_parse_result->syncrep_method == SYNC_REP_DEFAULT)
+ syncrep_parse_result->syncrep_method = SYNC_REP_PRIORITY;
+
/* GUC extra value must be guc_malloc'd, not palloc'd */
pconf = (SyncRepConfigData *)
guc_malloc(LOG, syncrep_parse_result->config_size);
diff --git a/src/backend/replication/syncrep_gram.y b/src/backend/replication/syncrep_gram.y
index 1b9d7b2edc4..f1550e109ef 100644
--- a/src/backend/replication/syncrep_gram.y
+++ b/src/backend/replication/syncrep_gram.y
@@ -65,7 +65,7 @@ result:
;
standby_config:
- standby_list { $$ = create_syncrep_config("1", $1, SYNC_REP_PRIORITY); }
+ standby_list { $$ = create_syncrep_config("1", $1, SYNC_REP_DEFAULT); }
| NUM '(' standby_list ')' { $$ = create_syncrep_config($1, $3, SYNC_REP_PRIORITY); }
| ANY NUM '(' standby_list ')' { $$ = create_syncrep_config($2, $4, SYNC_REP_QUORUM); }
| FIRST NUM '(' standby_list ')' { $$ = create_syncrep_config($2, $4, SYNC_REP_PRIORITY); }
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h
index b42b5862a70..130c7f6f242 100644
--- a/src/include/replication/syncrep.h
+++ b/src/include/replication/syncrep.h
@@ -34,6 +34,7 @@
/* syncrep_method of SyncRepConfigData */
#define SYNC_REP_PRIORITY 0
#define SYNC_REP_QUORUM 1
+#define SYNC_REP_DEFAULT 2
/*
* SyncRepGetCandidateStandbys returns an array of these structs,
--
2.43.0