1 /*-------------------------------------------------------------------------
4 * Common WAL archive routines
6 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/common/archive.c
13 *-------------------------------------------------------------------------
19 #include "postgres_fe.h"
22 #include "common/archive.h"
23 #include "common/percentrepl.h"
28 * Builds a restore command to retrieve a file from WAL archives, replacing
29 * the supported aliases with values supplied by the caller as defined by
30 * the GUC parameter restore_command: xlogpath for %p, xlogfname for %f and
31 * lastRestartPointFname for %r.
33 * The result is a palloc'd string for the restore command built. The
34 * caller is responsible for freeing it. If any of the required arguments
35 * is NULL and that the corresponding alias is found in the command given
36 * by the caller, then an error is thrown.
39 BuildRestoreCommand(const char *restoreCommand
,
41 const char *xlogfname
,
42 const char *lastRestartPointFname
)
44 char *nativePath
= NULL
;
49 nativePath
= pstrdup(xlogpath
);
50 make_native_path(nativePath
);
53 result
= replace_percent_placeholders(restoreCommand
, "restore_command", "frp",
54 xlogfname
, lastRestartPointFname
, nativePath
);