@@ -49,7 +49,7 @@ typedef struct
49
49
50
50
51
51
/*
52
- * Called when ERROR or FATAL happens in SendBaseBackup () after
52
+ * Called when ERROR or FATAL happens in perform_base_backup () after
53
53
* we have started the backup - make sure we end it!
54
54
*/
55
55
static void
@@ -58,6 +58,37 @@ base_backup_cleanup(int code, Datum arg)
58
58
do_pg_abort_backup ();
59
59
}
60
60
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
+
61
92
/*
62
93
* SendBaseBackup() - send a complete base backup.
63
94
*
@@ -145,26 +176,7 @@ SendBaseBackup(const char *options)
145
176
}
146
177
FreeDir (dir );
147
178
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 );
168
180
169
181
MemoryContextSwitchTo (old_context );
170
182
MemoryContextDelete (backup_context );
0 commit comments