Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3ad6aaa

Browse files
committed
Verbose min/max segment in delwal.
1 parent 0ccc9ee commit 3ad6aaa

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

delete.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ int do_deletewal(time_t backup_id, bool strict)
139139
DIR *arcdir;
140140
struct dirent *arcde;
141141
char wal_file[MAXPGPATH];
142+
char max_wal_file[MAXPGPATH];
143+
char min_wal_file[MAXPGPATH];
142144
int rc;
143-
int i = 0;
144145

146+
max_wal_file[0] = '\0';
147+
min_wal_file[0] = '\0';
145148
XLByteToSeg(oldest_lsn, targetSegNo);
146149
XLogFileName(oldestSegmentNeeded, oldest_tli, targetSegNo);
147150
elog(LOG, "Removing segments older than %s", oldestSegmentNeeded);
@@ -188,17 +191,25 @@ int do_deletewal(time_t backup_id, bool strict)
188191
}
189192
if (verbose)
190193
elog(LOG, "removed WAL segment \"%s\"", wal_file);
191-
else
194+
195+
if (max_wal_file[0] == '\0' ||
196+
strcmp(max_wal_file + 8, arcde->d_name + 8) < 0)
192197
{
193-
if (i==0)
194-
elog(NOTICE, "removed WAL segment \"%s\"", wal_file);
198+
strcpy(max_wal_file, arcde->d_name);
199+
}
195200

201+
if (min_wal_file[0] == '\0' ||
202+
strcmp(min_wal_file + 8, arcde->d_name + 8) > 0)
203+
{
204+
strcpy(min_wal_file, arcde->d_name);
196205
}
197206
}
198-
i++;
199207
}
200-
if (!verbose && i != 0 && errno == 0)
201-
elog(NOTICE, "removed WAL segment \"%s\"", wal_file);
208+
209+
if (!verbose && min_wal_file[0] != '\0')
210+
elog(NOTICE, "removed min WAL segment \"%s\"", min_wal_file);
211+
if (!verbose && max_wal_file[0] != '\0')
212+
elog(NOTICE, "removed max WAL segment \"%s\"", max_wal_file);
202213

203214
if (errno)
204215
elog(WARNING, "could not read archive location \"%s\": %s",

0 commit comments

Comments
 (0)