FreeFile.patch
application/octet-stream
Filename: FreeFile.patch
Type: application/octet-stream
Part: 0
Message:
Re: Patch pg_is_in_backup()
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlogfuncs.c | 12 | 1 |
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index d94809a..7f3f09d 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -613,12 +613,23 @@ pg_backup_start_time(PG_FUNCTION_ARGS)
/*
* Close the backup label file.
+ *
+ * AllocateFile() guarantees that file will be closed at the end of
+ * transaction, so the ereport(ERROR) here will not cause leakage.
*/
- if (ferror(lfp) || FreeFile(lfp))
+ if (ferror(lfp))
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read file \"%s\": %m", BACKUP_LABEL_FILE)));
+ /*
+ * Close the backup label file.
+ */
+ if (!FreeFile(lfp))
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not close file \"%s\": %m", BACKUP_LABEL_FILE)));
+
if (strlen(backup_start_time) == 0)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),