Skip to content

Commit 96cfb3e

Browse files
author
Michael Paquier
committed
Simplify code for recovery target identification
Some unnecessary comments are removed and cleaned as well at the same time.
1 parent f77d141 commit 96cfb3e

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

backup.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,8 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
175175
prev_backup = catalog_get_last_data_backup(backup_list);
176176
if (prev_backup == NULL || prev_backup->tli != current.tli)
177177
{
178-
elog(ERROR_SYSTEM, _("There is indeed a full backup but it is not validated."
179-
"So I can't take any incremental backup."
180-
"Please validate it and retry."));
181-
/// elog(INFO, _("no previous full backup, performing a full backup instead"));
182-
/// current.backup_mode = BACKUP_MODE_FULL;
178+
elog(ERROR_SYSTEM, _("Full backup detected but it is not "
179+
"validated so incremental backup cannot be taken"));
183180
}
184181
else
185182
{

restore.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ do_restore(const char *target_time,
205205
continue;
206206

207207
/* is the backup is necessary for restore to target timeline ? */
208-
//if (!satisfy_timeline(timelines, backup) && !satisfy_recovery_target(backup, rt))
209-
if (!satisfy_timeline(timelines, backup) || !satisfy_recovery_target(backup, rt))
208+
if (!satisfy_timeline(timelines, backup) ||
209+
!satisfy_recovery_target(backup, rt))
210210
continue;
211211

212212
if (verbose)
@@ -850,23 +850,13 @@ readTimeLineHistory(TimeLineID targetTLI)
850850
static bool
851851
satisfy_recovery_target(const pgBackup *backup, const pgRecoveryTarget *rt)
852852
{
853-
if(rt->xid_specified){
854-
// elog(INFO, "in satisfy_recovery_target:xid::%u:%u", backup->recovery_xid, rt->recovery_target_xid);
855-
if(backup->recovery_xid <= rt->recovery_target_xid)
856-
return true;
857-
else
858-
return false;
859-
}
860-
if(rt->time_specified){
861-
// elog(INFO, "in satisfy_recovery_target:time_t::%ld:%ld", backup->recovery_time, rt->recovery_target_time);
862-
if(backup->recovery_time <= rt->recovery_target_time)
863-
return true;
864-
else
865-
return false;
866-
}
867-
else{
853+
if(rt->xid_specified)
854+
return backup->recovery_xid <= rt->recovery_target_xid);
855+
856+
if (rt->time_specified)
857+
return backup->recovery_time <= rt->recovery_target_time);
858+
else
868859
return true;
869-
}
870860
}
871861

872862
static bool
@@ -1049,7 +1039,7 @@ checkIfCreateRecoveryConf(const char *target_time,
10491039
bool dummy_bool;
10501040
pgRecoveryTarget *rt;
10511041

1052-
// init pgRecoveryTarget
1042+
/* Initialize pgRecoveryTarget */
10531043
rt = pgut_new(pgRecoveryTarget);
10541044
rt->time_specified = false;
10551045
rt->xid_specified = false;

0 commit comments

Comments
 (0)