74 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
75 errmsg(
"a backup is already in progress in this session")));
87 "on-line backup context",
131 #define PG_BACKUP_STOP_V2_COLS 3
141 elog(
ERROR,
"return type must be a row type");
145 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
146 errmsg(
"backup is not in progress"),
147 errhint(
"Did you call pg_backup_start()?")));
188 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
189 errmsg(
"recovery is in progress"),
190 errhint(
"WAL control functions cannot be executed during recovery.")));
213 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
214 errmsg(
"recovery is in progress"),
215 errhint(
"%s cannot be executed during recovery.",
216 "pg_log_standby_snapshot()")));
220 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
221 errmsg(
"pg_log_standby_snapshot() can only be used if wal_level >= replica")));
241 char *restore_name_str;
246 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
247 errmsg(
"recovery is in progress"),
248 errhint(
"WAL control functions cannot be executed during recovery.")));
252 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
253 errmsg(
"WAL level not sufficient for creating a restore point"),
254 errhint(
"wal_level must be set to \"replica\" or \"logical\" at server start.")));
260 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
261 errmsg(
"value too long for restore point (maximum %d characters)",
MAXFNAMELEN - 1)));
285 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
286 errmsg(
"recovery is in progress"),
287 errhint(
"WAL control functions cannot be executed during recovery.")));
306 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
307 errmsg(
"recovery is in progress"),
308 errhint(
"WAL control functions cannot be executed during recovery.")));
327 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
328 errmsg(
"recovery is in progress"),
329 errhint(
"WAL control functions cannot be executed during recovery.")));
393 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
394 errmsg(
"recovery is in progress"),
395 errhint(
"%s cannot be executed during recovery.",
396 "pg_walfile_name_offset()")));
451 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
452 errmsg(
"recovery is in progress"),
453 errhint(
"%s cannot be executed during recovery.",
454 "pg_walfile_name()")));
470 #define PG_SPLIT_WALFILE_NAME_COLS 2
486 for (p = fname_upper; *p; p++)
491 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
492 errmsg(
"invalid WAL file name \"%s\"", fname)));
497 elog(
ERROR,
"return type must be a row type");
513 #undef PG_SPLIT_WALFILE_NAME_COLS
527 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
528 errmsg(
"recovery is not in progress"),
529 errhint(
"Recovery control functions can only be executed during recovery.")));
533 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
534 errmsg(
"standby promotion is ongoing"),
535 errhint(
"%s cannot be executed after promotion is triggered.",
536 "pg_wal_replay_pause()")));
557 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
558 errmsg(
"recovery is not in progress"),
559 errhint(
"Recovery control functions can only be executed during recovery.")));
563 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
564 errmsg(
"standby promotion is ongoing"),
565 errhint(
"%s cannot be executed after promotion is triggered.",
566 "pg_wal_replay_resume()")));
581 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
582 errmsg(
"recovery is not in progress"),
583 errhint(
"Recovery control functions can only be executed during recovery.")));
600 char *statestr = NULL;
604 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
605 errmsg(
"recovery is not in progress"),
606 errhint(
"Recovery control functions can only be executed during recovery.")));
612 statestr =
"not paused";
615 statestr =
"pause requested";
684 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
685 errmsg(
"recovery is not in progress"),
686 errhint(
"Recovery control functions can only be executed during recovery.")));
690 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
691 errmsg(
"\"wait_seconds\" must not be negative or zero")));
698 errmsg(
"could not create file \"%s\": %m",
704 errmsg(
"could not write file \"%s\": %m",
712 (
errcode(ERRCODE_SYSTEM_ERROR),
713 errmsg(
"failed to send signal to postmaster: %m")));
721 #define WAITS_PER_SECOND 10
744 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
745 errmsg(
"terminating connection due to unexpected postmaster exit"),
751 "server did not promote within %d seconds",
Datum numeric_in(PG_FUNCTION_ARGS)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
elog(ERROR, "%s: %s", p2, msg)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errcode_for_file_access(void)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
FILE * AllocateFile(const char *name, const char *mode)
Datum Int64GetDatum(int64 X)
#define PG_GETARG_TEXT_PP(n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_TEXT_P(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
#define PG_RETURN_BOOL(x)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_POSTMASTER_DEATH
Assert(fmt[strlen(fmt) - 1] !='\n')
void MemoryContextReset(MemoryContext context)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * palloc0(Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_START_SMALL_SIZES
#define CHECK_FOR_INTERRUPTS()
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static char promote_file[MAXPGPATH]
Datum pg_lsn_mi(PG_FUNCTION_ARGS)
static Datum LSNGetDatum(XLogRecPtr X)
unsigned char pg_toupper(unsigned char ch)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static Datum UInt32GetDatum(uint32 X)
XLogRecPtr LogStandbySnapshot(void)
StringInfo makeStringInfo(void)
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
#define PG_RETURN_TIMESTAMPTZ(x)
char * text_to_cstring(const text *t)
text * cstring_to_text(const char *s)
XLogRecPtr GetWalRcvFlushRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)
bool RecoveryInProgress(void)
TimeLineID GetWALInsertionTimeLine(void)
XLogRecPtr RequestXLogSwitch(bool mark_unimportant)
SessionBackupState get_backup_status(void)
XLogRecPtr GetXLogInsertRecPtr(void)
XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)
void register_persistent_abort_backup_handler(void)
XLogRecPtr GetXLogWriteRecPtr(void)
void do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces, BackupState *state, StringInfo tblspcmapfile)
XLogRecPtr XLogRestorePoint(const char *rpName)
void do_pg_backup_stop(BackupState *state, bool waitforarchive)
#define PROMOTE_SIGNAL_FILE
#define XLogStandbyInfoActive()
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
static bool IsXLogFileName(const char *fname)
static void XLogFromFileName(const char *fname, TimeLineID *tli, XLogSegNo *logSegNo, int wal_segsz_bytes)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
char * build_backup_content(BackupState *state, bool ishistoryfile)
Datum pg_is_wal_replay_paused(PG_FUNCTION_ARGS)
Datum pg_wal_lsn_diff(PG_FUNCTION_ARGS)
Datum pg_backup_start(PG_FUNCTION_ARGS)
Datum pg_create_restore_point(PG_FUNCTION_ARGS)
Datum pg_current_wal_insert_lsn(PG_FUNCTION_ARGS)
Datum pg_switch_wal(PG_FUNCTION_ARGS)
Datum pg_is_in_recovery(PG_FUNCTION_ARGS)
#define PG_SPLIT_WALFILE_NAME_COLS
Datum pg_split_walfile_name(PG_FUNCTION_ARGS)
Datum pg_backup_stop(PG_FUNCTION_ARGS)
Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS)
Datum pg_log_standby_snapshot(PG_FUNCTION_ARGS)
static BackupState * backup_state
Datum pg_current_wal_lsn(PG_FUNCTION_ARGS)
Datum pg_last_wal_receive_lsn(PG_FUNCTION_ARGS)
#define PG_BACKUP_STOP_V2_COLS
Datum pg_walfile_name(PG_FUNCTION_ARGS)
Datum pg_current_wal_flush_lsn(PG_FUNCTION_ARGS)
Datum pg_walfile_name_offset(PG_FUNCTION_ARGS)
static MemoryContext backupcontext
static StringInfo tablespace_map
Datum pg_promote(PG_FUNCTION_ARGS)
Datum pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS)
Datum pg_last_wal_replay_lsn(PG_FUNCTION_ARGS)
Datum pg_wal_replay_pause(PG_FUNCTION_ARGS)
Datum pg_wal_replay_resume(PG_FUNCTION_ARGS)
void SetRecoveryPause(bool recoveryPause)
void WakeupRecovery(void)
bool PromoteIsTriggered(void)
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
RecoveryPauseState GetRecoveryPauseState(void)
TimestampTz GetLatestXTime(void)
@ RECOVERY_PAUSE_REQUESTED