repmgr standby switchover: add "%p" event notification parameter

This will contain the node ID of the former primary.
This commit is contained in:
Ian Barwick
2018-01-10 10:58:01 +09:00
parent f7df8b9c80
commit 07a88c78a5
6 changed files with 60 additions and 22 deletions

View File

@@ -2962,7 +2962,6 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
}
/*
* create_event_notification()
*
@@ -3063,7 +3062,7 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
/* we don't treat this as an error */
/* we don't treat this as a fatal error */
log_warning(_("unable to create event record:\n %s"),
PQerrorMessage(conn));
@@ -3216,6 +3215,20 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
dst_ptr += strlen(dst_ptr);
}
break;
case 'p':
/* %p: former primary id ("repmgr standby switchover") */
src_ptr++;
if (event_info->former_primary_id != UNKNOWN_NODE_ID)
{
PQExpBufferData node_id;
initPQExpBuffer(&node_id);
appendPQExpBuffer(&node_id,
"%i", event_info->former_primary_id);
strlcpy(dst_ptr, node_id.data, end_ptr - dst_ptr);
dst_ptr += strlen(dst_ptr);
termPQExpBuffer(&node_id);
}
break;
default:
/* otherwise treat the % as not special */
if (dst_ptr < end_ptr)