@@ -1028,11 +1028,15 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
1028
1028
GetXLogFileName (xlogfname ,reader_data -> tli ,reader_data -> xlogsegno ,wal_seg_size );
1029
1029
1030
1030
/* obtain WAL archive subdir for ARCHIVE backup */
1031
+ // TODO: move to separate function and rewrite it
1031
1032
if (reader_data -> honor_subdirs )
1032
1033
{
1033
1034
char archive_subdir [MAXPGPATH ];
1034
1035
get_archive_subdir (archive_subdir ,wal_archivedir ,xlogfname ,SEGMENT );
1035
1036
1037
+ /* default value for xlogpath for error message */
1038
+ snprintf (reader_data -> xlogpath ,MAXPGPATH ,"%s/%s" ,archive_subdir ,xlogfname );
1039
+
1036
1040
/* check existence of wal_dir/xlogid/segment.gz file ... */
1037
1041
snprintf (fullpath_gz ,MAXPGPATH ,"%s/%s.gz" ,archive_subdir ,xlogfname );
1038
1042
@@ -1069,6 +1073,8 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
1069
1073
/* use directory as-is */
1070
1074
else
1071
1075
{
1076
+ /* default value for xlogpath for error message */
1077
+ snprintf (reader_data -> xlogpath ,MAXPGPATH ,"%s/%s" ,wal_archivedir ,xlogfname );
1072
1078
archive_dir :
1073
1079
#ifdef HAVE_LIBZ
1074
1080
/* ... failing that check existence of wal_dir/segment.gz ... */
@@ -1130,7 +1136,6 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
1130
1136
elog (LOG ,"Thread [%d]: Opening WAL segment \"%s\"" ,
1131
1137
reader_data -> thread_num ,reader_data -> xlogpath );
1132
1138
1133
- reader_data -> xlogexists = true;
1134
1139
reader_data -> xlogfile = fio_open (reader_data -> xlogpath ,
1135
1140
O_RDONLY |PG_BINARY ,FIO_LOCAL_HOST );
1136
1141
@@ -1141,6 +1146,8 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
1141
1146
strerror (errno ));
1142
1147
return -1 ;
1143
1148
}
1149
+ else
1150
+ reader_data -> xlogexists = true;
1144
1151
}
1145
1152
#ifdef HAVE_LIBZ
1146
1153
/* Try to open compressed WAL segment */
@@ -1149,7 +1156,6 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
1149
1156
elog (LOG ,"Thread [%d]: Opening compressed WAL segment \"%s\"" ,
1150
1157
reader_data -> thread_num ,reader_data -> gz_xlogpath );
1151
1158
1152
- reader_data -> xlogexists = true;
1153
1159
reader_data -> gz_xlogfile = fio_gzopen (reader_data -> gz_xlogpath ,
1154
1160
"rb" ,-1 ,FIO_LOCAL_HOST );
1155
1161
if (reader_data -> gz_xlogfile == NULL )
@@ -1159,6 +1165,8 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
1159
1165
strerror (errno ));
1160
1166
return -1 ;
1161
1167
}
1168
+ else
1169
+ reader_data -> xlogexists = true;
1162
1170
}
1163
1171
#endif
1164
1172
/* Exit without error if WAL segment doesn't exist */