@@ -106,7 +106,7 @@ digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
106106 * Write ControlFile to pg_control
107107 */
108108static void
109- writeControlFile (ControlFileData * ControlFile , const char * path , fio_location location )
109+ writeControlFile (fio_location location , const char * path , ControlFileData * ControlFile )
110110{
111111 int fd ;
112112 char * buffer = NULL ;
@@ -156,31 +156,31 @@ get_current_timeline(PGconn *conn)
156156 if (PQresultStatus (res ) == PGRES_TUPLES_OK )
157157 val = PQgetvalue (res , 0 , 0 );
158158 else
159- return get_current_timeline_from_control (instance_config .pgdata , FIO_DB_HOST , false);
159+ return get_current_timeline_from_control (FIO_DB_HOST , instance_config .pgdata , false);
160160
161161 if (!parse_uint32 (val , & tli , 0 ))
162162 {
163163 PQclear (res );
164164 elog (WARNING , "Invalid value of timeline_id %s" , val );
165165
166166 /* TODO 3.0 remove it and just error out */
167- return get_current_timeline_from_control (instance_config .pgdata , FIO_DB_HOST , false);
167+ return get_current_timeline_from_control (FIO_DB_HOST , instance_config .pgdata , false);
168168 }
169169
170170 return tli ;
171171}
172172
173173/* Get timeline from pg_control file */
174174TimeLineID
175- get_current_timeline_from_control (const char * pgdata_path , fio_location location , bool safe )
175+ get_current_timeline_from_control (fio_location location , const char * pgdata_path , bool safe )
176176{
177177 ControlFileData ControlFile ;
178178 char * buffer ;
179179 size_t size ;
180180
181181 /* First fetch file... */
182- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size ,
183- safe , location );
182+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE ,
183+ & size , safe );
184184 if (safe && buffer == NULL )
185185 return 0 ;
186186
@@ -218,11 +218,12 @@ get_checkpoint_location(PGconn *conn)
218218
219219 return lsn ;
220220#else
221+ /* PG-9.5 */
221222 char * buffer ;
222223 size_t size ;
223224 ControlFileData ControlFile ;
224225
225- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
226+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE , & size , false);
226227 digestControlFile (& ControlFile , buffer , size );
227228 pg_free (buffer );
228229
@@ -231,14 +232,14 @@ get_checkpoint_location(PGconn *conn)
231232}
232233
233234uint64
234- get_system_identifier (const char * pgdata_path , fio_location location , bool safe )
235+ get_system_identifier (fio_location location , const char * pgdata_path , bool safe )
235236{
236237 ControlFileData ControlFile ;
237238 char * buffer ;
238239 size_t size ;
239240
240241 /* First fetch file... */
241- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , safe , location );
242+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE , & size , safe );
242243 if (safe && buffer == NULL )
243244 return 0 ;
244245 digestControlFile (& ControlFile , buffer , size );
@@ -268,11 +269,12 @@ get_remote_system_identifier(PGconn *conn)
268269
269270 return system_id_conn ;
270271#else
272+ /* PG-9.5 */
271273 char * buffer ;
272274 size_t size ;
273275 ControlFileData ControlFile ;
274276
275- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
277+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE , & size , false);
276278 digestControlFile (& ControlFile , buffer , size );
277279 pg_free (buffer );
278280
@@ -289,7 +291,7 @@ get_xlog_seg_size(const char *pgdata_path)
289291 size_t size ;
290292
291293 /* First fetch file... */
292- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
294+ buffer = slurpFile (FIO_DB_HOST , pgdata_path , XLOG_CONTROL_FILE , & size , false);
293295 digestControlFile (& ControlFile , buffer , size );
294296 pg_free (buffer );
295297
@@ -307,8 +309,8 @@ get_data_checksum_version(bool safe)
307309 size_t size ;
308310
309311 /* First fetch file... */
310- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size ,
311- safe , FIO_DB_HOST );
312+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE ,
313+ & size , safe );
312314 if (buffer == NULL )
313315 return 0 ;
314316 digestControlFile (& ControlFile , buffer , size );
@@ -325,7 +327,7 @@ get_pgcontrol_checksum(const char *pgdata_path)
325327 size_t size ;
326328
327329 /* First fetch file... */
328- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, FIO_BACKUP_HOST );
330+ buffer = slurpFile (FIO_BACKUP_HOST , pgdata_path , XLOG_CONTROL_FILE , & size , false);
329331
330332 digestControlFile (& ControlFile , buffer , size );
331333 pg_free (buffer );
@@ -334,14 +336,14 @@ get_pgcontrol_checksum(const char *pgdata_path)
334336}
335337
336338void
337- get_redo (const char * pgdata_path , fio_location pgdata_location , RedoParams * redo )
339+ get_redo (fio_location location , const char * pgdata_path , RedoParams * redo )
338340{
339341 ControlFileData ControlFile ;
340342 char * buffer ;
341343 size_t size ;
342344
343345 /* First fetch file... */
344- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, pgdata_location );
346+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE , & size , false);
345347
346348 digestControlFile (& ControlFile , buffer , size );
347349 pg_free (buffer );
@@ -380,7 +382,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
380382 char fullpath [MAXPGPATH ];
381383
382384 /* First fetch file content */
383- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
385+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE , & size , false);
384386 digestControlFile (& ControlFile , buffer , size );
385387
386388 elog (LOG , "Current minRecPoint %X/%X" ,
@@ -401,7 +403,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
401403
402404 /* overwrite pg_control */
403405 join_path_components (fullpath , backup_path , XLOG_CONTROL_FILE );
404- writeControlFile (& ControlFile , fullpath , FIO_LOCAL_HOST );
406+ writeControlFile (FIO_LOCAL_HOST , fullpath , & ControlFile );
405407
406408 /* Update pg_control checksum in backup_list */
407409 file -> crc = ControlFile .crc ;
@@ -413,14 +415,14 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
413415 * Copy pg_control file to backup. We do not apply compression to this file.
414416 */
415417void
416- copy_pgcontrol_file (const char * from_fullpath , fio_location from_location ,
417- const char * to_fullpath , fio_location to_location , pgFile * file )
418+ copy_pgcontrol_file (fio_location from_location , const char * from_fullpath ,
419+ fio_location to_location , const char * to_fullpath , pgFile * file )
418420{
419421 ControlFileData ControlFile ;
420422 char * buffer ;
421423 size_t size ;
422424
423- buffer = slurpFile (from_fullpath , "" , & size , false, from_location );
425+ buffer = slurpFile (from_location , from_fullpath , "" , & size , false);
424426
425427 digestControlFile (& ControlFile , buffer , size );
426428
@@ -429,7 +431,7 @@ copy_pgcontrol_file(const char *from_fullpath, fio_location from_location,
429431 file -> write_size = size ;
430432 file -> uncompressed_size = size ;
431433
432- writeControlFile (& ControlFile , to_fullpath , to_location );
434+ writeControlFile (to_location , to_fullpath , & ControlFile );
433435
434436 pg_free (buffer );
435437}
0 commit comments