Skip to content

Commit f833ca6

Browse files
committed
Code cleanup: backup, restore. Still WIP. Something can be broken.
1 parent 3ca609a commit f833ca6

File tree

14 files changed

+660
-776
lines changed

14 files changed

+660
-776
lines changed

backup.c

Lines changed: 293 additions & 355 deletions
Large diffs are not rendered by default.

catalog.c

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ unlink_lock_atexit(void)
4141
* Create a lockfile.
4242
*/
4343
void
44-
catalog_lock(bool check_catalog)
44+
catalog_lock(void)
4545
{
4646
int fd;
4747
char buffer[MAXPGPATH * 2 + 256];
@@ -205,23 +205,10 @@ catalog_lock(bool check_catalog)
205205
atexit(unlink_lock_atexit);
206206
exit_hook_registered = true;
207207
}
208-
209-
if (check_catalog)
210-
{
211-
uint64 id;
212-
213-
Assert(pgdata);
214-
215-
/* Check system-identifier */
216-
id = get_system_identifier(false);
217-
if (id != system_identifier)
218-
elog(ERROR, "backup directory was initialized for system id %ld, but target system id is %ld",
219-
system_identifier, id);
220-
}
221208
}
222209

223210
/*
224-
* Create a pgBackup which taken at timestamp.
211+
* Read backup meta information from BACKUP_CONF_FILE.
225212
* If no backup matches, return NULL.
226213
*/
227214
pgBackup *
@@ -337,7 +324,7 @@ catalog_get_backup_list(time_t requested_backup_id)
337324
}
338325

339326
/*
340-
* Find the last completed database backup from the backup list.
327+
* Find the last completed backup on given timeline
341328
*/
342329
pgBackup *
343330
catalog_get_last_data_backup(parray *backup_list, TimeLineID tli)
@@ -350,15 +337,7 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli)
350337
{
351338
backup = (pgBackup *) parray_get(backup_list, i);
352339

353-
/*
354-
* We need completed database backup in the case of a full or
355-
* differential backup on current timeline.
356-
*/
357-
if (backup->status == BACKUP_STATUS_OK &&
358-
backup->tli == tli &&
359-
(backup->backup_mode == BACKUP_MODE_DIFF_PAGE ||
360-
backup->backup_mode == BACKUP_MODE_DIFF_PTRACK ||
361-
backup->backup_mode == BACKUP_MODE_FULL))
340+
if (backup->status == BACKUP_STATUS_OK && backup->tli == tli)
362341
return backup;
363342
}
364343

@@ -510,7 +489,7 @@ read_backup_from_file(const char *path)
510489
if (access(path, F_OK) != 0)
511490
return NULL;
512491

513-
init_backup(backup);
492+
pgBackup_init(backup);
514493
pgut_readopt(path, options, ERROR);
515494

516495
if (backup_mode)
@@ -642,22 +621,4 @@ pgBackupGetPath(const pgBackup *backup, char *path, size_t len, const char *subd
642621
free(datetime);
643622

644623
make_native_path(path);
645-
}
646-
647-
void
648-
init_backup(pgBackup *backup)
649-
{
650-
backup->backup_id = INVALID_BACKUP_ID;
651-
backup->backup_mode = BACKUP_MODE_INVALID;
652-
backup->status = BACKUP_STATUS_INVALID;
653-
backup->tli = 0;
654-
backup->start_lsn = 0;
655-
backup->stop_lsn = 0;
656-
backup->start_time = (time_t) 0;
657-
backup->end_time = (time_t) 0;
658-
backup->recovery_xid = 0;
659-
backup->recovery_time = (time_t) 0;
660-
backup->data_bytes = BYTES_INVALID;
661-
backup->stream = false;
662-
backup->parent_backup = 0;
663-
}
624+
}

0 commit comments

Comments
 (0)