PostgreSQL Source Code
git master
|
#include "access/xlog.h"
#include "access/xlogreader.h"
#include "replication/output_plugin.h"
#include "replication/slot.h"
Go to the source code of this file.
Data Structures | |
struct | LogicalDecodingContext |
Typedefs | |
typedef void(* | LogicalOutputPluginWriterWrite) (struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid, bool last_write) |
typedef LogicalOutputPluginWriterWrite | LogicalOutputPluginWriterPrepareWrite |
typedef void(* | LogicalOutputPluginWriterUpdateProgress) (struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid) |
typedef struct LogicalDecodingContext | LogicalDecodingContext |
typedef struct LogicalDecodingContext LogicalDecodingContext |
typedef void(* LogicalOutputPluginWriterUpdateProgress) (struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid) |
typedef void(* LogicalOutputPluginWriterWrite) (struct LogicalDecodingContext *lr, XLogRecPtr Ptr, TransactionId xid, bool last_write) |
void CheckLogicalDecodingRequirements | ( | void | ) |
Definition at line 103 of file logical.c.
References CheckSlotRequirements(), ereport, errcode(), errmsg(), ERROR, InvalidOid, MyDatabaseId, RecoveryInProgress(), wal_level, and WAL_LEVEL_LOGICAL.
Referenced by copy_replication_slot(), CreateReplicationSlot(), pg_create_logical_replication_slot(), pg_logical_slot_get_changes_guts(), and StartLogicalReplication().
LogicalDecodingContext* CreateDecodingContext | ( | XLogRecPtr | start_lsn, |
List * | output_plugin_options, | ||
bool | fast_forward, | ||
XLogReaderRoutine * | xl_routine, | ||
LogicalOutputPluginWriterPrepareWrite | prepare_write, | ||
LogicalOutputPluginWriterWrite | do_write, | ||
LogicalOutputPluginWriterUpdateProgress | update_progress | ||
) |
Definition at line 476 of file logical.c.
References LogicalDecodingContext::callbacks, ReplicationSlotPersistentData::confirmed_flush, LogicalDecodingContext::context, LogicalErrorCallbackState::ctx, ReplicationSlot::data, ReplicationSlotPersistentData::database, DEBUG1, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, InvalidTransactionId, InvalidXLogRecPtr, LOG, LSN_FORMAT_ARGS, MemoryContextSwitchTo(), MyDatabaseId, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, LogicalDecodingContext::options, ReorderBuffer::output_rewrites, OutputPluginOptions::receive_rewrites, LogicalDecodingContext::reorder, ReplicationSlotPersistentData::restart_lsn, SlotIsPhysical, OutputPluginCallbacks::startup_cb, startup_cb_wrapper(), StartupDecodingContext(), ReplicationSlotPersistentData::two_phase, and LogicalDecodingContext::twophase.
Referenced by pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), and StartLogicalReplication().
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 | ||
) |
Definition at line 318 of file logical.c.
References LogicalDecodingContext::callbacks, ReplicationSlotPersistentData::catalog_xmin, LogicalDecodingContext::context, LogicalErrorCallbackState::ctx, ReplicationSlot::data, ReplicationSlotPersistentData::database, ReplicationSlot::effective_catalog_xmin, ReplicationSlot::effective_xmin, elog, ereport, errcode(), errmsg(), ERROR, GetOldestSafeDecodingTransactionId(), GetTopTransactionIdIfAny(), InvalidTransactionId, IsTransactionState(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MemoryContextSwitchTo(), ReplicationSlot::mutex, MyDatabaseId, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, namestrcpy(), NIL, LogicalDecodingContext::options, ReorderBuffer::output_rewrites, ReplicationSlotPersistentData::plugin, OutputPluginOptions::receive_rewrites, LogicalDecodingContext::reorder, ReplicationSlotMarkDirty(), ReplicationSlotReserveWal(), ReplicationSlotSave(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotPersistentData::restart_lsn, SlotIsPhysical, SpinLockAcquire, SpinLockRelease, OutputPluginCallbacks::startup_cb, startup_cb_wrapper(), StartupDecodingContext(), ReplicationSlotPersistentData::two_phase, LogicalDecodingContext::twophase, and XLogRecPtrIsInvalid.
Referenced by create_logical_replication_slot(), and CreateReplicationSlot().
void DecodingContextFindStartpoint | ( | LogicalDecodingContext * | ctx | ) |
Definition at line 571 of file logical.c.
References CHECK_FOR_INTERRUPTS, ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, DEBUG1, DecodingContextReady(), elog, XLogReaderState::EndRecPtr, ERROR, ReplicationSlotPersistentData::initial_consistent_point, LogicalDecodingProcessRecord(), LSN_FORMAT_ARGS, ReplicationSlot::mutex, LogicalDecodingContext::reader, ReplicationSlotPersistentData::restart_lsn, LogicalDecodingContext::slot, SpinLockAcquire, SpinLockRelease, XLogBeginRead(), and XLogReadRecord().
Referenced by create_logical_replication_slot(), and CreateReplicationSlot().
bool DecodingContextReady | ( | LogicalDecodingContext * | ctx | ) |
Definition at line 562 of file logical.c.
References SNAPBUILD_CONSISTENT, SnapBuildCurrentState(), and LogicalDecodingContext::snapshot_builder.
Referenced by DecodingContextFindStartpoint().
bool filter_by_origin_cb_wrapper | ( | LogicalDecodingContext * | ctx, |
RepOriginId | origin_id | ||
) |
Definition at line 1116 of file logical.c.
References LogicalDecodingContext::accept_writes, ErrorContextCallback::arg, Assert, ErrorContextCallback::callback, LogicalErrorCallbackState::callback_name, LogicalDecodingContext::callbacks, LogicalErrorCallbackState::ctx, error_context_stack, LogicalDecodingContext::fast_forward, OutputPluginCallbacks::filter_by_origin_cb, InvalidXLogRecPtr, output_plugin_error_callback(), ErrorContextCallback::previous, and LogicalErrorCallbackState::report_location.
Referenced by FilterByOrigin().
bool filter_prepare_cb_wrapper | ( | LogicalDecodingContext * | ctx, |
const char * | gid | ||
) |
Definition at line 1086 of file logical.c.
References LogicalDecodingContext::accept_writes, ErrorContextCallback::arg, Assert, ErrorContextCallback::callback, LogicalErrorCallbackState::callback_name, LogicalDecodingContext::callbacks, LogicalErrorCallbackState::ctx, error_context_stack, LogicalDecodingContext::fast_forward, OutputPluginCallbacks::filter_prepare_cb, InvalidXLogRecPtr, output_plugin_error_callback(), ErrorContextCallback::previous, and LogicalErrorCallbackState::report_location.
Referenced by FilterPrepare().
void FreeDecodingContext | ( | LogicalDecodingContext * | ctx | ) |
Definition at line 614 of file logical.c.
References LogicalDecodingContext::callbacks, LogicalDecodingContext::context, FreeSnapshotBuilder(), MemoryContextDelete(), LogicalDecodingContext::reader, LogicalDecodingContext::reorder, ReorderBufferFree(), OutputPluginCallbacks::shutdown_cb, shutdown_cb_wrapper(), LogicalDecodingContext::snapshot_builder, and XLogReaderFree().
Referenced by create_logical_replication_slot(), CreateReplicationSlot(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), and StartLogicalReplication().
void LogicalConfirmReceivedLocation | ( | XLogRecPtr | lsn | ) |
Definition at line 1665 of file logical.c.
References Assert, ReplicationSlot::candidate_catalog_xmin, ReplicationSlot::candidate_restart_lsn, ReplicationSlot::candidate_restart_valid, ReplicationSlot::candidate_xmin_lsn, ReplicationSlotPersistentData::catalog_xmin, ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, DEBUG1, ReplicationSlot::effective_catalog_xmin, elog, InvalidTransactionId, InvalidXLogRecPtr, ReplicationSlot::mutex, MyReplicationSlot, ReplicationSlotMarkDirty(), ReplicationSlotSave(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotPersistentData::restart_lsn, SpinLockAcquire, SpinLockRelease, and TransactionIdIsValid.
Referenced by LogicalIncreaseRestartDecodingForSlot(), LogicalIncreaseXminForSlot(), pg_logical_replication_slot_advance(), pg_logical_slot_get_changes_guts(), and ProcessStandbyReplyMessage().
void LogicalIncreaseRestartDecodingForSlot | ( | XLogRecPtr | current_lsn, |
XLogRecPtr | restart_lsn | ||
) |
Definition at line 1591 of file logical.c.
References Assert, ReplicationSlot::candidate_restart_lsn, ReplicationSlot::candidate_restart_valid, ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, DEBUG1, elog, InvalidXLogRecPtr, LogicalConfirmReceivedLocation(), LSN_FORMAT_ARGS, ReplicationSlot::mutex, MyReplicationSlot, SpinLockAcquire, and SpinLockRelease.
Referenced by SnapBuildProcessRunningXacts().
void LogicalIncreaseXminForSlot | ( | XLogRecPtr | lsn, |
TransactionId | xmin | ||
) |
Definition at line 1534 of file logical.c.
References Assert, ReplicationSlot::candidate_catalog_xmin, ReplicationSlot::candidate_xmin_lsn, ReplicationSlotPersistentData::catalog_xmin, ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, InvalidXLogRecPtr, LogicalConfirmReceivedLocation(), ReplicationSlot::mutex, MyReplicationSlot, SpinLockAcquire, SpinLockRelease, and TransactionIdPrecedesOrEquals().
Referenced by SnapBuildProcessRunningXacts().
void ResetLogicalStreamingState | ( | void | ) |
Definition at line 1752 of file logical.c.
References bsysscan, CheckXidAlive, and InvalidTransactionId.
Referenced by AbortSubTransaction(), and AbortTransaction().
void UpdateDecodingStats | ( | LogicalDecodingContext * | ctx | ) |
Definition at line 1762 of file logical.c.
References ReplicationSlot::data, DEBUG2, elog, ReplicationSlotPersistentData::name, NameStr, pgstat_report_replslot(), LogicalDecodingContext::reorder, LogicalDecodingContext::slot, ReorderBuffer::spillBytes, ReorderBuffer::spillCount, ReorderBuffer::spillTxns, ReorderBuffer::streamBytes, ReorderBuffer::streamCount, and ReorderBuffer::streamTxns.
Referenced by DecodeAbort(), DecodeCommit(), and DecodePrepare().