diff --git a/repmgr.c b/repmgr.c index 6aed3ae3..8c9bc0e0 100644 --- a/repmgr.c +++ b/repmgr.c @@ -310,7 +310,7 @@ do_master_register(void) return; } - if (!PQgetisnull(res, 0, 0)) /* schema exists */ + if (!PQntuples(res) > 0) /* schema exists */ { if (!force) /* and we are not forcing so error */ { @@ -476,7 +476,7 @@ do_standby_register(void) return; } - if (PQgetisnull(res, 0, 0)) /* schema doesn't exists */ + if (PQntuples(res) == 0) /* schema doesn't exists */ { fprintf(stderr, "Schema repmgr_%s doesn't exists.", myClusterName); PQclear(res); diff --git a/repmgrd.c b/repmgrd.c index f26b4ac4..eaf3bd2e 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -234,10 +234,10 @@ MonitorExecute(void) * Build the SQL to execute on primary */ sprintf(sqlquery, - "INSERT INTO repl_monitor " + "INSERT INTO repmgr_%s.repl_monitor " "VALUES(%d, %d, '%s'::timestamp with time zone, " " '%s', '%s', " - " %lld, %lld)", + " %lld, %lld)", myClusterName, primaryId, myLocalId, monitor_standby_timestamp, last_wal_primary_location, last_wal_standby_received, @@ -259,8 +259,10 @@ checkClusterConfiguration(void) { PGresult *res; - res = PQexec(myLocalConn, "SELECT oid FROM pg_class " - " WHERE relname = 'repl_nodes'"); + sprintf(sqlquery, "SELECT oid FROM pg_class " + " WHERE oid = 'repmgr_%s.repl_nodes'::regclass", + myClusterName); + res = PQexec(myLocalConn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) { fprintf(stderr, "PQexec failed: %s\n", PQerrorMessage(myLocalConn)); @@ -295,9 +297,9 @@ checkNodeConfiguration(char *conninfo) /* * Check if we have my node information in repl_nodes */ - sprintf(sqlquery, "SELECT * FROM repl_nodes " + sprintf(sqlquery, "SELECT * FROM repmgr_%s.repl_nodes " " WHERE id = %d AND cluster = '%s' ", - myLocalId, myClusterName); + myClusterName, myLocalId, myClusterName); res = PQexec(myLocalConn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) @@ -317,9 +319,9 @@ checkNodeConfiguration(char *conninfo) { PQclear(res); /* Adding the node */ - sprintf(sqlquery, "INSERT INTO repl_nodes " + sprintf(sqlquery, "INSERT INTO repmgr_%s.repl_nodes " "VALUES (%d, '%s', '%s')", - myLocalId, myClusterName, conninfo); + myClusterName, myLocalId, myClusterName, conninfo); if (!PQexec(primaryConn, sqlquery)) {