50 if (immediately_reserve)
81 elog(
ERROR,
"return type must be a row type");
95 if (immediately_reserve)
125 bool find_startpoint)
187 elog(
ERROR,
"return type must be a row type");
204 memset(nulls, 0,
sizeof(nulls));
242 #define PG_GET_REPLICATION_SLOTS_COLS 19
273 slot_contents = *slot;
277 memset(nulls, 0,
sizeof(nulls));
405 failSeg = targetSeg +
Max(slotKeepSegs, keepSegs) + 1;
470 if (startlsn < moveto)
526 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
527 errmsg(
"invalid target WAL LSN")));
531 elog(
ERROR,
"return type must be a row type");
548 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
549 errmsg(
"replication slot \"%s\" cannot be advanced",
551 errdetail(
"This slot has never previously reserved WAL, or it has been invalidated.")));
566 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
567 errmsg(
"cannot advance replication slot to %X/%X, minimum is %X/%X",
620 elog(
ERROR,
"return type must be a row type");
650 first_slot_contents = *s;
661 (
errcode(ERRCODE_UNDEFINED_OBJECT),
662 errmsg(
"replication slot \"%s\" does not exist",
NameStr(*src_name))));
670 if (src_islogical != logical_slot)
672 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
674 errmsg(
"cannot copy physical replication slot \"%s\" as a logical replication slot",
676 errmsg(
"cannot copy logical replication slot \"%s\" as a physical replication slot",
682 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
683 errmsg(
"cannot copy a replication slot that doesn't reserve WAL")));
740 second_slot_contents = *src;
746 copy_xmin = second_slot_contents.
data.
xmin;
765 if (copy_restart_lsn < src_restart_lsn ||
766 src_islogical != copy_islogical ||
767 strcmp(copy_name,
NameStr(*src_name)) != 0)
769 (
errmsg(
"could not copy replication slot \"%s\"",
771 errdetail(
"The source replication slot was modified incompatibly during the copy operation.")));
776 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
777 errmsg(
"cannot copy unfinished logical replication slot \"%s\"",
779 errhint(
"Retry when the source replication slot's confirmed_flush_lsn is valid.")));
797 #ifdef USE_ASSERT_CHECKING
809 if (logical_slot && !temporary)
877 errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
878 errmsg(
"replication slots can only be synchronized to a standby server"));
900 errcode(ERRCODE_CONNECTION_FAILURE),
901 errmsg(
"synchronization worker \"%s\" could not connect to the primary server: %s",
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define Assert(condition)
#define OidIsValid(objectId)
void load_file(const char *filename, bool restricted)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
Datum Int64GetDatum(int64 X)
#define PG_GETARG_NAME(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
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)
XLogRecPtr LogicalSlotAdvanceAndCheckSnapState(XLogRecPtr moveto, bool *found_consistent_snapshot)
void FreeDecodingContext(LogicalDecodingContext *ctx)
void DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
void CheckLogicalDecodingRequirements(void)
LogicalDecodingContext * CreateInitDecodingContext(const char *plugin, List *output_plugin_options, bool need_full_snapshot, XLogRecPtr restart_lsn, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void pfree(void *pointer)
static Datum LSNGetDatum(XLogRecPtr X)
static const char * plugin
static Datum TransactionIdGetDatum(TransactionId X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum Int32GetDatum(int32 X)
void ReplicationSlotCreate(const char *name, bool db_specific, ReplicationSlotPersistency persistency, bool two_phase, bool failover, bool synced)
void ReplicationSlotMarkDirty(void)
void ReplicationSlotReserveWal(void)
void ReplicationSlotAcquire(const char *name, bool nowait)
void ReplicationSlotsComputeRequiredXmin(bool already_locked)
void ReplicationSlotPersist(void)
ReplicationSlot * MyReplicationSlot
void ReplicationSlotDrop(const char *name, bool nowait)
void ReplicationSlotSave(void)
void CheckSlotPermissions(void)
const char *const SlotInvalidationCauses[]
void ReplicationSlotRelease(void)
int max_replication_slots
ReplicationSlotCtlData * ReplicationSlotCtl
void ReplicationSlotsComputeRequiredLSN(void)
void CheckSlotRequirements(void)
#define SlotIsPhysical(slot)
ReplicationSlotInvalidationCause
#define SlotIsLogical(slot)
Datum pg_get_replication_slots(PG_FUNCTION_ARGS)
Datum pg_copy_physical_replication_slot_a(PG_FUNCTION_ARGS)
static void create_logical_replication_slot(char *name, char *plugin, bool temporary, bool two_phase, bool failover, XLogRecPtr restart_lsn, bool find_startpoint)
Datum pg_create_logical_replication_slot(PG_FUNCTION_ARGS)
#define PG_GET_REPLICATION_SLOTS_COLS
static Datum copy_replication_slot(FunctionCallInfo fcinfo, bool logical_slot)
Datum pg_copy_logical_replication_slot_c(PG_FUNCTION_ARGS)
Datum pg_create_physical_replication_slot(PG_FUNCTION_ARGS)
Datum pg_copy_logical_replication_slot_a(PG_FUNCTION_ARGS)
Datum pg_copy_physical_replication_slot_b(PG_FUNCTION_ARGS)
Datum pg_sync_replication_slots(PG_FUNCTION_ARGS)
Datum pg_copy_logical_replication_slot_b(PG_FUNCTION_ARGS)
static XLogRecPtr pg_logical_replication_slot_advance(XLogRecPtr moveto)
static XLogRecPtr pg_physical_replication_slot_advance(XLogRecPtr moveto)
Datum pg_replication_slot_advance(PG_FUNCTION_ARGS)
static void create_physical_replication_slot(char *name, bool immediately_reserve, bool temporary, XLogRecPtr restart_lsn)
Datum pg_drop_replication_slot(PG_FUNCTION_ARGS)
void SyncReplicationSlots(WalReceiverConn *wrconn)
char * CheckAndGetDbnameFromConninfo(void)
bool ValidateSlotSyncParams(int elevel)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
ReplicationSlot replication_slots[1]
TransactionId catalog_xmin
XLogRecPtr confirmed_flush
ReplicationSlotPersistency persistency
ReplicationSlotInvalidationCause invalidated
TransactionId effective_catalog_xmin
TransactionId effective_xmin
ReplicationSlotPersistentData data
TimestampTz inactive_since
Tuplestorestate * setResult
#define InvalidTransactionId
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
static Datum TimestampTzGetDatum(TimestampTz X)
static WalReceiverConn * wrconn
#define walrcv_connect(conninfo, replication, logical, must_use_password, appname, err)
#define walrcv_disconnect(conn)
void PhysicalWakeupLogicalWalSnd(void)
bool RecoveryInProgress(void)
XLogSegNo XLogGetLastRemovedSegno(void)
WALAvailability GetWALAvailability(XLogRecPtr targetLSN)
int max_slot_wal_keep_size_mb
XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)
XLogRecPtr GetXLogWriteRecPtr(void)
#define XLogSegNoOffsetToRecPtr(segno, offset, wal_segsz_bytes, dest)
#define XLogMBVarToSegs(mbvar, wal_segsz_bytes)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
#define LSN_FORMAT_ARGS(lsn)
#define XLogRecPtrIsInvalid(r)
#define InvalidXLogRecPtr
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
void wal_segment_close(XLogReaderState *state)
void wal_segment_open(XLogReaderState *state, XLogSegNo nextSegNo, TimeLineID *tli_p)
int read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page)