Allow repmgr to obtain tablespace's locations from pg 9.2 and later

in which we no longer have a spclocation column in pg_tablespaces
This commit is contained in:
Jaime Casanova
2012-06-12 11:05:51 -05:00
parent 331eca447a
commit 4db046a8ea
2 changed files with 32 additions and 10 deletions

View File

@@ -35,3 +35,10 @@
Add --ignore-rsync-warning (Cédric)
Add strnlen for compatibility with OS X (Greg)
Improve performance of the repl_status view (Jaime)
1.2.0 2012-06-15
Test ssh connection before trying to rsync (Cédric)
Add CLUSTER SHOW command (Carlo Ascani)
Add CLUSTER CLEANUP command (Jaime)
Add function write_primary_conninfo (Marco Nenciarini)
Teach repmgr how to get tablespace's location in different pg version (Jaime Casanova)

View File

@@ -790,11 +790,18 @@ do_standby_clone(void)
* Check if the tablespace locations exists and that we can write to
* them.
*/
sqlquery_snprintf(sqlquery,
"SELECT spclocation "
" FROM pg_tablespace "
"WHERE spcname NOT IN ('pg_default', 'pg_global')");
log_debug(_("standby clone: %s\n"), sqlquery);
if (strcmp(master_version, "9.0") == 0 || strcmp(master_version, "9.1") == 0)
sqlquery_snprintf(sqlquery,
"SELECT spclocation "
" FROM pg_tablespace "
"WHERE spcname NOT IN ('pg_default', 'pg_global')");
else
sqlquery_snprintf(sqlquery,
"SELECT pg_tablespace_location(oid) spclocation "
" FROM pg_tablespace "
"WHERE spcname NOT IN ('pg_default', 'pg_global')");
log_debug("standby clone: %s\n", sqlquery);
res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -1009,11 +1016,19 @@ do_standby_clone(void)
* XXX We may not do that if we are in test_mode but it does not hurt too much
* (except if a tablespace is created during the test)
*/
sqlquery_snprintf(sqlquery,
"SELECT spclocation "
" FROM pg_tablespace "
" WHERE spcname NOT IN ('pg_default', 'pg_global')");
log_debug(_("standby clone: %s\n"), sqlquery);
if (strcmp(master_version, "9.0") == 0 || strcmp(master_version, "9.1") == 0)
sqlquery_snprintf(sqlquery,
"SELECT spclocation "
" FROM pg_tablespace "
" WHERE spcname NOT IN ('pg_default', 'pg_global')");
else
sqlquery_snprintf(sqlquery,
"SELECT pg_tablespace_location(oid) spclocation "
" FROM pg_tablespace "
" WHERE spcname NOT IN ('pg_default', 'pg_global')");
log_debug("standby clone: %s\n", sqlquery);
res = PQexec(conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{