Skip to content

Commit 2b23095

Browse files
committed
[Issue #155] Use full filename as segno
1 parent eccd847 commit 2b23095

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/catalog.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ catalog_get_timelines(InstanceConfig *instance)
697697
char arclog_path[MAXPGPATH];
698698

699699
/* for fancy reporting */
700-
char begin_segno_str[20];
701-
char end_segno_str[20];
700+
char begin_segno_str[XLOG_FNAME_LEN];
701+
char end_segno_str[XLOG_FNAME_LEN];
702702

703703
/* read all xlog files that belong to this archive */
704704
sprintf(arclog_path, "%s/%s/%s", backup_path, "wal", instance->name);
@@ -1119,8 +1119,8 @@ catalog_get_timelines(InstanceConfig *instance)
11191119
* covered by other larger interval.
11201120
*/
11211121

1122-
GetXLogSegName(begin_segno_str, interval->begin_segno, instance->xlog_seg_size);
1123-
GetXLogSegName(end_segno_str, interval->end_segno, instance->xlog_seg_size);
1122+
GetXLogFileName(begin_segno_str, tlinfo->tli, interval->begin_segno, instance->xlog_seg_size);
1123+
GetXLogFileName(end_segno_str, tlinfo->tli, interval->end_segno, instance->xlog_seg_size);
11241124

11251125
elog(LOG, "Timeline %i to stay reachable from timeline %i "
11261126
"protect from purge WAL interval between "
@@ -1174,8 +1174,8 @@ catalog_get_timelines(InstanceConfig *instance)
11741174
else
11751175
interval->end_segno = segno;
11761176

1177-
GetXLogSegName(begin_segno_str, interval->begin_segno, instance->xlog_seg_size);
1178-
GetXLogSegName(end_segno_str, interval->end_segno, instance->xlog_seg_size);
1177+
GetXLogFileName(begin_segno_str, tlinfo->tli, interval->begin_segno, instance->xlog_seg_size);
1178+
GetXLogFileName(end_segno_str, tlinfo->tli, interval->end_segno, instance->xlog_seg_size);
11791179

11801180
elog(LOG, "Archive backup %s to stay consistent "
11811181
"protect from purge WAL interval "

src/delete.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ delete_walfiles_in_tli(XLogRecPtr keep_lsn, timelineInfo *tlinfo,
810810
{
811811
XLogSegNo FirstToDeleteSegNo;
812812
XLogSegNo OldestToKeepSegNo = 0;
813-
char first_to_del_str[20];
814-
char oldest_to_keep_str[20];
813+
char first_to_del_str[XLOG_FNAME_LEN];
814+
char oldest_to_keep_str[XLOG_FNAME_LEN];
815815
int rc;
816816
int i;
817817
size_t wal_size_logical = 0;
@@ -846,8 +846,8 @@ delete_walfiles_in_tli(XLogRecPtr keep_lsn, timelineInfo *tlinfo,
846846
if (OldestToKeepSegNo > 0 && OldestToKeepSegNo > FirstToDeleteSegNo)
847847
{
848848
/* translate segno number into human readable format */
849-
GetXLogSegName(first_to_del_str, FirstToDeleteSegNo, xlog_seg_size);
850-
GetXLogSegName(oldest_to_keep_str, OldestToKeepSegNo, xlog_seg_size);
849+
GetXLogFileName(first_to_del_str, tlinfo->tli, FirstToDeleteSegNo, xlog_seg_size);
850+
GetXLogFileName(oldest_to_keep_str, tlinfo->tli, OldestToKeepSegNo, xlog_seg_size);
851851

852852
elog(INFO, "On timeline %i WAL segments between %s and %s %s be removed",
853853
tlinfo->tli, first_to_del_str,
@@ -874,8 +874,8 @@ delete_walfiles_in_tli(XLogRecPtr keep_lsn, timelineInfo *tlinfo,
874874

875875
if (FirstToDeleteSegNo > 0 && OldestToKeepSegNo > 0)
876876
{
877-
GetXLogSegName(first_to_del_str, FirstToDeleteSegNo, xlog_seg_size);
878-
GetXLogSegName(oldest_to_keep_str, OldestToKeepSegNo, xlog_seg_size);
877+
GetXLogFileName(first_to_del_str, tlinfo->tli, FirstToDeleteSegNo, xlog_seg_size);
878+
GetXLogFileName(oldest_to_keep_str, tlinfo->tli, OldestToKeepSegNo, xlog_seg_size);
879879

880880
elog(LOG, "On timeline %i first segment %s is greater than oldest segment to keep %s",
881881
tlinfo->tli, first_to_del_str, oldest_to_keep_str);

src/show.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ typedef struct ShowArchiveRow
4343
char tli[20];
4444
char parent_tli[20];
4545
char switchpoint[20];
46-
char min_segno[20];
47-
char max_segno[20];
46+
char min_segno[XLOG_FNAME_LEN+1];
47+
char max_segno[XLOG_FNAME_LEN+1];
4848
char n_segments[20];
4949
char size[20];
5050
char zratio[20];
@@ -749,7 +749,7 @@ static void
749749
show_archive_plain(const char *instance_name, uint32 xlog_seg_size,
750750
parray *tli_list, bool show_name)
751751
{
752-
char segno_tmp[20];
752+
char segno_tmp[XLOG_FNAME_LEN];
753753
parray *actual_tli_list = parray_new();
754754
#define SHOW_ARCHIVE_FIELDS_COUNT 10
755755
int i;
@@ -808,14 +808,14 @@ show_archive_plain(const char *instance_name, uint32 xlog_seg_size,
808808
cur++;
809809

810810
/* Min Segno */
811-
GetXLogSegName(segno_tmp, tlinfo->begin_segno, xlog_seg_size);
811+
GetXLogFileName(segno_tmp, tlinfo->tli, tlinfo->begin_segno, xlog_seg_size);
812812
snprintf(row->min_segno, lengthof(row->min_segno), "%s",segno_tmp);
813813

814814
widths[cur] = Max(widths[cur], strlen(row->min_segno));
815815
cur++;
816816

817817
/* Max Segno */
818-
GetXLogSegName(segno_tmp, tlinfo->end_segno, xlog_seg_size);
818+
GetXLogFileName(segno_tmp, tlinfo->tli, tlinfo->end_segno, xlog_seg_size);
819819
snprintf(row->max_segno, lengthof(row->max_segno), "%s", segno_tmp);
820820

821821
widths[cur] = Max(widths[cur], strlen(row->max_segno));
@@ -940,7 +940,7 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
940940
int i,j;
941941
PQExpBuffer buf = &show_buf;
942942
parray *actual_tli_list = parray_new();
943-
char segno_tmp[20];
943+
char segno_tmp[XLOG_FNAME_LEN+1];
944944

945945
if (!first_instance)
946946
appendPQExpBufferChar(buf, ',');
@@ -969,7 +969,7 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
969969
for (i = parray_num(actual_tli_list) - 1; i >= 0; i--)
970970
{
971971
timelineInfo *tlinfo = (timelineInfo *) parray_get(actual_tli_list, i);
972-
char tmp_buf[20];
972+
char tmp_buf[XLOG_FNAME_LEN+1];
973973
float zratio = 0;
974974

975975
if (i != (parray_num(actual_tli_list) - 1))
@@ -987,11 +987,11 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
987987
(uint32) (tlinfo->switchpoint >> 32), (uint32) tlinfo->switchpoint);
988988
json_add_value(buf, "switchpoint", tmp_buf, json_level, true);
989989

990-
GetXLogSegName(segno_tmp, tlinfo->begin_segno, xlog_seg_size);
990+
GetXLogFileName(segno_tmp, tlinfo->tli, tlinfo->begin_segno, xlog_seg_size);
991991
snprintf(tmp_buf, lengthof(tmp_buf), "%s", segno_tmp);
992992
json_add_value(buf, "min-segno", tmp_buf, json_level, true);
993993

994-
GetXLogSegName(segno_tmp, tlinfo->end_segno, xlog_seg_size);
994+
GetXLogFileName(segno_tmp, tlinfo->tli, tlinfo->end_segno, xlog_seg_size);
995995
snprintf(tmp_buf, lengthof(tmp_buf), "%s", segno_tmp);
996996
json_add_value(buf, "max-segno", tmp_buf, json_level, true);
997997

@@ -1034,11 +1034,11 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
10341034

10351035
json_add(buf, JT_BEGIN_OBJECT, &json_level);
10361036

1037-
GetXLogSegName(segno_tmp, lost_segments->begin_segno, xlog_seg_size);
1037+
GetXLogFileName(segno_tmp, tlinfo->tli, lost_segments->begin_segno, xlog_seg_size);
10381038
snprintf(tmp_buf, lengthof(tmp_buf), "%s", segno_tmp);
10391039
json_add_value(buf, "begin-segno", tmp_buf, json_level, true);
10401040

1041-
GetXLogSegName(segno_tmp, lost_segments->end_segno, xlog_seg_size);
1041+
GetXLogFileName(segno_tmp, tlinfo->tli, lost_segments->end_segno, xlog_seg_size);
10421042
snprintf(tmp_buf, lengthof(tmp_buf), "%s", segno_tmp);
10431043
json_add_value(buf, "end-segno", tmp_buf, json_level, true);
10441044
json_add(buf, JT_END_OBJECT, &json_level);

0 commit comments

Comments
 (0)