@@ -59,18 +59,19 @@ mark_file_as_archived(StreamCtl *stream, const char *fname)
59
59
snprintf (tmppath , sizeof (tmppath ), "archive_status/%s.done" ,
60
60
fname );
61
61
62
- f = stream -> walmethod -> open_for_write (tmppath , NULL , 0 );
62
+ f = stream -> walmethod -> ops -> open_for_write (stream -> walmethod , tmppath ,
63
+ NULL , 0 );
63
64
if (f == NULL )
64
65
{
65
66
pg_log_error ("could not create archive status file \"%s\": %s" ,
66
- tmppath , stream -> walmethod -> getlasterror ( ));
67
+ tmppath , GetLastWalMethodError ( stream -> walmethod ));
67
68
return false;
68
69
}
69
70
70
- if (stream -> walmethod -> close (f , CLOSE_NORMAL ) != 0 )
71
+ if (stream -> walmethod -> ops -> close (f , CLOSE_NORMAL ) != 0 )
71
72
{
72
73
pg_log_error ("could not close archive status file \"%s\": %s" ,
73
- tmppath , stream -> walmethod -> getlasterror ( ));
74
+ tmppath , GetLastWalMethodError ( stream -> walmethod ));
74
75
return false;
75
76
}
76
77
@@ -98,8 +99,9 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
98
99
XLogFileName (walfile_name , stream -> timeline , segno , WalSegSz );
99
100
100
101
/* Note that this considers the compression used if necessary */
101
- fn = stream -> walmethod -> get_file_name (walfile_name ,
102
- stream -> partial_suffix );
102
+ fn = stream -> walmethod -> ops -> get_file_name (stream -> walmethod ,
103
+ walfile_name ,
104
+ stream -> partial_suffix );
103
105
104
106
/*
105
107
* When streaming to files, if an existing file exists we verify that it's
@@ -111,35 +113,35 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
111
113
* When streaming to tar, no file with this name will exist before, so we
112
114
* never have to verify a size.
113
115
*/
114
- if (stream -> walmethod -> compression_algorithm () == PG_COMPRESSION_NONE &&
115
- stream -> walmethod -> existsfile (fn ))
116
+ if (stream -> walmethod -> compression_algorithm == PG_COMPRESSION_NONE &&
117
+ stream -> walmethod -> ops -> existsfile (stream -> walmethod , fn ))
116
118
{
117
- size = stream -> walmethod -> get_file_size (fn );
119
+ size = stream -> walmethod -> ops -> get_file_size (stream -> walmethod , fn );
118
120
if (size < 0 )
119
121
{
120
122
pg_log_error ("could not get size of write-ahead log file \"%s\": %s" ,
121
- fn , stream -> walmethod -> getlasterror ( ));
123
+ fn , GetLastWalMethodError ( stream -> walmethod ));
122
124
pg_free (fn );
123
125
return false;
124
126
}
125
127
if (size == WalSegSz )
126
128
{
127
129
/* Already padded file. Open it for use */
128
- f = stream -> walmethod -> open_for_write (walfile_name , stream -> partial_suffix , 0 );
130
+ f = stream -> walmethod -> ops -> open_for_write (stream -> walmethod , walfile_name , stream -> partial_suffix , 0 );
129
131
if (f == NULL )
130
132
{
131
133
pg_log_error ("could not open existing write-ahead log file \"%s\": %s" ,
132
- fn , stream -> walmethod -> getlasterror ( ));
134
+ fn , GetLastWalMethodError ( stream -> walmethod ));
133
135
pg_free (fn );
134
136
return false;
135
137
}
136
138
137
139
/* fsync file in case of a previous crash */
138
- if (stream -> walmethod -> sync (f ) != 0 )
140
+ if (stream -> walmethod -> ops -> sync (f ) != 0 )
139
141
{
140
142
pg_log_error ("could not fsync existing write-ahead log file \"%s\": %s" ,
141
- fn , stream -> walmethod -> getlasterror ( ));
142
- stream -> walmethod -> close (f , CLOSE_UNLINK );
143
+ fn , GetLastWalMethodError ( stream -> walmethod ));
144
+ stream -> walmethod -> ops -> close (f , CLOSE_UNLINK );
143
145
exit (1 );
144
146
}
145
147
@@ -164,12 +166,14 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
164
166
165
167
/* No file existed, so create one */
166
168
167
- f = stream -> walmethod -> open_for_write (walfile_name ,
168
- stream -> partial_suffix , WalSegSz );
169
+ f = stream -> walmethod -> ops -> open_for_write (stream -> walmethod ,
170
+ walfile_name ,
171
+ stream -> partial_suffix ,
172
+ WalSegSz );
169
173
if (f == NULL )
170
174
{
171
175
pg_log_error ("could not open write-ahead log file \"%s\": %s" ,
172
- fn , stream -> walmethod -> getlasterror ( ));
176
+ fn , GetLastWalMethodError ( stream -> walmethod ));
173
177
pg_free (fn );
174
178
return false;
175
179
}
@@ -199,28 +203,29 @@ close_walfile(StreamCtl *stream, XLogRecPtr pos)
199
203
currpos = walfile -> currpos ;
200
204
201
205
/* Note that this considers the compression used if necessary */
202
- fn = stream -> walmethod -> get_file_name (walfile_name ,
203
- stream -> partial_suffix );
206
+ fn = stream -> walmethod -> ops -> get_file_name (stream -> walmethod ,
207
+ walfile_name ,
208
+ stream -> partial_suffix );
204
209
205
210
if (stream -> partial_suffix )
206
211
{
207
212
if (currpos == WalSegSz )
208
- r = stream -> walmethod -> close (walfile , CLOSE_NORMAL );
213
+ r = stream -> walmethod -> ops -> close (walfile , CLOSE_NORMAL );
209
214
else
210
215
{
211
216
pg_log_info ("not renaming \"%s\", segment is not complete" , fn );
212
- r = stream -> walmethod -> close (walfile , CLOSE_NO_RENAME );
217
+ r = stream -> walmethod -> ops -> close (walfile , CLOSE_NO_RENAME );
213
218
}
214
219
}
215
220
else
216
- r = stream -> walmethod -> close (walfile , CLOSE_NORMAL );
221
+ r = stream -> walmethod -> ops -> close (walfile , CLOSE_NORMAL );
217
222
218
223
walfile = NULL ;
219
224
220
225
if (r != 0 )
221
226
{
222
227
pg_log_error ("could not close file \"%s\": %s" ,
223
- fn , stream -> walmethod -> getlasterror ( ));
228
+ fn , GetLastWalMethodError ( stream -> walmethod ));
224
229
225
230
pg_free (fn );
226
231
return false;
@@ -263,7 +268,7 @@ existsTimeLineHistoryFile(StreamCtl *stream)
263
268
264
269
TLHistoryFileName (histfname , stream -> timeline );
265
270
266
- return stream -> walmethod -> existsfile (histfname );
271
+ return stream -> walmethod -> ops -> existsfile (stream -> walmethod , histfname );
267
272
}
268
273
269
274
static bool
@@ -285,31 +290,32 @@ writeTimeLineHistoryFile(StreamCtl *stream, char *filename, char *content)
285
290
return false;
286
291
}
287
292
288
- f = stream -> walmethod -> open_for_write (histfname , ".tmp" , 0 );
293
+ f = stream -> walmethod -> ops -> open_for_write (stream -> walmethod ,
294
+ histfname , ".tmp" , 0 );
289
295
if (f == NULL )
290
296
{
291
297
pg_log_error ("could not create timeline history file \"%s\": %s" ,
292
- histfname , stream -> walmethod -> getlasterror ( ));
298
+ histfname , GetLastWalMethodError ( stream -> walmethod ));
293
299
return false;
294
300
}
295
301
296
- if ((int ) stream -> walmethod -> write (f , content , size ) != size )
302
+ if ((int ) stream -> walmethod -> ops -> write (f , content , size ) != size )
297
303
{
298
304
pg_log_error ("could not write timeline history file \"%s\": %s" ,
299
- histfname , stream -> walmethod -> getlasterror ( ));
305
+ histfname , GetLastWalMethodError ( stream -> walmethod ));
300
306
301
307
/*
302
308
* If we fail to make the file, delete it to release disk space
303
309
*/
304
- stream -> walmethod -> close (f , CLOSE_UNLINK );
310
+ stream -> walmethod -> ops -> close (f , CLOSE_UNLINK );
305
311
306
312
return false;
307
313
}
308
314
309
- if (stream -> walmethod -> close (f , CLOSE_NORMAL ) != 0 )
315
+ if (stream -> walmethod -> ops -> close (f , CLOSE_NORMAL ) != 0 )
310
316
{
311
317
pg_log_error ("could not close file \"%s\": %s" ,
312
- histfname , stream -> walmethod -> getlasterror ( ));
318
+ histfname , GetLastWalMethodError ( stream -> walmethod ));
313
319
return false;
314
320
}
315
321
@@ -678,9 +684,9 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
678
684
}
679
685
680
686
error :
681
- if (walfile != NULL && stream -> walmethod -> close (walfile , CLOSE_NO_RENAME ) != 0 )
687
+ if (walfile != NULL && stream -> walmethod -> ops -> close (walfile , CLOSE_NO_RENAME ) != 0 )
682
688
pg_log_error ("could not close file \"%s\": %s" ,
683
- walfile -> pathname , stream -> walmethod -> getlasterror ( ));
689
+ walfile -> pathname , GetLastWalMethodError ( stream -> walmethod ));
684
690
walfile = NULL ;
685
691
return false;
686
692
}
@@ -765,9 +771,9 @@ HandleCopyStream(PGconn *conn, StreamCtl *stream,
765
771
*/
766
772
if (stream -> synchronous && lastFlushPosition < blockpos && walfile != NULL )
767
773
{
768
- if (stream -> walmethod -> sync (walfile ) != 0 )
774
+ if (stream -> walmethod -> ops -> sync (walfile ) != 0 )
769
775
pg_fatal ("could not fsync file \"%s\": %s" ,
770
- walfile -> pathname , stream -> walmethod -> getlasterror ( ));
776
+ walfile -> pathname , GetLastWalMethodError ( stream -> walmethod ));
771
777
lastFlushPosition = blockpos ;
772
778
773
779
/*
@@ -1012,9 +1018,9 @@ ProcessKeepaliveMsg(PGconn *conn, StreamCtl *stream, char *copybuf, int len,
1012
1018
* data has been successfully replicated or not, at the normal
1013
1019
* shutdown of the server.
1014
1020
*/
1015
- if (stream -> walmethod -> sync (walfile ) != 0 )
1021
+ if (stream -> walmethod -> ops -> sync (walfile ) != 0 )
1016
1022
pg_fatal ("could not fsync file \"%s\": %s" ,
1017
- walfile -> pathname , stream -> walmethod -> getlasterror ( ));
1023
+ walfile -> pathname , GetLastWalMethodError ( stream -> walmethod ));
1018
1024
lastFlushPosition = blockpos ;
1019
1025
}
1020
1026
@@ -1115,12 +1121,13 @@ ProcessXLogDataMsg(PGconn *conn, StreamCtl *stream, char *copybuf, int len,
1115
1121
}
1116
1122
}
1117
1123
1118
- if (stream -> walmethod -> write (walfile , copybuf + hdr_len + bytes_written ,
1119
- bytes_to_write ) != bytes_to_write )
1124
+ if (stream -> walmethod -> ops -> write (walfile ,
1125
+ copybuf + hdr_len + bytes_written ,
1126
+ bytes_to_write ) != bytes_to_write )
1120
1127
{
1121
1128
pg_log_error ("could not write %d bytes to WAL file \"%s\": %s" ,
1122
1129
bytes_to_write , walfile -> pathname ,
1123
- stream -> walmethod -> getlasterror ( ));
1130
+ GetLastWalMethodError ( stream -> walmethod ));
1124
1131
return false;
1125
1132
}
1126
1133
0 commit comments