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 10:45:48 -05:00
parent 9caa243354
commit 5d8cf6abe0
2 changed files with 23 additions and 8 deletions

View File

@@ -41,3 +41,4 @@
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

@@ -940,10 +940,17 @@ 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')");
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);
@@ -1149,10 +1156,17 @@ do_standby_clone(void)
* find and appropiate rsync option but besides we could someday make all
* these rsync happen concurrently
*/
sqlquery_snprintf(sqlquery,
"SELECT spclocation "
" FROM pg_tablespace "
" WHERE spcname NOT IN ('pg_default', 'pg_global')");
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)