mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 15:46:29 +00:00
Initial support for physical replication slots
Todo: - if slots specified in repmgr.conf, verify server version - store generated slot name in `repl_nodes` table
This commit is contained in:
28
dbutils.c
28
dbutils.c
@@ -558,6 +558,7 @@ get_master_connection(PGconn *standby_conn, char *cluster,
|
||||
{
|
||||
PQclear(res2);
|
||||
PQclear(res1);
|
||||
log_debug(_("get_master_connection(): current primary node is %i\n"), node_id);
|
||||
|
||||
if(master_id != NULL)
|
||||
{
|
||||
@@ -709,3 +710,30 @@ get_repmgr_schema_quoted(PGconn *conn)
|
||||
|
||||
return repmgr_schema_quoted;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
create_replication_slot(PGconn *conn, char *slot_name)
|
||||
{
|
||||
char sqlquery[QUERY_STR_LEN];
|
||||
PGresult *res;
|
||||
|
||||
sqlquery_snprintf(sqlquery,
|
||||
"SELECT * FROM pg_create_physical_replication_slot('%s')",
|
||||
slot_name);
|
||||
|
||||
log_debug(_("create_replication_slot(): Creating slot '%s' on primary\n"), slot_name);
|
||||
|
||||
res = PQexec(conn, sqlquery);
|
||||
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_err(_("Unable to create slot '%s' on the primary node: %s\n"),
|
||||
slot_name,
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
return false;
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user