Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e6dce4e

Browse files
committed
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.
1 parent 9d1ac2f commit e6dce4e

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

src/backend/replication/basebackup.c

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct
4949

5050

5151
/*
52-
* Called when ERROR or FATAL happens in SendBaseBackup() after
52+
* Called when ERROR or FATAL happens in perform_base_backup() after
5353
* we have started the backup - make sure we end it!
5454
*/
5555
static void
@@ -58,6 +58,37 @@ base_backup_cleanup(int code, Datum arg)
5858
do_pg_abort_backup();
5959
}
6060

61+
/*
62+
* Actually do a base backup for the specified tablespaces.
63+
*
64+
* This is split out mainly to avoid complaints about "variable might be
65+
* clobbered by longjmp" from stupider versions of gcc.
66+
*/
67+
static void
68+
perform_base_backup(const char *backup_label, List *tablespaces)
69+
{
70+
do_pg_start_backup(backup_label, true);
71+
72+
PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
73+
{
74+
ListCell *lc;
75+
76+
/* Send tablespace header */
77+
SendBackupHeader(tablespaces);
78+
79+
/* Send off our tablespaces one by one */
80+
foreach(lc, tablespaces)
81+
{
82+
tablespaceinfo *ti = (tablespaceinfo *) lfirst(lc);
83+
84+
SendBackupDirectory(ti->path, ti->oid);
85+
}
86+
}
87+
PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
88+
89+
do_pg_stop_backup();
90+
}
91+
6192
/*
6293
* SendBaseBackup() - send a complete base backup.
6394
*
@@ -145,26 +176,7 @@ SendBaseBackup(const char *options)
145176
}
146177
FreeDir(dir);
147178

148-
do_pg_start_backup(backup_label, true);
149-
150-
PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
151-
{
152-
ListCell *lc;
153-
154-
/* Send tablespace header */
155-
SendBackupHeader(tablespaces);
156-
157-
/* Send off our tablespaces one by one */
158-
foreach(lc, tablespaces)
159-
{
160-
ti = (tablespaceinfo *) lfirst(lc);
161-
162-
SendBackupDirectory(ti->path, ti->oid);
163-
}
164-
}
165-
PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
166-
167-
do_pg_stop_backup();
179+
perform_base_backup(backup_label, tablespaces);
168180

169181
MemoryContextSwitchTo(old_context);
170182
MemoryContextDelete(backup_context);

0 commit comments

Comments
 (0)