From e89c43c5cb22e7bae9e04cc9260d01b1a3ab2295 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 13 Jun 2017 00:35:01 +0900 Subject: [PATCH] Remove unused backup functions Not needed since removal of rsync functionality --- dbutils.c | 100 +--------------------------------------- dbutils.h | 4 -- repmgr-action-standby.c | 5 +- 3 files changed, 3 insertions(+), 106 deletions(-) diff --git a/dbutils.c b/dbutils.c index 2451a864..84beac37 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1933,7 +1933,7 @@ drop_replication_slot(PGconn *conn, char *slot_name) initPQExpBuffer(&query); appendPQExpBuffer(&query, - "SELECT pg_drop_replication_slot('%s')", + "SELECT pg_catalog.pg_drop_replication_slot('%s')", slot_name); log_verbose(LOG_DEBUG, "drop_replication_slot():\n %s", query.data); @@ -2003,101 +2003,3 @@ get_slot_record(PGconn *conn, char *slot_name, t_replication_slot *record) } -/* ================ */ -/* backup functions */ -/* ================ */ - -// XXX is first_wal_segment actually used anywhere? -bool -start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint, int server_version_num) -{ - PQExpBufferData query; - PGresult *res; - - initPQExpBuffer(&query); - - if (server_version_num >= 100000) - { - appendPQExpBuffer(&query, - "SELECT pg_catalog.pg_walfile_name(pg_catalog.pg_start_backup('repmgr_standby_clone_%ld', %s))", - time(NULL), - fast_checkpoint ? "TRUE" : "FALSE"); - } - else - { - appendPQExpBuffer(&query, - "SELECT pg_catalog.pg_xlogfile_name(pg_catalog.pg_start_backup('repmgr_standby_clone_%ld', %s))", - time(NULL), - fast_checkpoint ? "TRUE" : "FALSE"); - } - - log_verbose(LOG_DEBUG, "start_backup():\n %s", query.data); - - res = PQexec(conn, query.data); - - termPQExpBuffer(&query); - - if (PQresultStatus(res) != PGRES_TUPLES_OK) - { - log_error(_("unable to start backup:\n %s"), PQerrorMessage(conn)); - PQclear(res); - return false; - } - - if (first_wal_segment != NULL) - { - char *first_wal_seg_pq = PQgetvalue(res, 0, 0); - size_t buf_sz = strlen(first_wal_seg_pq); - - first_wal_segment = pg_malloc0(buf_sz + 1); - snprintf(first_wal_segment, buf_sz + 1, "%s", first_wal_seg_pq); - } - - PQclear(res); - - return true; -} - - -bool -stop_backup(PGconn *conn, char *last_wal_segment, int server_version_num) -{ - PQExpBufferData query; - PGresult *res; - - initPQExpBuffer(&query); - - if (server_version_num >= 100000) - { - appendPQExpBuffer(&query, - "SELECT pg_catalog.pg_walfile_name(pg_catalog.pg_stop_backup())"); - } - else - { - appendPQExpBuffer(&query, - "SELECT pg_catalog.pg_xlogfile_name(pg_catalog.pg_stop_backup())"); - } - - res = PQexec(conn, query.data); - termPQExpBuffer(&query); - - if (PQresultStatus(res) != PGRES_TUPLES_OK) - { - log_error(_("unable to stop backup:\n %s"), PQerrorMessage(conn)); - PQclear(res); - return false; - } - - if (last_wal_segment != NULL) - { - char *last_wal_seg_pq = PQgetvalue(res, 0, 0); - size_t buf_sz = strlen(last_wal_seg_pq); - - last_wal_segment = pg_malloc0(buf_sz + 1); - snprintf(last_wal_segment, buf_sz + 1, "%s", last_wal_seg_pq); - } - - PQclear(res); - - return true; -} diff --git a/dbutils.h b/dbutils.h index c9d2b772..12700d79 100644 --- a/dbutils.h +++ b/dbutils.h @@ -216,9 +216,5 @@ bool create_replication_slot(PGconn *conn, char *slot_name, int server_version_ bool drop_replication_slot(PGconn *conn, char *slot_name); int get_slot_record(PGconn *conn, char *slot_name, t_replication_slot *record); -/* backup functions */ -bool start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint, int server_version_num); -bool stop_backup(PGconn *conn, char *last_wal_segment, int server_version_num); - #endif diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 448e17f6..8489a3ef 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -1726,9 +1726,8 @@ initialise_direct_clone(void) PQclear(res); /* - * If replication slots requested, create appropriate slot on - * the primary; this must be done before pg_start_backup() is - * issued, either by us or by pg_basebackup. + * If replication slots requested, create appropriate slot on the + * primary; this must be done before pg_basebackup is called. * * Replication slots are not supported (and not very useful * anyway) in Barman mode.