Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf6ca26

Browse files
author
Michael Paquier
committed
Remove notion of Xlog ID/offset and use XLogRecPtr instead
This simplifies algorithm and APIs a bit, and removes a duplicationfunction used to generate a file name...
1 parent5bc7164 commitcf6ca26

File tree

2 files changed

+16
-31
lines changed

2 files changed

+16
-31
lines changed

‎pg_rman.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,4 @@ extern void remove_not_digit(char *buf, size_t len, const char *str);
318318
/* in pgsql_src/pg_ctl.c */
319319
externboolis_pg_running(void);
320320

321-
#defineNextLogSeg(logId,logSeg)\
322-
do { \
323-
if ((logSeg) >= XLogSegmentsPerXLogId - 1) \
324-
{ \
325-
(logId)++; \
326-
(logSeg) = 0; \
327-
} \
328-
else \
329-
(logSeg)++; \
330-
} while (0)
331-
332-
#defineMAXFNAMELEN64
333-
#defineXLogFileNameLong(fname,tli,log,seg)\
334-
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, log, seg)
335-
336321
#endif/* PG_RMAN_H */

‎restore.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ static pgRecoveryTarget *checkIfCreateRecoveryConf(const char *target_time,
2929
constchar*target_inclusive);
3030
staticparray*readTimeLineHistory(TimeLineIDtargetTLI);
3131
staticboolsatisfy_timeline(constparray*timelines,constpgBackup*backup);
32-
staticboolsatisfy_recovery_target(constpgBackup*backup,constpgRecoveryTarget*rt);
32+
staticboolsatisfy_recovery_target(constpgBackup*backup,
33+
constpgRecoveryTarget*rt);
3334
staticTimeLineIDget_current_timeline(void);
34-
staticTimeLineIDget_fullbackup_timeline(parray*backups,constpgRecoveryTarget*rt);
35+
staticTimeLineIDget_fullbackup_timeline(parray*backups,
36+
constpgRecoveryTarget*rt);
3537
staticvoidprint_backup_id(constpgBackup*backup);
36-
staticvoidsearch_next_wal(constchar*path,uint32*needId,uint32*needSeg,parray*timelines);
38+
staticvoidsearch_next_wal(constchar*path,
39+
XLogRecPtr*need_lsn,
40+
parray*timelines);
3741

3842
int
3943
do_restore(constchar*target_time,
@@ -53,9 +57,8 @@ do_restore(const char *target_time,
5357
parray*files;
5458
parray*timelines;
5559
chartimeline_dir[MAXPGPATH];
56-
uint32needId=0;
57-
uint32needSeg=0;
5860
pgRecoveryTarget*rt=NULL;
61+
XLogRecPtrneed_lsn;
5962

6063
/* PGDATA and ARCLOG_PATH are always required */
6164
if (pgdata==NULL)
@@ -224,11 +227,7 @@ do_restore(const char *target_time,
224227
if (check)
225228
{
226229
pgBackup*backup= (pgBackup*)parray_get(backups,last_restored_index);
227-
uint32xrecoff= (uint32)backup->start_lsn;
228-
uint32xlogid= (uint32) (backup->start_lsn >>32);
229-
230-
needId=xlogid;
231-
needSeg=xrecoff /XLogSegSize;
230+
need_lsn=backup->start_lsn;
232231
}
233232

234233
for (i=last_restored_index;i >=0;i--)
@@ -253,7 +252,7 @@ do_restore(const char *target_time,
253252
charxlogpath[MAXPGPATH];
254253

255254
pgBackupGetPath(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,
266265
if (verbose)
267266
printf(_("searching archived WAL...\n"));
268267

269-
search_next_wal(arclog_path,&needId,&needSeg,timelines);
268+
search_next_wal(arclog_path,&need_lsn,timelines);
270269

271270
if (verbose)
272271
printf(_("searching online WAL...\n"));
273272

274273
join_path_components(xlogpath,pgdata,PG_XLOG_DIR);
275-
search_next_wal(xlogpath,&needId,&needSeg,timelines);
274+
search_next_wal(xlogpath,&need_lsn,timelines);
276275

277276
if (verbose)
278277
printf(_("all necessary files are found.\n"));
@@ -989,7 +988,7 @@ print_backup_id(const pgBackup *backup)
989988
}
990989

991990
staticvoid
992-
search_next_wal(constchar*path,uint32*needId,uint32*needSeg,parray*timelines)
991+
search_next_wal(constchar*path,XLogRecPtr*need_lsn,parray*timelines)
993992
{
994993
inti;
995994
intj;
@@ -1006,7 +1005,7 @@ search_next_wal(const char *path, uint32 *needId, uint32 *needSeg, parray *timel
10061005
{
10071006
pgTimeLine*timeline= (pgTimeLine*)parray_get(timelines,i);
10081007

1009-
XLogFileNameLong(xlogfname,timeline->tli,*needId,*needSeg);
1008+
XLogFileName(xlogfname,timeline->tli,*need_lsn);
10101009
join_path_components(xlogpath,path,xlogfname);
10111010

10121011
if (stat(xlogpath,&st)==0)
@@ -1035,7 +1034,8 @@ search_next_wal(const char *path, uint32 *needId, uint32 *needSeg, parray *timel
10351034
parray_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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp