47 if (immediately_reserve)
78 elog(
ERROR,
"return type must be a row type");
92 if (immediately_reserve)
121 bool find_startpoint)
181 elog(
ERROR,
"return type must be a row type");
197 memset(nulls, 0,
sizeof(nulls));
235 #define PG_GET_REPLICATION_SLOTS_COLS 15
265 slot_contents = *slot;
269 memset(nulls, 0,
sizeof(nulls));
397 failSeg = targetSeg +
Max(slotKeepSegs, keepSegs) + 1;
441 if (startlsn < moveto)
515 elog(
ERROR,
"could not find record while advancing replication slot: %s",
527 if (moveto <= ctx->reader->EndRecPtr)
601 (
errmsg(
"invalid target WAL LSN")));
605 elog(
ERROR,
"return type must be a row type");
622 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
623 errmsg(
"replication slot \"%s\" cannot be advanced",
625 errdetail(
"This slot has never previously reserved WAL, or it has been invalidated.")));
640 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
641 errmsg(
"cannot advance replication slot to %X/%X, minimum is %X/%X",
694 elog(
ERROR,
"return type must be a row type");
724 first_slot_contents = *s;
735 (
errcode(ERRCODE_UNDEFINED_OBJECT),
736 errmsg(
"replication slot \"%s\" does not exist",
NameStr(*src_name))));
744 if (src_islogical != logical_slot)
746 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
748 errmsg(
"cannot copy physical replication slot \"%s\" as a logical replication slot",
750 errmsg(
"cannot copy logical replication slot \"%s\" as a physical replication slot",
756 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
757 errmsg(
"cannot copy a replication slot that doesn't reserve WAL")));
805 second_slot_contents = *src;
811 copy_xmin = second_slot_contents.
data.
xmin;
830 if (copy_restart_lsn < src_restart_lsn ||
831 src_islogical != copy_islogical ||
832 strcmp(copy_name,
NameStr(*src_name)) != 0)
834 (
errmsg(
"could not copy replication slot \"%s\"",
836 errdetail(
"The source replication slot was modified incompatibly during the copy operation.")));
841 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
842 errmsg(
"cannot copy unfinished logical replication slot \"%s\"",
844 errhint(
"Retry when the source replication slot's confirmed_flush_lsn is valid.")));
862 #ifdef USE_ASSERT_CHECKING
874 if (logical_slot && !temporary)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define OidIsValid(objectId)
elog(ERROR, "%s: %s", p2, msg)
void LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *record)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
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, Datum *values, bool *isnull)
void InvalidateSystemCaches(void)
Assert(fmt[strlen(fmt) - 1] !='\n')
void LogicalConfirmReceivedLocation(XLogRecPtr lsn)
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)
LogicalDecodingContext * CreateDecodingContext(XLogRecPtr start_lsn, List *output_plugin_options, bool fast_forward, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
#define CHECK_FOR_INTERRUPTS()
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)
ResourceOwner CurrentResourceOwner
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)
void ReplicationSlotRelease(void)
int max_replication_slots
ReplicationSlotCtlData * ReplicationSlotCtl
void ReplicationSlotsComputeRequiredLSN(void)
void ReplicationSlotCreate(const char *name, bool db_specific, ReplicationSlotPersistency persistency, bool two_phase)
void CheckSlotRequirements(void)
#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, 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_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)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
ReplicationSlot replication_slots[1]
TransactionId catalog_xmin
XLogRecPtr confirmed_flush
ReplicationSlotPersistency persistency
ReplicationSlotInvalidationCause invalidated
TransactionId effective_catalog_xmin
TransactionId effective_xmin
ReplicationSlotPersistentData data
Tuplestorestate * setResult
#define InvalidTransactionId
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
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
XLogRecord * XLogReadRecord(XLogReaderState *state, char **errormsg)
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
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)