PostgreSQL Source Code git master
Loading...
Searching...
No Matches
xlogfuncs.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * xlogfuncs.c
4 *
5 * PostgreSQL write-ahead log manager user interface functions
6 *
7 * This file contains WAL control and information functions.
8 *
9 *
10 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
11 * Portions Copyright (c) 1994, Regents of the University of California
12 *
13 * src/backend/access/transam/xlogfuncs.c
14 *
15 *-------------------------------------------------------------------------
16 */
17#include "postgres.h"
18
19#include <unistd.h>
20
21#include "access/htup_details.h"
23#include "access/xlogbackup.h"
24#include "access/xlogrecovery.h"
25#include "catalog/pg_authid.h"
26#include "catalog/pg_type.h"
27#include "funcapi.h"
28#include "miscadmin.h"
29#include "pgstat.h"
30#include "utils/acl.h"
32#include "storage/fd.h"
33#include "storage/latch.h"
34#include "storage/standby.h"
35#include "utils/builtins.h"
36#include "utils/memutils.h"
37#include "utils/pg_lsn.h"
38#include "utils/timestamp.h"
39#include "utils/wait_event.h"
40
41/*
42 * Backup-related variables.
43 */
46
47/* Session-level context for the SQL-callable backup functions */
49
50
51/*
52 * Return a string constant representing the recovery pause state. This is
53 * used in system functions and views, and should *not* be translated.
54 */
55static const char *
57{
58 const char *statestr = NULL;
59
60 switch (pause_state)
61 {
63 statestr = "not paused";
64 break;
66 statestr = "pause requested";
67 break;
68 case RECOVERY_PAUSED:
69 statestr = "paused";
70 break;
71 }
72
74 return statestr;
75}
76
77/*
78 * pg_backup_start: set up for taking an on-line backup dump
79 *
80 * Essentially what this does is to create the contents required for the
81 * backup_label file and the tablespace map.
82 *
83 * Permission checking for this function is managed through the normal
84 * GRANT system.
85 */
88{
90 bool fast = PG_GETARG_BOOL(1);
91 char *backupidstr;
93 MemoryContext oldcontext;
94
96
97 if (status == SESSION_BACKUP_RUNNING)
100 errmsg("a backup is already in progress in this session")));
101
102 /*
103 * backup_state and tablespace_map need to be long-lived as they are used
104 * in pg_backup_stop(). These are allocated in a dedicated memory context
105 * child of TopMemoryContext, deleted at the end of pg_backup_stop(). If
106 * an error happens before ending the backup, memory would be leaked in
107 * this context until pg_backup_start() is called again.
108 */
109 if (backupcontext == NULL)
110 {
112 "on-line backup context",
114 }
115 else
116 {
120 }
121
125 MemoryContextSwitchTo(oldcontext);
126
129
131}
132
133
134/*
135 * pg_backup_stop: finish taking an on-line backup.
136 *
137 * The first parameter (variable 'waitforarchive'), which is optional,
138 * allows the user to choose if they want to wait for the WAL to be archived
139 * or if we should just return as soon as the WAL record is written.
140 *
141 * This function stops an in-progress backup, creates backup_label contents and
142 * it returns the backup stop LSN, backup_label and tablespace_map contents.
143 *
144 * The backup_label contains the user-supplied label string (typically this
145 * would be used to tell where the backup dump will be stored), the starting
146 * time, starting WAL location for the dump and so on. It is the caller's
147 * responsibility to write the backup_label and tablespace_map files in the
148 * data folder that will be restored from this backup.
149 *
150 * Permission checking for this function is managed through the normal
151 * GRANT system.
152 */
153Datum
155{
156#define PG_BACKUP_STOP_V2_COLS 3
157 TupleDesc tupdesc;
159 bool nulls[PG_BACKUP_STOP_V2_COLS] = {0};
161 char *backup_label;
163
164 /* Initialize attributes information in the tuple descriptor */
165 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
166 elog(ERROR, "return type must be a row type");
167
168 if (status != SESSION_BACKUP_RUNNING)
171 errmsg("backup is not in progress"),
172 errhint("Did you call pg_backup_start()?")));
173
176
177 /* Stop the backup */
179
180 /* Build the contents of backup_label */
182
186
187 /* Deallocate backup-related variables */
189
190 /* Clean up the session-level state and its memory context */
195
196 /* Returns the record as Datum */
198}
199
200/*
201 * pg_switch_wal: switch to next xlog file
202 *
203 * Permission checking for this function is managed through the normal
204 * GRANT system.
205 */
206Datum
208{
210
211 if (RecoveryInProgress())
214 errmsg("recovery is in progress"),
215 errhint("WAL control functions cannot be executed during recovery.")));
216
218
219 /*
220 * As a convenience, return the WAL location of the switch record
221 */
223}
224
225/*
226 * pg_log_standby_snapshot: call LogStandbySnapshot()
227 *
228 * Permission checking for this function is managed through the normal
229 * GRANT system.
230 */
231Datum
233{
235
236 if (RecoveryInProgress())
239 errmsg("recovery is in progress"),
240 errhint("%s cannot be executed during recovery.",
241 "pg_log_standby_snapshot()")));
242
246 errmsg("pg_log_standby_snapshot() can only be used if \"wal_level\" >= \"replica\"")));
247
249
250 /*
251 * As a convenience, return the WAL location of the last inserted record
252 */
254}
255
256/*
257 * pg_create_restore_point: a named point for restore
258 *
259 * Permission checking for this function is managed through the normal
260 * GRANT system.
261 */
262Datum
264{
266 char *restore_name_str;
268
269 if (RecoveryInProgress())
272 errmsg("recovery is in progress"),
273 errhint("WAL control functions cannot be executed during recovery.")));
274
275 if (!XLogIsNeeded())
278 errmsg("WAL level not sufficient for creating a restore point"),
279 errhint("\"wal_level\" must be set to \"replica\" or \"logical\" at server start.")));
280
282
286 errmsg("value too long for restore point (maximum %d characters)", MAXFNAMELEN - 1)));
287
289
290 /*
291 * As a convenience, return the WAL location of the restore point record
292 */
294}
295
296/*
297 * Report the current WAL write location (same format as pg_backup_start etc)
298 *
299 * This is useful for determining how much of WAL is visible to an external
300 * archiving process. Note that the data before this point is written out
301 * to the kernel, but is not necessarily synced to disk.
302 */
303Datum
305{
307
308 if (RecoveryInProgress())
311 errmsg("recovery is in progress"),
312 errhint("WAL control functions cannot be executed during recovery.")));
313
315
317}
318
319/*
320 * Report the current WAL insert location (same format as pg_backup_start etc)
321 *
322 * This function is mostly for debugging purposes.
323 */
324Datum
326{
328
329 if (RecoveryInProgress())
332 errmsg("recovery is in progress"),
333 errhint("WAL control functions cannot be executed during recovery.")));
334
336
338}
339
340/*
341 * Report the current WAL flush location (same format as pg_backup_start etc)
342 *
343 * This function is mostly for debugging purposes.
344 */
345Datum
347{
349
350 if (RecoveryInProgress())
353 errmsg("recovery is in progress"),
354 errhint("WAL control functions cannot be executed during recovery.")));
355
357
359}
360
361/*
362 * Report the last WAL receive location (same format as pg_backup_start etc)
363 *
364 * This is useful for determining how much of WAL is guaranteed to be received
365 * and synced to disk by walreceiver.
366 */
367Datum
379
380/*
381 * Report the last WAL replay location (same format as pg_backup_start etc)
382 *
383 * This is useful for determining how much of WAL is visible to read-only
384 * connections during recovery.
385 */
386Datum
398
399/*
400 * Compute an xlog file name and decimal byte offset given a WAL location,
401 * such as is returned by pg_backup_stop() or pg_switch_wal().
402 */
403Datum
405{
410 Datum values[2];
411 bool isnull[2];
414 Datum result;
415
416 if (RecoveryInProgress())
419 errmsg("recovery is in progress"),
420 errhint("%s cannot be executed during recovery.",
421 "pg_walfile_name_offset()")));
422
423 /*
424 * Construct a tuple descriptor for the result row. This must match this
425 * function's pg_proc entry!
426 */
429 TEXTOID, -1, 0);
431 INT4OID, -1, 0);
432
435
436 /*
437 * xlogfilename
438 */
442
444 isnull[0] = false;
445
446 /*
447 * offset
448 */
450
452 isnull[1] = false;
453
454 /*
455 * Tuple jam: Having first prepared your Datums, then squash together
456 */
458
460
461 PG_RETURN_DATUM(result);
462}
463
464/*
465 * Compute an xlog file name given a WAL location,
466 * such as is returned by pg_backup_stop() or pg_switch_wal().
467 */
468Datum
488
489/*
490 * Extract the sequence number and the timeline ID from given a WAL file
491 * name.
492 */
493Datum
495{
496#define PG_SPLIT_WALFILE_NAME_COLS 2
497 char *fname = text_to_cstring(PG_GETARG_TEXT_PP(0));
498 char *fname_upper;
499 char *p;
500 TimeLineID tli;
501 XLogSegNo segno;
503 bool isnull[PG_SPLIT_WALFILE_NAME_COLS] = {0};
504 TupleDesc tupdesc;
505 HeapTuple tuple;
506 char buf[256];
507 Datum result;
508
509 fname_upper = pstrdup(fname);
510
511 /* Capitalize WAL file name. */
512 for (p = fname_upper; *p; p++)
513 *p = pg_ascii_toupper((unsigned char) *p);
514
518 errmsg("invalid WAL file name \"%s\"", fname)));
519
521
522 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
523 elog(ERROR, "return type must be a row type");
524
525 /* Convert to numeric. */
526 snprintf(buf, sizeof buf, UINT64_FORMAT, segno);
530 Int32GetDatum(-1));
531
532 values[1] = Int64GetDatum(tli);
533
534 tuple = heap_form_tuple(tupdesc, values, isnull);
535 result = HeapTupleGetDatum(tuple);
536
537 PG_RETURN_DATUM(result);
538
539#undef PG_SPLIT_WALFILE_NAME_COLS
540}
541
542/*
543 * pg_wal_replay_pause - Request to pause recovery
544 *
545 * Permission checking for this function is managed through the normal
546 * GRANT system.
547 */
548Datum
550{
551 if (!RecoveryInProgress())
554 errmsg("recovery is not in progress"),
555 errhint("Recovery control functions can only be executed during recovery.")));
556
557 if (PromoteIsTriggered())
560 errmsg("standby promotion is ongoing"),
561 errhint("%s cannot be executed after promotion is triggered.",
562 "pg_wal_replay_pause()")));
563
564 SetRecoveryPause(true);
565
566 /* wake up the recovery process so that it can process the pause request */
568
570}
571
572/*
573 * pg_wal_replay_resume - resume recovery now
574 *
575 * Permission checking for this function is managed through the normal
576 * GRANT system.
577 */
578Datum
580{
581 if (!RecoveryInProgress())
584 errmsg("recovery is not in progress"),
585 errhint("Recovery control functions can only be executed during recovery.")));
586
587 if (PromoteIsTriggered())
590 errmsg("standby promotion is ongoing"),
591 errhint("%s cannot be executed after promotion is triggered.",
592 "pg_wal_replay_resume()")));
593
594 SetRecoveryPause(false);
595
597}
598
599/*
600 * pg_is_wal_replay_paused
601 */
602Datum
604{
605 if (!RecoveryInProgress())
608 errmsg("recovery is not in progress"),
609 errhint("Recovery control functions can only be executed during recovery.")));
610
612}
613
614/*
615 * pg_get_wal_replay_pause_state - Returns the recovery pause state.
616 *
617 * Returned values:
618 *
619 * 'not paused' - if pause is not requested
620 * 'pause requested' - if pause is requested but recovery is not yet paused
621 * 'paused' - if recovery is paused
622 */
623Datum
625{
627
628 if (!RecoveryInProgress())
631 errmsg("recovery is not in progress"),
632 errhint("Recovery control functions can only be executed during recovery.")));
633
635
636 /* get the recovery pause state */
638}
639
640/*
641 * Returns timestamp of latest processed commit/abort record.
642 *
643 * When the server has been started normally without recovery the function
644 * returns NULL.
645 */
646Datum
657
658/*
659 * Returns bool with current recovery mode, a global state.
660 */
661Datum
666
667/*
668 * Compute the difference in bytes between two WAL locations.
669 */
670Datum
672{
673 Datum result;
674
677 PG_GETARG_DATUM(1));
678
679 PG_RETURN_DATUM(result);
680}
681
682/*
683 * Promotes a standby server.
684 *
685 * A result of "true" means that promotion has been completed if "wait" is
686 * "true", or initiated if "wait" is false.
687 */
688Datum
690{
691 bool wait = PG_GETARG_BOOL(0);
694 int i;
695
696 if (!RecoveryInProgress())
699 errmsg("recovery is not in progress"),
700 errhint("Recovery control functions can only be executed during recovery.")));
701
702 if (wait_seconds <= 0)
705 errmsg("\"wait_seconds\" must not be negative or zero")));
706
707 /* create the promote signal file */
709 if (!promote_file)
712 errmsg("could not create file \"%s\": %m",
714
718 errmsg("could not write file \"%s\": %m",
720
721 /* signal the postmaster */
722 if (kill(PostmasterPid, SIGUSR1) != 0)
723 {
727 errmsg("failed to send signal to postmaster: %m")));
728 }
729
730 /* return immediately if waiting was not requested */
731 if (!wait)
732 PG_RETURN_BOOL(true);
733
734 /* wait for the amount of time wanted until promotion */
735#define WAITS_PER_SECOND 10
736 for (i = 0; i < WAITS_PER_SECOND * wait_seconds; i++)
737 {
738 int rc;
739
741
742 if (!RecoveryInProgress())
743 PG_RETURN_BOOL(true);
744
746
747 rc = WaitLatch(MyLatch,
749 1000L / WAITS_PER_SECOND,
751
752 /*
753 * Emergency bailout if postmaster has died. This is to avoid the
754 * necessity for manual cleanup of all postmaster children.
755 */
756 if (rc & WL_POSTMASTER_DEATH)
759 errmsg("terminating connection due to unexpected postmaster exit"),
760 errcontext("while waiting on promotion")));
761 }
762
764 (errmsg_plural("server did not promote within %d second",
765 "server did not promote within %d seconds",
767 wait_seconds)));
768 PG_RETURN_BOOL(false);
769}
770
771/*
772 * pg_stat_get_recovery - returns information about WAL recovery state
773 *
774 * Returns NULL when not in recovery or when the caller lacks
775 * pg_read_all_stats privileges; one row otherwise.
776 */
777Datum
779{
780 TupleDesc tupdesc;
781 Datum *values;
782 bool *nulls;
783
784 /* Local copies of shared state */
794
795 if (!RecoveryInProgress())
797
800
801 /* Take a lock to ensure value consistency */
813
814 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
815 elog(ERROR, "return type must be a row type");
816
817 values = palloc0_array(Datum, tupdesc->natts);
818 nulls = palloc0_array(bool, tupdesc->natts);
819
821
824 else
825 nulls[1] = true;
826
829 else
830 nulls[2] = true;
831
834 else
835 nulls[3] = true;
836
839 else
840 nulls[4] = true;
841
844 else
845 nulls[5] = true;
846
849 else
850 nulls[6] = true;
851
854 else
855 nulls[7] = true;
856
858
860}
bool has_privs_of_role(Oid member, Oid role)
Definition acl.c:5314
int16 AttrNumber
Definition attnum.h:21
Datum numeric_in(PG_FUNCTION_ARGS)
Definition numeric.c:626
static Datum values[MAXATTR]
Definition bootstrap.c:188
#define CStringGetTextDatum(s)
Definition builtins.h:98
#define Assert(condition)
Definition c.h:945
#define UINT64_FORMAT
Definition c.h:637
uint32_t uint32
Definition c.h:618
int64 TimestampTz
Definition timestamp.h:39
int errcode_for_file_access(void)
Definition elog.c:897
int errcode(int sqlerrcode)
Definition elog.c:874
#define errcontext
Definition elog.h:198
int errhint(const char *fmt,...) pg_attribute_printf(1
#define FATAL
Definition elog.h:41
#define WARNING
Definition elog.h:36
int int int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
#define ereport(elevel,...)
Definition elog.h:150
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
int FreeFile(FILE *file)
Definition fd.c:2827
FILE * AllocateFile(const char *name, const char *mode)
Definition fd.c:2628
#define palloc0_array(type, count)
Definition fe_memutils.h:77
#define palloc0_object(type)
Definition fe_memutils.h:75
#define PG_RETURN_VOID()
Definition fmgr.h:350
#define PG_GETARG_TEXT_PP(n)
Definition fmgr.h:310
#define DirectFunctionCall2(func, arg1, arg2)
Definition fmgr.h:686
#define PG_GETARG_DATUM(n)
Definition fmgr.h:268
#define PG_RETURN_NULL()
Definition fmgr.h:346
#define PG_RETURN_TEXT_P(x)
Definition fmgr.h:374
#define PG_GETARG_INT32(n)
Definition fmgr.h:269
#define PG_GETARG_BOOL(n)
Definition fmgr.h:274
#define PG_RETURN_DATUM(x)
Definition fmgr.h:354
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition fmgr.h:688
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition funcapi.c:276
@ TYPEFUNC_COMPOSITE
Definition funcapi.h:149
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition funcapi.h:230
pid_t PostmasterPid
Definition globals.c:106
struct Latch * MyLatch
Definition globals.c:63
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1037
int i
Definition isn.c:77
void ResetLatch(Latch *latch)
Definition latch.c:374
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition latch.c:172
void MemoryContextReset(MemoryContext context)
Definition mcxt.c:403
char * pstrdup(const char *in)
Definition mcxt.c:1781
void pfree(void *pointer)
Definition mcxt.c:1616
MemoryContext TopMemoryContext
Definition mcxt.c:166
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_START_SMALL_SIZES
Definition memutils.h:177
#define CHECK_FOR_INTERRUPTS()
Definition miscadmin.h:123
Oid GetUserId(void)
Definition miscinit.c:470
static char * errmsg
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
static char promote_file[MAXPGPATH]
Definition pg_ctl.c:101
static int wait_seconds
Definition pg_ctl.c:77
Datum pg_lsn_mi(PG_FUNCTION_ARGS)
Definition pg_lsn.c:219
#define PG_GETARG_LSN(n)
Definition pg_lsn.h:36
static Datum LSNGetDatum(XLogRecPtr X)
Definition pg_lsn.h:31
#define PG_RETURN_LSN(x)
Definition pg_lsn.h:37
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define snprintf
Definition port.h:260
static unsigned char pg_ascii_toupper(unsigned char ch)
Definition port.h:177
static Datum Int64GetDatum(int64 X)
Definition postgres.h:413
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
uint64_t Datum
Definition postgres.h:70
static Datum CStringGetDatum(const char *X)
Definition postgres.h:370
static Datum Int32GetDatum(int32 X)
Definition postgres.h:212
static Datum UInt32GetDatum(uint32 X)
Definition postgres.h:232
static int fb(int x)
static void SpinLockRelease(volatile slock_t *lock)
Definition spin.h:62
static void SpinLockAcquire(volatile slock_t *lock)
Definition spin.h:56
XLogRecPtr LogStandbySnapshot(void)
Definition standby.c:1283
StringInfo makeStringInfo(void)
Definition stringinfo.c:72
XLogRecPtr startpoint
Definition xlogbackup.h:26
XLogRecPtr stoppoint
Definition xlogbackup.h:35
XLogRecPtr lastReplayedEndRecPtr
TimeLineID replayEndTLI
TimeLineID lastReplayedTLI
TimestampTz currentChunkStartTime
XLogRecPtr replayEndRecPtr
TimestampTz recoveryLastXTime
RecoveryPauseState recoveryPauseState
XLogRecPtr lastReplayedReadRecPtr
Definition c.h:778
TupleDesc CreateTemplateTupleDesc(int natts)
Definition tupdesc.c:165
void TupleDescFinalize(TupleDesc tupdesc)
Definition tupdesc.c:508
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition tupdesc.c:897
static Datum TimestampTzGetDatum(TimestampTz X)
Definition timestamp.h:52
#define PG_RETURN_TIMESTAMPTZ(x)
Definition timestamp.h:68
text * cstring_to_text(const char *s)
Definition varlena.c:184
char * text_to_cstring(const text *t)
Definition varlena.c:217
#define WL_TIMEOUT
#define WL_LATCH_SET
#define WL_POSTMASTER_DEATH
XLogRecPtr GetWalRcvFlushRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)
#define kill(pid, sig)
Definition win32_port.h:490
#define SIGUSR1
Definition win32_port.h:170
bool RecoveryInProgress(void)
Definition xlog.c:6444
TimeLineID GetWALInsertionTimeLine(void)
Definition xlog.c:6630
XLogRecPtr RequestXLogSwitch(bool mark_unimportant)
Definition xlog.c:8189
SessionBackupState get_backup_status(void)
Definition xlog.c:9280
int wal_segment_size
Definition xlog.c:147
XLogRecPtr GetXLogInsertRecPtr(void)
Definition xlog.c:9614
XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)
Definition xlog.c:6609
void register_persistent_abort_backup_handler(void)
Definition xlog.c:9600
XLogRecPtr GetXLogWriteRecPtr(void)
Definition xlog.c:9646
void do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces, BackupState *state, StringInfo tblspcmapfile)
Definition xlog.c:8977
XLogRecPtr XLogRestorePoint(const char *rpName)
Definition xlog.c:8207
void do_pg_backup_stop(BackupState *state, bool waitforarchive)
Definition xlog.c:9299
#define PROMOTE_SIGNAL_FILE
Definition xlog.h:328
SessionBackupState
Definition xlog.h:305
@ SESSION_BACKUP_RUNNING
Definition xlog.h:307
#define XLogIsNeeded()
Definition xlog.h:111
#define XLogStandbyInfoActive()
Definition xlog.h:125
#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 MAXFNAMELEN
#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)
Definition xlogbackup.c:29
#define XLogRecPtrIsValid(r)
Definition xlogdefs.h:29
uint64 XLogRecPtr
Definition xlogdefs.h:21
uint32 TimeLineID
Definition xlogdefs.h:63
uint64 XLogSegNo
Definition xlogdefs.h:52
Datum pg_is_wal_replay_paused(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:603
Datum pg_wal_lsn_diff(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:671
Datum pg_stat_get_recovery(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:778
Datum pg_backup_start(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:87
Datum pg_create_restore_point(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:263
Datum pg_current_wal_insert_lsn(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:325
Datum pg_switch_wal(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:207
Datum pg_is_in_recovery(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:662
#define PG_SPLIT_WALFILE_NAME_COLS
Datum pg_split_walfile_name(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:494
Datum pg_backup_stop(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:154
#define WAITS_PER_SECOND
Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:647
Datum pg_log_standby_snapshot(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:232
static const char * GetRecoveryPauseStateString(RecoveryPauseState pause_state)
Definition xlogfuncs.c:56
static BackupState * backup_state
Definition xlogfuncs.c:44
Datum pg_current_wal_lsn(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:304
Datum pg_last_wal_receive_lsn(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:368
#define PG_BACKUP_STOP_V2_COLS
Datum pg_walfile_name(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:469
Datum pg_current_wal_flush_lsn(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:346
Datum pg_walfile_name_offset(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:404
static MemoryContext backupcontext
Definition xlogfuncs.c:48
static StringInfo tablespace_map
Definition xlogfuncs.c:45
Datum pg_promote(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:689
Datum pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:624
Datum pg_last_wal_replay_lsn(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:387
Datum pg_wal_replay_pause(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:549
Datum pg_wal_replay_resume(PG_FUNCTION_ARGS)
Definition xlogfuncs.c:579
void SetRecoveryPause(bool recoveryPause)
void WakeupRecovery(void)
bool PromoteIsTriggered(void)
XLogRecoveryCtlData * XLogRecoveryCtl
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
RecoveryPauseState GetRecoveryPauseState(void)
TimestampTz GetLatestXTime(void)
RecoveryPauseState
@ RECOVERY_PAUSED
@ RECOVERY_NOT_PAUSED
@ RECOVERY_PAUSE_REQUESTED