78 const char *prefix,
Size message_size,
const char *message);
95 const char *prefix,
Size message_size,
const char *message);
123 errmsg(
"logical decoding requires a database connection")));
132 errmsg(
"logical decoding on standby requires \"effective_wal_level\" >= \"logical\" on the primary"),
133 errhint(
"Set \"wal_level\" >= \"logical\" or create at least one logical slot when \"wal_level\" = \"replica\".")));
161 "Logical decoding context",
202 errdetail(
"Failed while allocating a WAL reading processor.")));
326 List *output_plugin_options,
352 elog(
ERROR,
"cannot perform logical decoding without an acquired slot");
355 elog(
ERROR,
"cannot initialize logical decoding without a specified plugin");
361 errmsg(
"cannot use physical replication slot for logical decoding")));
366 errmsg(
"replication slot \"%s\" was not created in this database",
373 errmsg(
"cannot create logical replication slot in transaction that has performed writes")));
495 List *output_plugin_options,
511 elog(
ERROR,
"cannot perform logical decoding without an acquired slot");
517 errmsg(
"cannot use physical replication slot for logical decoding")));
527 errmsg(
"replication slot \"%s\" was not created in this database",
538 errmsg(
"cannot use replication slot \"%s\" for logical decoding",
540 errdetail(
"This replication slot is being synchronized from the primary server."),
541 errhint(
"Specify another replication slot."));
566 elog(
LOG,
"%X/%08X has been already streamed, forwarding to %X/%08X",
575 fast_forward,
false,
xl_routine, prepare_write,
607 (
errmsg(
"starting logical decoding for slot \"%s\"",
609 errdetail(
"Streaming transactions committing after %X/%08X, reading WAL from %X/%08X.",
636 elog(
DEBUG1,
"searching for logical decoding starting point, starting at %X/%08X",
648 elog(
ERROR,
"could not find logical decoding starting point: %s",
err);
650 elog(
ERROR,
"could not find logical decoding starting point");
691 elog(
ERROR,
"writes are only accepted in commit, begin and change callbacks");
704 elog(
ERROR,
"OutputPluginPrepareWrite needs to be called before OutputPluginWrite");
737 elog(
ERROR,
"output plugins have to declare the _PG_output_plugin_init symbol");
743 elog(
ERROR,
"output plugins have to register a begin callback");
745 elog(
ERROR,
"output plugins have to register a change callback");
747 elog(
ERROR,
"output plugins have to register a commit callback");
757 errcontext(
"slot \"%s\", output plugin \"%s\", in the %s callback, associated LSN %X/%08X",
760 state->callback_name,
763 errcontext(
"slot \"%s\", output plugin \"%s\", in the %s callback",
766 state->callback_name);
779 state.callback_name =
"startup";
807 state.callback_name =
"shutdown";
841 state.callback_name =
"begin";
873 state.callback_name =
"commit";
914 state.callback_name =
"begin_prepare";
934 errmsg(
"logical replication at prepare time requires a %s callback",
935 "begin_prepare_cb")));
959 state.callback_name =
"prepare";
979 errmsg(
"logical replication at prepare time requires a %s callback",
1004 state.callback_name =
"commit_prepared";
1024 errmsg(
"logical replication at prepare time requires a %s callback",
1025 "commit_prepared_cb")));
1050 state.callback_name =
"rollback_prepared";
1070 errmsg(
"logical replication at prepare time requires a %s callback",
1071 "rollback_prepared_cb")));
1093 state.callback_name =
"change";
1094 state.report_location = change->
lsn;
1135 state.callback_name =
"truncate";
1136 state.report_location = change->
lsn;
1174 state.callback_name =
"filter_prepare";
1205 state.callback_name =
"filter_by_origin";
1228 const char *prefix,
Size message_size,
const char *message)
1241 state.callback_name =
"message";
1256 message_size, message);
1277 state.callback_name =
"stream_start";
1278 state.report_location = first_lsn;
1302 errmsg(
"logical streaming requires a %s callback",
1303 "stream_start_cb")));
1326 state.callback_name =
"stream_stop";
1327 state.report_location = last_lsn;
1351 errmsg(
"logical streaming requires a %s callback",
1352 "stream_stop_cb")));
1375 state.callback_name =
"stream_abort";
1376 state.report_location = abort_lsn;
1392 errmsg(
"logical streaming requires a %s callback",
1393 "stream_abort_cb")));
1420 state.callback_name =
"stream_prepare";
1437 errmsg(
"logical streaming at prepare time requires a %s callback",
1438 "stream_prepare_cb")));
1461 state.callback_name =
"stream_commit";
1478 errmsg(
"logical streaming requires a %s callback",
1479 "stream_commit_cb")));
1502 state.callback_name =
"stream_change";
1503 state.report_location = change->
lsn;
1527 errmsg(
"logical streaming requires a %s callback",
1528 "stream_change_cb")));
1539 const char *prefix,
Size message_size,
const char *message)
1556 state.callback_name =
"stream_message";
1571 message_size, message);
1597 state.callback_name =
"stream_truncate";
1598 state.report_location = change->
lsn;
1636 state.callback_name =
"update_progress_txn";
1637 state.report_location = lsn;
1724 elog(
DEBUG1,
"got new catalog xmin %u at %X/%08X", xmin,
1784 elog(
DEBUG1,
"got new restart lsn %X/%08X at %X/%08X",
1799 elog(
DEBUG1,
"failed to increase restart lsn: proposed %X/%08X, after %X/%08X, current candidate %X/%08X, current after %X/%08X, flushed up to %X/%08X",
1886#ifdef USE_INJECTION_POINTS
1954 if (
rb->spillBytes <= 0 &&
rb->streamBytes <= 0 &&
rb->totalBytes <= 0 &&
1955 rb->memExceededCount <= 0)
1966 rb->memExceededCount,
1986 rb->streamCount = 0;
1987 rb->streamBytes = 0;
1988 rb->memExceededCount = 0;
2045 elog(
ERROR,
"could not find record for logical decoding: %s",
errm);
2153 elog(
ERROR,
"could not find record while advancing replication slot: %s",
#define pg_attribute_unused()
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
void LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *record)
void * load_external_function(const char *filename, const char *funcname, bool signalNotFound, void **filehandle)
ErrorContextCallback * error_context_stack
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
#define palloc0_object(type)
#define INJECTION_POINT(name, arg)
void InvalidateSystemCaches(void)
static void change_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
static void commit_prepared_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
static void update_progress_txn_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr lsn)
XLogRecPtr LogicalSlotAdvanceAndCheckSnapState(XLogRecPtr moveto, bool *found_consistent_snapshot)
void LogicalConfirmReceivedLocation(XLogRecPtr lsn)
void FreeDecodingContext(LogicalDecodingContext *ctx)
XLogRecPtr LogicalReplicationSlotCheckPendingWal(XLogRecPtr end_of_wal, XLogRecPtr scan_cutoff_lsn)
static void stream_start_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr first_lsn)
static void commit_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
static void output_plugin_error_callback(void *arg)
static void begin_prepare_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn)
static void stream_prepare_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
LogicalDecodingContext * CreateDecodingContext(XLogRecPtr start_lsn, List *output_plugin_options, bool fast_forward, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
static void prepare_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr prepare_lsn)
void OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write)
static void stream_truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
static void truncate_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, int nrelations, Relation relations[], ReorderBufferChange *change)
void DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
static void begin_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn)
static void rollback_prepared_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr prepare_end_lsn, TimestampTz prepare_time)
bool DecodingContextReady(LogicalDecodingContext *ctx)
void OutputPluginUpdateProgress(struct LogicalDecodingContext *ctx, bool skipped_xact)
static void startup_cb_wrapper(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is_init)
void UpdateDecodingStats(LogicalDecodingContext *ctx)
void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart_lsn)
static void stream_change_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change)
static void stream_abort_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr abort_lsn)
LogicalDecodingContext * CreateInitDecodingContext(const char *plugin, List *output_plugin_options, bool need_full_snapshot, bool for_repack, XLogRecPtr restart_lsn, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
void CheckLogicalDecodingRequirements(bool repack)
void ResetLogicalStreamingState(void)
void LogicalIncreaseXminForSlot(XLogRecPtr current_lsn, TransactionId xmin)
static LogicalDecodingContext * StartupDecodingContext(List *output_plugin_options, XLogRecPtr start_lsn, TransactionId xmin_horizon, bool need_full_snapshot, bool fast_forward, bool in_create, XLogReaderRoutine *xl_routine, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
static void stream_message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size message_size, const char *message)
static void stream_commit_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr commit_lsn)
bool filter_prepare_cb_wrapper(LogicalDecodingContext *ctx, TransactionId xid, const char *gid)
static void shutdown_cb_wrapper(LogicalDecodingContext *ctx)
bool filter_by_origin_cb_wrapper(LogicalDecodingContext *ctx, ReplOriginId origin_id)
void OutputPluginPrepareWrite(struct LogicalDecodingContext *ctx, bool last_write)
static void LoadOutputPlugin(OutputPluginCallbacks *callbacks, const char *plugin)
static void stream_stop_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr last_lsn)
static void message_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn, XLogRecPtr message_lsn, bool transactional, const char *prefix, Size message_size, const char *message)
void(* LogicalOutputPluginWriterUpdateProgress)(struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid, bool skipped_xact)
#define LogicalDecodingLogLevel()
void(* LogicalOutputPluginWriterWrite)(struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid, bool last_write)
LogicalOutputPluginWriterWrite LogicalOutputPluginWriterPrepareWrite
bool IsLogicalDecodingEnabled(void)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
void namestrcpy(Name name, const char *str)
void(* LogicalOutputPluginInit)(struct OutputPluginCallbacks *cb)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static const char * plugin
void pgstat_report_replslot(ReplicationSlot *slot, const PgStat_StatReplSlotEntry *repSlotStat)
#define PROC_IN_LOGICAL_DECODING
TransactionId GetOldestSafeDecodingTransactionId(bool catalogOnly)
ReorderBuffer * ReorderBufferAllocate(void)
void ReorderBufferFree(ReorderBuffer *rb)
ResourceOwner CurrentResourceOwner
void ReplicationSlotMarkDirty(void)
void ReplicationSlotReserveWal(void)
void ReplicationSlotsComputeRequiredXmin(bool already_locked)
ReplicationSlot * MyReplicationSlot
void ReplicationSlotSave(void)
void WaitForStandbyConfirmation(XLogRecPtr wait_for_lsn)
void ReplicationSlotsComputeRequiredLSN(void)
void CheckSlotRequirements(bool repack)
#define SlotIsPhysical(slot)
bool IsSyncingReplicationSlots(void)
void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr)
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
SnapBuild * AllocateSnapshotBuilder(ReorderBuffer *reorder, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot, bool in_slot_creation, XLogRecPtr two_phase_at)
void FreeSnapshotBuilder(SnapBuild *builder)
static void SpinLockRelease(volatile slock_t *lock)
static void SpinLockAcquire(volatile slock_t *lock)
StringInfo makeStringInfo(void)
struct ErrorContextCallback * previous
void(* callback)(void *arg)
OutputPluginOptions options
struct SnapBuild * snapshot_builder
XLogRecPtr write_location
LogicalOutputPluginWriterPrepareWrite prepare_write
OutputPluginCallbacks callbacks
List * output_plugin_options
LogicalOutputPluginWriterWrite write
struct ReorderBuffer * reorder
LogicalOutputPluginWriterUpdateProgress update_progress
XLogRecPtr report_location
LogicalDecodingContext * ctx
const char * callback_name
LogicalDecodeStreamChangeCB stream_change_cb
LogicalDecodeMessageCB message_cb
LogicalDecodeStreamTruncateCB stream_truncate_cb
LogicalDecodeStreamMessageCB stream_message_cb
LogicalDecodeFilterPrepareCB filter_prepare_cb
LogicalDecodeFilterByOriginCB filter_by_origin_cb
LogicalDecodeTruncateCB truncate_cb
LogicalDecodeStreamStopCB stream_stop_cb
LogicalDecodeStreamCommitCB stream_commit_cb
LogicalDecodeRollbackPreparedCB rollback_prepared_cb
LogicalDecodeStreamPrepareCB stream_prepare_cb
LogicalDecodeCommitPreparedCB commit_prepared_cb
LogicalDecodeStreamStartCB stream_start_cb
LogicalDecodePrepareCB prepare_cb
LogicalDecodeStartupCB startup_cb
LogicalDecodeCommitCB commit_cb
LogicalDecodeBeginCB begin_cb
LogicalDecodeStreamAbortCB stream_abort_cb
LogicalDecodeBeginPrepareCB begin_prepare_cb
LogicalDecodeChangeCB change_cb
LogicalDecodeShutdownCB shutdown_cb
bool need_shared_catalogs
ReorderBufferStreamMessageCB stream_message
ReorderBufferStreamChangeCB stream_change
ReorderBufferBeginCB begin_prepare
ReorderBufferStreamTruncateCB stream_truncate
ReorderBufferCommitPreparedCB commit_prepared
ReorderBufferUpdateProgressTxnCB update_progress_txn
ReorderBufferMessageCB message
ReorderBufferRollbackPreparedCB rollback_prepared
ReorderBufferPrepareCB prepare
ReorderBufferStreamStopCB stream_stop
ReorderBufferApplyChangeCB apply_change
ReorderBufferStreamPrepareCB stream_prepare
ReorderBufferStreamAbortCB stream_abort
ReorderBufferCommitCB commit
ReorderBufferStreamStartCB stream_start
ReorderBufferStreamCommitCB stream_commit
ReorderBufferApplyTruncateCB apply_truncate
ReorderBufferBeginCB begin
TransactionId catalog_xmin
XLogRecPtr confirmed_flush
ReplicationSlotInvalidationCause invalidated
XLogRecPtr candidate_xmin_lsn
TransactionId effective_catalog_xmin
XLogRecPtr candidate_restart_valid
TransactionId effective_xmin
XLogRecPtr candidate_restart_lsn
TransactionId candidate_catalog_xmin
ReplicationSlotPersistentData data
#define InvalidTransactionId
static bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
#define TransactionIdIsValid(xid)
bool IsTransactionOrTransactionBlock(void)
TransactionId CheckXidAlive
bool IsTransactionState(void)
TransactionId GetTopTransactionIdIfAny(void)
bool RecoveryInProgress(void)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
#define XLogRecPtrIsValid(r)
#define LSN_FORMAT_ARGS(lsn)
#define InvalidXLogRecPtr
XLogReaderState * XLogReaderAllocate(int wal_segment_size, const char *waldir, XLogReaderRoutine *routine, void *private_data)
XLogRecord * XLogReadRecord(XLogReaderState *state, char **errormsg)
void XLogReaderFree(XLogReaderState *state)
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
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)