repmgrd: fix pidfile handling at shutdown

This commit is contained in:
Ian Barwick
2019-08-19 17:55:18 +09:00
parent 2ec761a979
commit 28f4536372
2 changed files with 15 additions and 3 deletions

View File

@@ -1908,8 +1908,20 @@ repmgrd_set_pid(PGconn *conn, pid_t repmgrd_pid, const char *pidfile)
initPQExpBuffer(&query); initPQExpBuffer(&query);
appendPQExpBuffer(&query, appendPQExpBuffer(&query,
"SELECT repmgr.set_repmgrd_pid(%i, '%s')", "SELECT repmgr.set_repmgrd_pid(%i, ",
(int) repmgrd_pid, pidfile); (int) repmgrd_pid);
if (pidfile != NULL)
{
appendPQExpBuffer(&query,
" '%s')",
pidfile);
}
else
{
appendPQExpBufferStr(&query,
" '')");
}
res = PQexec(conn, query.data); res = PQexec(conn, query.data);
termPQExpBuffer(&query); termPQExpBuffer(&query);

View File

@@ -702,7 +702,7 @@ set_repmgrd_pid(PG_FUNCTION_ARGS)
shared_state->repmgrd_pid = repmgrd_pid; shared_state->repmgrd_pid = repmgrd_pid;
memset(shared_state->repmgrd_pidfile, 0, MAXPGPATH); memset(shared_state->repmgrd_pidfile, 0, MAXPGPATH);
if(repmgrd_pidfile != NULL) if (repmgrd_pidfile != NULL)
{ {
strncpy(shared_state->repmgrd_pidfile, repmgrd_pidfile, MAXPGPATH); strncpy(shared_state->repmgrd_pidfile, repmgrd_pidfile, MAXPGPATH);
} }