I failed to add the schema "repmgr_%s" in all places where the repl_*

tables are used.
This commit is contained in:
Jaime Casanova
2010-10-18 09:34:14 -05:00
parent 378bdd7bd4
commit cd287f923a
2 changed files with 12 additions and 10 deletions

View File

@@ -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);

View File

@@ -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))
{