From d40e299c3c11bac7bc6b15d448d2d4a167fa13ce Mon Sep 17 00:00:00 2001 From: Anastasia Date: Tue, 2 May 2017 17:28:08 +0300 Subject: [PATCH] fix dest backup search --- backup.c | 1 + data.c | 10 ++++------ restore.c | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backup.c b/backup.c index b181d607..f502bfd6 100644 --- a/backup.c +++ b/backup.c @@ -876,6 +876,7 @@ pg_stop_backup(pgBackup *backup) fwrite(PQgetvalue(res, 0, 1), 1, strlen(PQgetvalue(res, 0, 1)), fp); fclose(fp); + /* TODO What for do we save the file into backup_list? */ file = pgFileNew(backup_label, true); calc_file_checksum(file); free(file->path); diff --git a/data.c b/data.c index 4b7bb1a3..a19d0407 100644 --- a/data.c +++ b/data.c @@ -319,7 +319,7 @@ restore_file_partly(const char *from_root,const char *to_root, pgFile *file) int errno_tmp; struct stat st; char to_path[MAXPGPATH]; - char buf[8192]; + char buf[BLCKSZ]; size_t write_size = 0; join_path_components(to_path, to_root, file->path + strlen(from_root) + 1); @@ -562,7 +562,6 @@ is_compressed_data_file(pgFile *file) } /* - * TODO Don't use buffer. * Add check that file is not bigger than RELSEG_SIZE. * WARNING compressed file can be exceed this limit. * Add compression. @@ -575,7 +574,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file) FILE *out; size_t read_len = 0; int errno_tmp; - char buf[8192]; + char buf[BLCKSZ]; struct stat st; pg_crc32 crc; @@ -705,7 +704,7 @@ copy_file_partly(const char *from_root, const char *to_root, size_t read_len = 0; int errno_tmp; struct stat st; - char buf[8192]; + char buf[BLCKSZ]; /* reset size summary */ file->read_size = 0; @@ -823,7 +822,6 @@ copy_file_partly(const char *from_root, const char *to_root, * Calculate checksum of various files which are not copied from PGDATA, * but created in process of backup, such as stream XLOG files, * PG_TABLESPACE_MAP_FILE and PG_BACKUP_LABEL_FILE. - * TODO Why do we read them into a buffer of blocksize? */ bool calc_file_checksum(pgFile *file) @@ -831,7 +829,7 @@ calc_file_checksum(pgFile *file) FILE *in; size_t read_len = 0; int errno_tmp; - char buf[8192]; + char buf[BLCKSZ]; struct stat st; pg_crc32 crc; diff --git a/restore.c b/restore.c index 32031695..1a1f0946 100644 --- a/restore.c +++ b/restore.c @@ -135,8 +135,9 @@ do_restore_or_validate(time_t target_backup_id, * We found target backup. Check its status and * ensure that it satisfies recovery target. */ - if (target_backup_id == current_backup->start_time + if ((target_backup_id == current_backup->start_time || target_backup_id == INVALID_BACKUP_ID) + && !dest_backup) { if (current_backup->status != BACKUP_STATUS_OK) elog(ERROR, "given backup %s is in %s status",