mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 00:26:30 +00:00
Clean up replication slot creation/deletion functions
This commit is contained in:
23
dbutils.c
23
dbutils.c
@@ -4197,11 +4197,11 @@ create_replication_slot_replprot(PGconn *conn, PGconn *repl_conn, char *slot_nam
|
|||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL;
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
if (_verify_replication_slot(conn, slot_name, error_msg) == false)
|
if (_verify_replication_slot(conn, slot_name, error_msg) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
@@ -4219,16 +4219,17 @@ create_replication_slot_replprot(PGconn *conn, PGconn *repl_conn, char *slot_nam
|
|||||||
|
|
||||||
res = PQexec(repl_conn, query.data);
|
res = PQexec(repl_conn, query.data);
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK || !PQntuples(res))
|
if ((PQresultStatus(res) != PGRES_TUPLES_OK || !PQntuples(res)) && error_msg != NULL)
|
||||||
{
|
{
|
||||||
log_db_error(conn, NULL, _("unable to execute CREATE_REPLICATION_SLOT"));
|
appendPQExpBuffer(error_msg,
|
||||||
|
_("unable to create slot \"%s\" on the upstream node: %s\n"),
|
||||||
PQclear(res);
|
slot_name,
|
||||||
return false;
|
PQerrorMessage(conn));
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
return true;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4237,6 +4238,7 @@ create_replication_slot_sql(PGconn *conn, char *slot_name, PQExpBufferData *erro
|
|||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL;
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
if (_verify_replication_slot(conn, slot_name, error_msg) == false)
|
if (_verify_replication_slot(conn, slot_name, error_msg) == false)
|
||||||
return false;
|
return false;
|
||||||
@@ -4263,18 +4265,17 @@ create_replication_slot_sql(PGconn *conn, char *slot_name, PQExpBufferData *erro
|
|||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK && error_msg != NULL)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(error_msg,
|
appendPQExpBuffer(error_msg,
|
||||||
_("unable to create slot \"%s\" on the upstream node: %s\n"),
|
_("unable to create slot \"%s\" on the upstream node: %s\n"),
|
||||||
slot_name,
|
slot_name,
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
success = false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
return true;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user