diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-01-11 13:41:13 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-01-11 13:41:13 -0500 |
commit | e6dce4e439e1d271dad9a95bc4b94147be2fc39a (patch) | |
tree | b608e01875fd3c8851464c796f22719a46e562a7 | |
parent | 9d1ac2f5fa4043529dbaff5ebdc73405fa73207b (diff) | |
download | postgresql-e6dce4e439e1d271dad9a95bc4b94147be2fc39a.tar.gz postgresql-e6dce4e439e1d271dad9a95bc4b94147be2fc39a.zip |
Adjust basebackup.c to suppress compiler warnings.
Some versions of gcc complain about "variable `tablespaces' might be
clobbered by `longjmp' or `vfork'" with the original coding. Fix by
moving the PG_TRY block into a separate subroutine.
-rw-r--r-- | src/backend/replication/basebackup.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index de5fa2209bd..2a74c5f8310 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -49,7 +49,7 @@ typedef struct /* - * Called when ERROR or FATAL happens in SendBaseBackup() after + * Called when ERROR or FATAL happens in perform_base_backup() after * we have started the backup - make sure we end it! */ static void @@ -59,6 +59,37 @@ base_backup_cleanup(int code, Datum arg) } /* + * Actually do a base backup for the specified tablespaces. + * + * This is split out mainly to avoid complaints about "variable might be + * clobbered by longjmp" from stupider versions of gcc. + */ +static void +perform_base_backup(const char *backup_label, List *tablespaces) +{ + do_pg_start_backup(backup_label, true); + + PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0); + { + ListCell *lc; + + /* Send tablespace header */ + SendBackupHeader(tablespaces); + + /* Send off our tablespaces one by one */ + foreach(lc, tablespaces) + { + tablespaceinfo *ti = (tablespaceinfo *) lfirst(lc); + + SendBackupDirectory(ti->path, ti->oid); + } + } + PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0); + + do_pg_stop_backup(); +} + +/* * SendBaseBackup() - send a complete base backup. * * The function will take care of running pg_start_backup() and @@ -145,26 +176,7 @@ SendBaseBackup(const char *options) } FreeDir(dir); - do_pg_start_backup(backup_label, true); - - PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0); - { - ListCell *lc; - - /* Send tablespace header */ - SendBackupHeader(tablespaces); - - /* Send off our tablespaces one by one */ - foreach(lc, tablespaces) - { - ti = (tablespaceinfo *) lfirst(lc); - - SendBackupDirectory(ti->path, ti->oid); - } - } - PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0); - - do_pg_stop_backup(); + perform_base_backup(backup_label, tablespaces); MemoryContextSwitchTo(old_context); MemoryContextDelete(backup_context); |