Skip to content

Commit

Permalink
wal_utils: Fix compilation with Postgres 11
Browse files Browse the repository at this point in the history
The WAL segment file is not a compilation-time variable anymore and can
be changed at initialization time, so adapt the code to cope with that.
  • Loading branch information
michaelpq committed May 31, 2018
1 parent f6d1e98 commit 090acda
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions wal_utils/wal_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sys/stat.h>

#include "access/timeline.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "catalog/pg_type.h"
#include "funcapi.h"
Expand Down Expand Up @@ -394,8 +395,8 @@ archive_build_segment_list(PG_FUNCTION_ARGS)
*/

/* Begin tracking at the beginning of the next segment */
current_seg_lsn = origin_lsn + XLOG_SEG_SIZE;
current_seg_lsn -= current_seg_lsn % XLOG_SEG_SIZE;
current_seg_lsn = origin_lsn + wal_segment_size;
current_seg_lsn -= current_seg_lsn % wal_segment_size;
current_tli = origin_tli;

foreach(entry, entries)
Expand All @@ -408,8 +409,8 @@ archive_build_segment_list(PG_FUNCTION_ARGS)
while (current_seg_lsn >= history->begin &&
current_seg_lsn < history->end)
{
XLByteToPrevSeg(current_seg_lsn, logSegNo);
XLogFileName(xlogfname, current_tli, logSegNo);
XLByteToPrevSeg(current_seg_lsn, logSegNo, wal_segment_size);
XLogFileName(xlogfname, current_tli, logSegNo, wal_segment_size);
nulls[0] = false;
values[0] = CStringGetTextDatum(xlogfname);
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
Expand All @@ -418,17 +419,17 @@ archive_build_segment_list(PG_FUNCTION_ARGS)
* Add equivalent of one segment, and just track the beginning
* of it.
*/
current_seg_lsn += XLOG_SEG_SIZE;
current_seg_lsn -= current_seg_lsn % XLOG_SEG_SIZE;
current_seg_lsn += wal_segment_size;
current_seg_lsn -= current_seg_lsn % wal_segment_size;
}
}

/*
* Add as well the last segment possible, this is needed to reach
* consistency up to the target point.
*/
XLByteToPrevSeg(target_lsn, logSegNo);
XLogFileName(xlogfname, target_tli, logSegNo);
XLByteToPrevSeg(target_lsn, logSegNo, wal_segment_size);
XLogFileName(xlogfname, target_tli, logSegNo, wal_segment_size);
nulls[0] = false;
values[0] = CStringGetTextDatum(xlogfname);
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
Expand Down

0 comments on commit 090acda

Please sign in to comment.