53 static bool compare_files(
const char *file1,
const char *file2);
154 sigjmp_buf local_sigjmp_buf;
172 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
227 (
errmsg(
"archiving \"%s\" via basic_archive", file)));
241 if (
stat(destination, &st) == 0)
246 (
errmsg(
"archive file \"%s\" already exists with identical contents",
256 (
errmsg(
"archive file \"%s\" already exists", destination)));
258 else if (errno != ENOENT)
261 errmsg(
"could not stat file \"%s\": %m", destination)));
272 elog(
ERROR,
"could not generate temporary file name for archiving");
290 (
errmsg(
"archived \"%s\" via basic_archive", file)));
301 #define CMP_BUF_SIZE (4096)
312 errmsg(
"could not open file \"%s\": %m", file1)));
318 errmsg(
"could not open file \"%s\": %m", file2)));
332 errmsg(
"could not read file \"%s\": %m", file1)));
333 else if (nbytes == 0)
345 errmsg(
"could not read file \"%s\": %m", file2)));
346 else if (nbytes == 0)
352 if (buf1_len != buf2_len || memcmp(buf1, buf2, buf1_len) != 0)
357 else if (buf1_len == 0)
364 errmsg(
"could not close file \"%s\": %m", file1)));
369 errmsg(
"could not close file \"%s\": %m", file2)));
static MemoryContext basic_archive_context
void _PG_archive_module_init(ArchiveModuleCallbacks *cb)
static char * archive_directory
static bool basic_archive_file(const char *file, const char *path)
static bool basic_archive_configured(void)
static void basic_archive_file_internal(const char *file, const char *path)
static bool compare_files(const char *file1, const char *file2)
static bool check_archive_directory(char **newval, void **extra, GucSource source)
#define unconstify(underlying_type, expr)
#define AssertVariableIsOfType(varname, typename)
#define InvalidSubTransactionId
void copy_file(char *fromfile, char *tofile)
void EmitErrorReport(void)
int errcode_for_file_access(void)
ErrorContextCallback * error_context_stack
void FlushErrorState(void)
int errmsg(const char *fmt,...)
sigjmp_buf * PG_exception_stack
#define ereport(elevel,...)
int durable_rename_excl(const char *oldfile, const char *newfile, int elevel)
int CloseTransientFile(int fd)
void fsync_fname(const char *fname, bool isdir)
void AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
int OpenTransientFile(const char *fileName, int fileFlags)
static const unsigned __int64 epoch
int gettimeofday(struct timeval *tp, struct timezone *tzp)
void DefineCustomStringVariable(const char *name, const char *short_desc, const char *long_desc, char **valueAddr, const char *bootValue, GucContext context, int flags, GucStringCheckHook check_hook, GucStringAssignHook assign_hook, GucShowHook show_hook)
void MarkGUCPrefixReserved(const char *className)
#define GUC_check_errdetail
static bool pg_add_u64_overflow(uint64 a, uint64 b, uint64 *result)
static bool pg_mul_u64_overflow(uint64 a, uint64 b, uint64 *result)
void MemoryContextReset(MemoryContext context)
MemoryContext TopMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define RESUME_INTERRUPTS()
#define HOLD_INTERRUPTS()
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static rewind_source * source
void(* ArchiveModuleInit)(ArchiveModuleCallbacks *cb)
ArchiveFileCB archive_file_cb
ArchiveCheckConfiguredCB check_configured_cb