@@ -139,9 +139,12 @@ int do_deletewal(time_t backup_id, bool strict)
139
139
DIR * arcdir ;
140
140
struct dirent * arcde ;
141
141
char wal_file [MAXPGPATH ];
142
+ char max_wal_file [MAXPGPATH ];
143
+ char min_wal_file [MAXPGPATH ];
142
144
int rc ;
143
- int i = 0 ;
144
145
146
+ max_wal_file [0 ]= '\0' ;
147
+ min_wal_file [0 ]= '\0' ;
145
148
XLByteToSeg (oldest_lsn ,targetSegNo );
146
149
XLogFileName (oldestSegmentNeeded ,oldest_tli ,targetSegNo );
147
150
elog (LOG ,"Removing segments older than %s" ,oldestSegmentNeeded );
@@ -188,17 +191,25 @@ int do_deletewal(time_t backup_id, bool strict)
188
191
}
189
192
if (verbose )
190
193
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 )
192
197
{
193
- if ( i == 0 )
194
- elog ( NOTICE , "removed WAL segment \"%s\"" , wal_file );
198
+ strcpy ( max_wal_file , arcde -> d_name );
199
+ }
195
200
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 );
196
205
}
197
206
}
198
- i ++ ;
199
207
}
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 );
202
213
203
214
if (errno )
204
215
elog (WARNING ,"could not read archive location \"%s\": %s" ,