55 static bool compare_files(
const char *file1,
const char *file2);
175 sigjmp_buf local_sigjmp_buf;
195 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
250 (
errmsg(
"archiving \"%s\" via basic_archive", file)));
264 if (
stat(destination, &st) == 0)
269 (
errmsg(
"archive file \"%s\" already exists with identical contents",
279 (
errmsg(
"archive file \"%s\" already exists", destination)));
281 else if (errno != ENOENT)
284 errmsg(
"could not stat file \"%s\": %m", destination)));
295 elog(
ERROR,
"could not generate temporary file name for archiving");
314 (
errmsg(
"archived \"%s\" via basic_archive", file)));
325 #define CMP_BUF_SIZE (4096)
336 errmsg(
"could not open file \"%s\": %m", file1)));
342 errmsg(
"could not open file \"%s\": %m", file2)));
356 errmsg(
"could not read file \"%s\": %m", file1)));
357 else if (nbytes == 0)
369 errmsg(
"could not read file \"%s\": %m", file2)));
370 else if (nbytes == 0)
376 if (buf1_len != buf2_len || memcmp(buf1, buf2, buf1_len) != 0)
381 else if (buf1_len == 0)
388 errmsg(
"could not close file \"%s\": %m", file1)));
393 errmsg(
"could not close file \"%s\": %m", file2)));
416 basic_archive_context =
data->context;
421 data->context = NULL;
427 state->private_data = NULL;
struct BasicArchiveData BasicArchiveData
static void basic_archive_startup(ArchiveModuleState *state)
static char * archive_directory
static bool basic_archive_file(ArchiveModuleState *state, const char *file, const char *path)
const ArchiveModuleCallbacks * _PG_archive_module_init(void)
static void basic_archive_file_internal(const char *file, const char *path)
static const ArchiveModuleCallbacks basic_archive_callbacks
static bool compare_files(const char *file1, const char *file2)
static bool basic_archive_configured(ArchiveModuleState *state)
static bool check_archive_directory(char **newval, void **extra, GucSource source)
static void basic_archive_shutdown(ArchiveModuleState *state)
#define InvalidSubTransactionId
void copy_file(const char *fromfile, const char *tofile)
elog(ERROR, "%s: %s", p2, msg)
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(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)
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)
if(TABLE==NULL||TABLE_index==NULL)
Assert(fmt[strlen(fmt) - 1] !='\n')
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define MemoryContextIsValid(context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define RESUME_INTERRUPTS()
#define HOLD_INTERRUPTS()
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static rewind_source * source
ArchiveStartupCB startup_cb
static const unsigned __int64 epoch
int gettimeofday(struct timeval *tp, void *tzp)