Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit a714299

Browse files
author
Asim R P
committed
Fix compilation: use 9.4 version of SyncRepGetStandbyPriority
1 parent c0ceca3 commit a714299

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/backend/replication/syncrep.c

+24-14
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,10 @@ SyncRepGetSyncStandbys(bool *am_sync)
856856
static int
857857
SyncRepGetStandbyPriority(void)
858858
{
859-
const char *standby_name;
860-
int priority;
859+
char *rawstring;
860+
List *elemlist;
861+
ListCell *l;
862+
int priority = 0;
861863
bool found = false;
862864

863865
/*
@@ -867,29 +869,37 @@ SyncRepGetStandbyPriority(void)
867869
if (am_cascading_walsender)
868870
return 0;
869871

870-
if (!SyncStandbysDefined() || SyncRepConfig == NULL)
872+
/* Need a modifiable copy of string */
873+
rawstring = pstrdup(SyncRepStandbyNames);
874+
875+
/* Parse string into list of identifiers */
876+
if (!SplitIdentifierString(rawstring, ',', &elemlist))
877+
{
878+
/* syntax error in list */
879+
pfree(rawstring);
880+
list_free(elemlist);
881+
/* GUC machinery will have already complained - no need to do again */
871882
return 0;
883+
}
872884

873-
standby_name = SyncRepConfig->member_names;
874-
for (priority = 1; priority <= SyncRepConfig->nmembers; priority++)
885+
foreach(l, elemlist)
875886
{
887+
char *standby_name = (char *) lfirst(l);
888+
889+
priority++;
890+
876891
if (pg_strcasecmp(standby_name, application_name) == 0 ||
877-
strcmp(standby_name, "*") == 0)
892+
pg_strcasecmp(standby_name, "*") == 0)
878893
{
879894
found = true;
880895
break;
881896
}
882-
standby_name += strlen(standby_name) + 1;
883897
}
884898

885-
if (!found)
886-
return 0;
899+
pfree(rawstring);
900+
list_free(elemlist);
887901

888-
/*
889-
* In quorum-based sync replication, all the standbys in the list have the
890-
* same priority, one.
891-
*/
892-
return (SyncRepConfig->syncrep_method == SYNC_REP_PRIORITY) ? priority : 1;
902+
return (found ? priority : 0);
893903
}
894904

895905
/*

0 commit comments

Comments
 (0)