@@ -168,13 +168,14 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
168168 * Save it as dest_backup
169169 */
170170 dest_backup = current_backup ;
171- dest_backup_index = i - 1 ;
172171 }
173172 }
174173
175174 if (dest_backup == NULL )
176175 elog (ERROR , "Backup satisfying target options is not found." );
177176
177+ dest_backup_index = get_backup_index_number (backups , dest_backup );
178+
178179 /* If we already found dest_backup, look for full backup. */
179180 if (dest_backup -> backup_mode == BACKUP_MODE_FULL )
180181 base_full_backup = dest_backup ;
@@ -264,12 +265,13 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
264265 * and avoid relying on sort order anymore.
265266 */
266267 base_full_backup = tmp_backup ;
267- base_full_backup_index = get_backup_index_number (backups , base_full_backup );
268268 }
269269
270270 if (base_full_backup == NULL )
271271 elog (ERROR , "Full backup satisfying target options is not found." );
272272
273+ base_full_backup_index = get_backup_index_number (backups , base_full_backup );
274+
273275 /*
274276 * Ensure that directories provided in tablespace mapping are valid
275277 * i.e. empty or not exist.
@@ -284,7 +286,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
284286
285287 /*
286288 * Validate backups from base_full_backup to dest_backup.
287- * At this moment we are sure that parent chain is intact.
289+ * At this point we are sure that parent chain is intact.
288290 */
289291 for (i = base_full_backup_index ; i >= dest_backup_index ; i -- )
290292 {
0 commit comments