Fix compilation: use 9.4 version of SyncRepGetStandbyPriority
@@ -856,8 +856,10 @@ SyncRepGetSyncStandbys(bool *am_sync)
static int
SyncRepGetStandbyPriority(void)
{
- const char *standby_name;
- int priority;
+ char *rawstring;
+ List *elemlist;
+ ListCell *l;
+ int priority = 0;
bool found = false;
/*
@@ -867,29 +869,37 @@ SyncRepGetStandbyPriority(void)
if (am_cascading_walsender)
return 0;
- if (!SyncStandbysDefined() || SyncRepConfig == NULL)
+ /* Need a modifiable copy of string */
+ rawstring = pstrdup(SyncRepStandbyNames);
+
+ /* Parse string into list of identifiers */
+ if (!SplitIdentifierString(rawstring, ',', &elemlist))
+ {
+ /* syntax error in list */
+ pfree(rawstring);
+ list_free(elemlist);
+ /* GUC machinery will have already complained - no need to do again */
return 0;
+ }
- standby_name = SyncRepConfig->member_names;
- for (priority = 1; priority <= SyncRepConfig->nmembers; priority++)
+ foreach(l, elemlist)
{
+ char *standby_name = (char *) lfirst(l);
+
+ priority++;
+
if (pg_strcasecmp(standby_name, application_name) == 0 ||
- strcmp(standby_name, "*") == 0)
+ pg_strcasecmp(standby_name, "*") == 0)
{
found = true;
break;
}
- standby_name += strlen(standby_name) + 1;
}
- if (!found)
- return 0;
+ pfree(rawstring);
+ list_free(elemlist);
- /*
- * In quorum-based sync replication, all the standbys in the list have the
- * same priority, one.
- */
- return (SyncRepConfig->syncrep_method == SYNC_REP_PRIORITY) ? priority : 1;
+ return (found ? priority : 0);
}
/*
