@@ -29,11 +29,15 @@ static pgRecoveryTarget *checkIfCreateRecoveryConf(const char *target_time,
29
29
const char * target_inclusive );
30
30
static parray * readTimeLineHistory (TimeLineID targetTLI );
31
31
static bool satisfy_timeline (const parray * timelines , const pgBackup * backup );
32
- static bool satisfy_recovery_target (const pgBackup * backup , const pgRecoveryTarget * rt );
32
+ static bool satisfy_recovery_target (const pgBackup * backup ,
33
+ const pgRecoveryTarget * rt );
33
34
static TimeLineID get_current_timeline (void );
34
- static TimeLineID get_fullbackup_timeline (parray * backups , const pgRecoveryTarget * rt );
35
+ static TimeLineID get_fullbackup_timeline (parray * backups ,
36
+ const pgRecoveryTarget * rt );
35
37
static void print_backup_id (const pgBackup * backup );
36
- static void search_next_wal (const char * path , uint32 * needId , uint32 * needSeg , parray * timelines );
38
+ static void search_next_wal (const char * path ,
39
+ XLogRecPtr * need_lsn ,
40
+ parray * timelines );
37
41
38
42
int
39
43
do_restore (const char * target_time ,
@@ -53,9 +57,8 @@ do_restore(const char *target_time,
53
57
parray * files ;
54
58
parray * timelines ;
55
59
char timeline_dir [MAXPGPATH ];
56
- uint32 needId = 0 ;
57
- uint32 needSeg = 0 ;
58
60
pgRecoveryTarget * rt = NULL ;
61
+ XLogRecPtr need_lsn ;
59
62
60
63
/* PGDATA and ARCLOG_PATH are always required */
61
64
if (pgdata == NULL )
@@ -224,11 +227,7 @@ do_restore(const char *target_time,
224
227
if (check )
225
228
{
226
229
pgBackup * backup = (pgBackup * ) parray_get (backups , last_restored_index );
227
- uint32 xrecoff = (uint32 ) backup -> start_lsn ;
228
- uint32 xlogid = (uint32 ) (backup -> start_lsn >> 32 );
229
-
230
- needId = xlogid ;
231
- needSeg = xrecoff / XLogSegSize ;
230
+ need_lsn = backup -> start_lsn ;
232
231
}
233
232
234
233
for (i = last_restored_index ; i >= 0 ; i -- )
@@ -253,7 +252,7 @@ do_restore(const char *target_time,
253
252
char xlogpath [MAXPGPATH ];
254
253
255
254
pgBackupGetPath (backup , xlogpath , lengthof (xlogpath ), ARCLOG_DIR );
256
- search_next_wal (xlogpath , & needId , & needSeg , timelines );
255
+ search_next_wal (xlogpath , & need_lsn , timelines );
257
256
}
258
257
}
259
258
@@ -266,13 +265,13 @@ do_restore(const char *target_time,
266
265
if (verbose )
267
266
printf (_ ("searching archived WAL...\n" ));
268
267
269
- search_next_wal (arclog_path , & needId , & needSeg , timelines );
268
+ search_next_wal (arclog_path , & need_lsn , timelines );
270
269
271
270
if (verbose )
272
271
printf (_ ("searching online WAL...\n" ));
273
272
274
273
join_path_components (xlogpath , pgdata , PG_XLOG_DIR );
275
- search_next_wal (xlogpath , & needId , & needSeg , timelines );
274
+ search_next_wal (xlogpath , & need_lsn , timelines );
276
275
277
276
if (verbose )
278
277
printf (_ ("all necessary files are found.\n" ));
@@ -989,7 +988,7 @@ print_backup_id(const pgBackup *backup)
989
988
}
990
989
991
990
static void
992
- search_next_wal (const char * path , uint32 * needId , uint32 * needSeg , parray * timelines )
991
+ search_next_wal (const char * path , XLogRecPtr * need_lsn , parray * timelines )
993
992
{
994
993
int i ;
995
994
int j ;
@@ -1006,7 +1005,7 @@ search_next_wal(const char *path, uint32 *needId, uint32 *needSeg, parray *timel
1006
1005
{
1007
1006
pgTimeLine * timeline = (pgTimeLine * ) parray_get (timelines , i );
1008
1007
1009
- XLogFileNameLong (xlogfname , timeline -> tli , * needId , * needSeg );
1008
+ XLogFileName (xlogfname , timeline -> tli , * need_lsn );
1010
1009
join_path_components (xlogpath , path , xlogfname );
1011
1010
1012
1011
if (stat (xlogpath , & st ) == 0 )
@@ -1035,7 +1034,8 @@ search_next_wal(const char *path, uint32 *needId, uint32 *needSeg, parray *timel
1035
1034
parray_remove (timelines , i + 1 );
1036
1035
/* XXX: should we add a linebreak when we find a timeline? */
1037
1036
1038
- NextLogSeg (* needId , * needSeg );
1037
+ /* Move to next xlog record */
1038
+ (* need_lsn )++ ;
1039
1039
}
1040
1040
}
1041
1041
0 commit comments