@@ -122,7 +122,7 @@ digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
122
122
* Write ControlFile to pg_control
123
123
*/
124
124
static void
125
- writeControlFile (ControlFileData * ControlFile , const char * path , fio_location location )
125
+ writeControlFile (fio_location location , const char * path , ControlFileData * ControlFile )
126
126
{
127
127
int fd ;
128
128
char * buffer = NULL ;
@@ -172,31 +172,31 @@ get_current_timeline(PGconn *conn)
172
172
if (PQresultStatus (res ) == PGRES_TUPLES_OK )
173
173
val = PQgetvalue (res , 0 , 0 );
174
174
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);
176
176
177
177
if (!parse_uint32 (val , & tli , 0 ))
178
178
{
179
179
PQclear (res );
180
180
elog (WARNING , "Invalid value of timeline_id %s" , val );
181
181
182
182
/* 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);
184
184
}
185
185
186
186
return tli ;
187
187
}
188
188
189
189
/* Get timeline from pg_control file */
190
190
TimeLineID
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 )
192
192
{
193
193
ControlFileData ControlFile ;
194
194
char * buffer ;
195
195
size_t size ;
196
196
197
197
/* 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 );
200
200
if (safe && buffer == NULL )
201
201
return 0 ;
202
202
@@ -234,11 +234,12 @@ get_checkpoint_location(PGconn *conn)
234
234
235
235
return lsn ;
236
236
#else
237
+ /* PG-9.5 */
237
238
char * buffer ;
238
239
size_t size ;
239
240
ControlFileData ControlFile ;
240
241
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);
242
243
digestControlFile (& ControlFile , buffer , size );
243
244
pg_free (buffer );
244
245
@@ -247,14 +248,14 @@ get_checkpoint_location(PGconn *conn)
247
248
}
248
249
249
250
uint64
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 )
251
252
{
252
253
ControlFileData ControlFile ;
253
254
char * buffer ;
254
255
size_t size ;
255
256
256
257
/* 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 );
258
259
if (safe && buffer == NULL )
259
260
return 0 ;
260
261
digestControlFile (& ControlFile , buffer , size );
@@ -284,11 +285,12 @@ get_remote_system_identifier(PGconn *conn)
284
285
285
286
return system_id_conn ;
286
287
#else
288
+ /* PG-9.5 */
287
289
char * buffer ;
288
290
size_t size ;
289
291
ControlFileData ControlFile ;
290
292
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);
292
294
digestControlFile (& ControlFile , buffer , size );
293
295
pg_free (buffer );
294
296
@@ -305,7 +307,7 @@ get_xlog_seg_size(const char *pgdata_path)
305
307
size_t size ;
306
308
307
309
/* 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);
309
311
digestControlFile (& ControlFile , buffer , size );
310
312
pg_free (buffer );
311
313
@@ -323,8 +325,8 @@ get_data_checksum_version(bool safe)
323
325
size_t size ;
324
326
325
327
/* 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 );
328
330
if (buffer == NULL )
329
331
return 0 ;
330
332
digestControlFile (& ControlFile , buffer , size );
@@ -341,22 +343,23 @@ get_pgcontrol_checksum(const char *pgdata_path)
341
343
size_t size ;
342
344
343
345
/* 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);
345
347
346
348
digestControlFile (& ControlFile , buffer , size );
347
349
pg_free (buffer );
348
350
349
351
return ControlFile .crc ;
350
352
}
351
353
354
+ /* unused function */
352
355
DBState
353
- get_system_dbstate (const char * pgdata_path , fio_location location )
356
+ get_system_dbstate (fio_location location , const char * pgdata_path )
354
357
{
355
358
ControlFileData ControlFile ;
356
359
char * buffer ;
357
360
size_t size ;
358
361
359
- buffer = slurpFile (pgdata_path , XLOG_CONTROL_FILE , & size , false, location );
362
+ buffer = slurpFile (location , pgdata_path , XLOG_CONTROL_FILE , & size , false);
360
363
if (buffer == NULL )
361
364
return 0 ;
362
365
digestControlFile (& ControlFile , buffer , size );
@@ -366,14 +369,14 @@ get_system_dbstate(const char *pgdata_path, fio_location location)
366
369
}
367
370
368
371
void
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 )
370
373
{
371
374
ControlFileData ControlFile ;
372
375
char * buffer ;
373
376
size_t size ;
374
377
375
378
/* 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);
377
380
378
381
digestControlFile (& ControlFile , buffer , size );
379
382
pg_free (buffer );
@@ -412,7 +415,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
412
415
char fullpath [MAXPGPATH ];
413
416
414
417
/* 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);
416
419
digestControlFile (& ControlFile , buffer , size );
417
420
418
421
elog (LOG , "Current minRecPoint %X/%X" ,
@@ -433,7 +436,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
433
436
434
437
/* overwrite pg_control */
435
438
join_path_components (fullpath , backup_path , XLOG_CONTROL_FILE );
436
- writeControlFile (& ControlFile , fullpath , FIO_LOCAL_HOST );
439
+ writeControlFile (FIO_LOCAL_HOST , fullpath , & ControlFile );
437
440
438
441
/* Update pg_control checksum in backup_list */
439
442
file -> crc = ControlFile .crc ;
@@ -445,14 +448,14 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
445
448
* Copy pg_control file to backup. We do not apply compression to this file.
446
449
*/
447
450
void
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 )
450
453
{
451
454
ControlFileData ControlFile ;
452
455
char * buffer ;
453
456
size_t size ;
454
457
455
- buffer = slurpFile (from_fullpath , "" , & size , false, from_location );
458
+ buffer = slurpFile (from_location , from_fullpath , "" , & size , false);
456
459
457
460
digestControlFile (& ControlFile , buffer , size );
458
461
@@ -461,7 +464,7 @@ copy_pgcontrol_file(const char *from_fullpath, fio_location from_location,
461
464
file -> write_size = size ;
462
465
file -> uncompressed_size = size ;
463
466
464
- writeControlFile (& ControlFile , to_fullpath , to_location );
467
+ writeControlFile (to_location , to_fullpath , & ControlFile );
465
468
466
469
pg_free (buffer );
467
470
}
0 commit comments