@@ -29,11 +29,15 @@ static pgRecoveryTarget *checkIfCreateRecoveryConf(const char *target_time,
2929const char * target_inclusive );
3030static parray * readTimeLineHistory (TimeLineID targetTLI );
3131static 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 );
3334static 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 );
3537static 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 );
3741
3842int
3943do_restore (const char * target_time ,
@@ -53,9 +57,8 @@ do_restore(const char *target_time,
5357parray * files ;
5458parray * timelines ;
5559char timeline_dir [MAXPGPATH ];
56- uint32 needId = 0 ;
57- uint32 needSeg = 0 ;
5860pgRecoveryTarget * rt = NULL ;
61+ XLogRecPtr need_lsn ;
5962
6063/* PGDATA and ARCLOG_PATH are always required */
6164if (pgdata == NULL )
@@ -224,11 +227,7 @@ do_restore(const char *target_time,
224227if (check )
225228{
226229pgBackup * 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 ;
232231}
233232
234233for (i = last_restored_index ;i >=0 ;i -- )
@@ -253,7 +252,7 @@ do_restore(const char *target_time,
253252char xlogpath [MAXPGPATH ];
254253
255254pgBackupGetPath (backup ,xlogpath ,lengthof (xlogpath ),ARCLOG_DIR );
256- search_next_wal (xlogpath ,& needId , & needSeg ,timelines );
255+ search_next_wal (xlogpath ,& need_lsn ,timelines );
257256}
258257}
259258
@@ -266,13 +265,13 @@ do_restore(const char *target_time,
266265if (verbose )
267266printf (_ ("searching archived WAL...\n" ));
268267
269- search_next_wal (arclog_path ,& needId , & needSeg ,timelines );
268+ search_next_wal (arclog_path ,& need_lsn ,timelines );
270269
271270if (verbose )
272271printf (_ ("searching online WAL...\n" ));
273272
274273join_path_components (xlogpath ,pgdata ,PG_XLOG_DIR );
275- search_next_wal (xlogpath ,& needId , & needSeg ,timelines );
274+ search_next_wal (xlogpath ,& need_lsn ,timelines );
276275
277276if (verbose )
278277printf (_ ("all necessary files are found.\n" ));
@@ -989,7 +988,7 @@ print_backup_id(const pgBackup *backup)
989988}
990989
991990static 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 )
993992{
994993int i ;
995994int j ;
@@ -1006,7 +1005,7 @@ search_next_wal(const char *path, uint32 *needId, uint32 *needSeg, parray *timel
10061005{
10071006pgTimeLine * timeline = (pgTimeLine * )parray_get (timelines ,i );
10081007
1009- XLogFileNameLong (xlogfname ,timeline -> tli ,* needId , * needSeg );
1008+ XLogFileName (xlogfname ,timeline -> tli ,* need_lsn );
10101009join_path_components (xlogpath ,path ,xlogfname );
10111010
10121011if (stat (xlogpath ,& st )== 0 )
@@ -1035,7 +1034,8 @@ search_next_wal(const char *path, uint32 *needId, uint32 *needSeg, parray *timel
10351034parray_remove (timelines ,i + 1 );
10361035/* XXX: should we add a linebreak when we find a timeline? */
10371036
1038- NextLogSeg (* needId ,* needSeg );
1037+ /* Move to next xlog record */
1038+ (* need_lsn )++ ;
10391039}
10401040}
10411041