@@ -122,7 +122,7 @@ digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
122122 * Write ControlFile to pg_control
123123 */
124124static void
125- writeControlFile (ControlFileData * ControlFile , const char * path , fio_location location )
125+ writeControlFile (fio_location location , const char * path , ControlFileData * ControlFile )
126126{
127127 int fd ;
128128 char * buffer = NULL ;
@@ -172,31 +172,31 @@ get_current_timeline(PGconn *conn)
172172 if (PQresultStatus (res ) == PGRES_TUPLES_OK )
173173 val = PQgetvalue (res , 0 , 0 );
174174 else
175- return get_current_timeline_from_control (instance_config .pgdata , FIO_DB_HOST , false);
175+ return get_current_timeline_from_control (FIO_DB_HOST , instance_config .pgdata , false);
176176
177177 if (!parse_uint32 (val , & tli , 0 ))
178178 {
179179 PQclear (res );
180180 elog (WARNING , "Invalid value of timeline_id %s" , val );
181181
182182 /* TODO 3.0 remove it and just error out */
183- return get_current_timeline_from_control (instance_config .pgdata , FIO_DB_HOST , false);
183+ return get_current_timeline_from_control (FIO_DB_HOST , instance_config .pgdata , false);
184184 }
185185
186186 return tli ;
187187}
188188
189189/* Get timeline from pg_control file */
190190TimeLineID
191- get_current_timeline_from_control (const char * pgdata_path , fio_location location , bool safe )
191+ get_current_timeline_from_control (fio_location location , const char * pgdata_path , bool safe )
192192{
193193 ControlFileData ControlFile ;
194194 char * buffer ;
195195 size_t size ;
196196
197197 /* First fetch file... */
198- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size ,
199- safe , location );
198+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE ,
199+ & size , safe );
200200 if (safe && buffer == NULL )
201201 return 0 ;
202202
@@ -234,11 +234,12 @@ get_checkpoint_location(PGconn *conn)
234234
235235 return lsn ;
236236#else
237+ /* PG-9.5 */
237238 char * buffer ;
238239 size_t size ;
239240 ControlFileData ControlFile ;
240241
241- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
242+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE , & size , false);
242243 digestControlFile (& ControlFile , buffer , size );
243244 pg_free (buffer );
244245
@@ -247,14 +248,14 @@ get_checkpoint_location(PGconn *conn)
247248}
248249
249250uint64
250- get_system_identifier (const char * pgdata_path , fio_location location , bool safe )
251+ get_system_identifier (fio_location location , const char * pgdata_path , bool safe )
251252{
252253 ControlFileData ControlFile ;
253254 char * buffer ;
254255 size_t size ;
255256
256257 /* First fetch file... */
257- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , safe , location );
258+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE , & size , safe );
258259 if (safe && buffer == NULL )
259260 return 0 ;
260261 digestControlFile (& ControlFile , buffer , size );
@@ -284,11 +285,12 @@ get_remote_system_identifier(PGconn *conn)
284285
285286 return system_id_conn ;
286287#else
288+ /* PG-9.5 */
287289 char * buffer ;
288290 size_t size ;
289291 ControlFileData ControlFile ;
290292
291- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
293+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE , & size , false);
292294 digestControlFile (& ControlFile , buffer , size );
293295 pg_free (buffer );
294296
@@ -305,7 +307,7 @@ get_xlog_seg_size(const char *pgdata_path)
305307 size_t size ;
306308
307309 /* First fetch file... */
308- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
310+ buffer = slurpFile (FIO_DB_HOST , pgdata_path , XLOG_CONTROL_FILE , & size , false);
309311 digestControlFile (& ControlFile , buffer , size );
310312 pg_free (buffer );
311313
@@ -323,8 +325,8 @@ get_data_checksum_version(bool safe)
323325 size_t size ;
324326
325327 /* First fetch file... */
326- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size ,
327- safe , FIO_DB_HOST );
328+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE ,
329+ & size , safe );
328330 if (buffer == NULL )
329331 return 0 ;
330332 digestControlFile (& ControlFile , buffer , size );
@@ -341,22 +343,23 @@ get_pgcontrol_checksum(const char *pgdata_path)
341343 size_t size ;
342344
343345 /* First fetch file... */
344- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, FIO_BACKUP_HOST );
346+ buffer = slurpFile (FIO_BACKUP_HOST , pgdata_path , XLOG_CONTROL_FILE , & size , false);
345347
346348 digestControlFile (& ControlFile , buffer , size );
347349 pg_free (buffer );
348350
349351 return ControlFile .crc ;
350352}
351353
354+ /* unused function */
352355DBState
353- get_system_dbstate (const char * pgdata_path , fio_location location )
356+ get_system_dbstate (fio_location location , const char * pgdata_path )
354357{
355358 ControlFileData ControlFile ;
356359 char * buffer ;
357360 size_t size ;
358361
359- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, location );
362+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE , & size , false);
360363 if (buffer == NULL )
361364 return 0 ;
362365 digestControlFile (& ControlFile , buffer , size );
@@ -366,14 +369,14 @@ get_system_dbstate(const char *pgdata_path, fio_location location)
366369}
367370
368371void
369- get_redo (const char * pgdata_path , fio_location pgdata_location , RedoParams * redo )
372+ get_redo (fio_location location , const char * pgdata_path , RedoParams * redo )
370373{
371374 ControlFileData ControlFile ;
372375 char * buffer ;
373376 size_t size ;
374377
375378 /* First fetch file... */
376- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, pgdata_location );
379+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE , & size , false);
377380
378381 digestControlFile (& ControlFile , buffer , size );
379382 pg_free (buffer );
@@ -412,7 +415,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
412415 char fullpath [MAXPGPATH ];
413416
414417 /* First fetch file content */
415- buffer = slurpFile (instance_config .pgdata , XLOG_CONTROL_FILE , & size , false, FIO_DB_HOST );
418+ buffer = slurpFile (FIO_DB_HOST , instance_config .pgdata , XLOG_CONTROL_FILE , & size , false);
416419 digestControlFile (& ControlFile , buffer , size );
417420
418421 elog (LOG , "Current minRecPoint %X/%X" ,
@@ -433,7 +436,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
433436
434437 /* overwrite pg_control */
435438 join_path_components (fullpath , backup_path , XLOG_CONTROL_FILE );
436- writeControlFile (& ControlFile , fullpath , FIO_LOCAL_HOST );
439+ writeControlFile (FIO_LOCAL_HOST , fullpath , & ControlFile );
437440
438441 /* Update pg_control checksum in backup_list */
439442 file -> crc = ControlFile .crc ;
@@ -445,14 +448,14 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
445448 * Copy pg_control file to backup. We do not apply compression to this file.
446449 */
447450void
448- copy_pgcontrol_file (const char * from_fullpath , fio_location from_location ,
449- const char * to_fullpath , fio_location to_location , pgFile * file )
451+ copy_pgcontrol_file (fio_location from_location , const char * from_fullpath ,
452+ fio_location to_location , const char * to_fullpath , pgFile * file )
450453{
451454 ControlFileData ControlFile ;
452455 char * buffer ;
453456 size_t size ;
454457
455- buffer = slurpFile (from_fullpath , "" , & size , false, from_location );
458+ buffer = slurpFile (from_location , from_fullpath , "" , & size , false);
456459
457460 digestControlFile (& ControlFile , buffer , size );
458461
@@ -461,7 +464,7 @@ copy_pgcontrol_file(const char *from_fullpath, fio_location from_location,
461464 file -> write_size = size ;
462465 file -> uncompressed_size = size ;
463466
464- writeControlFile (& ControlFile , to_fullpath , to_location );
467+ writeControlFile (to_location , to_fullpath , & ControlFile );
465468
466469 pg_free (buffer );
467470}
0 commit comments