PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/tupconvert.h"
#include "catalog/partition.h"
#include "catalog/pg_publication.h"
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_subscription.h"
#include "commands/defrem.h"
#include "commands/subscriptioncmds.h"
#include "executor/executor.h"
#include "fmgr.h"
#include "nodes/makefuncs.h"
#include "parser/parse_relation.h"
#include "replication/logical.h"
#include "replication/logicalproto.h"
#include "replication/origin.h"
#include "replication/pgoutput.h"
#include "utils/builtins.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | RelationSyncEntry |
struct | PGOutputTxnData |
Macros | |
#define | NUM_ROWFILTER_PUBACTIONS (PUBACTION_DELETE+1) |
Typedefs | |
typedef struct RelationSyncEntry | RelationSyncEntry |
typedef struct PGOutputTxnData | PGOutputTxnData |
Enumerations | |
enum | RowFilterPubAction { PUBACTION_INSERT , PUBACTION_UPDATE , PUBACTION_DELETE } |
Variables | |
PG_MODULE_MAGIC | |
static bool | publications_valid |
static HTAB * | RelationSyncCache = NULL |
#define NUM_ROWFILTER_PUBACTIONS (PUBACTION_DELETE+1) |
Definition at line 102 of file pgoutput.c.
typedef struct PGOutputTxnData PGOutputTxnData |
typedef struct RelationSyncEntry RelationSyncEntry |
enum RowFilterPubAction |
Enumerator | |
---|---|
PUBACTION_INSERT | |
PUBACTION_UPDATE | |
PUBACTION_DELETE |
Definition at line 95 of file pgoutput.c.
void _PG_output_plugin_init | ( | OutputPluginCallbacks * | cb | ) |
Definition at line 253 of file pgoutput.c.
References OutputPluginCallbacks::begin_cb, OutputPluginCallbacks::begin_prepare_cb, OutputPluginCallbacks::change_cb, OutputPluginCallbacks::commit_cb, OutputPluginCallbacks::commit_prepared_cb, OutputPluginCallbacks::filter_by_origin_cb, OutputPluginCallbacks::message_cb, pgoutput_begin_prepare_txn(), pgoutput_begin_txn(), pgoutput_change(), pgoutput_commit_prepared_txn(), pgoutput_commit_txn(), pgoutput_message(), pgoutput_origin_filter(), pgoutput_prepare_txn(), pgoutput_rollback_prepared_txn(), pgoutput_shutdown(), pgoutput_startup(), pgoutput_stream_abort(), pgoutput_stream_commit(), pgoutput_stream_prepare_txn(), pgoutput_stream_start(), pgoutput_stream_stop(), pgoutput_truncate(), OutputPluginCallbacks::prepare_cb, OutputPluginCallbacks::rollback_prepared_cb, OutputPluginCallbacks::shutdown_cb, OutputPluginCallbacks::startup_cb, OutputPluginCallbacks::stream_abort_cb, OutputPluginCallbacks::stream_change_cb, OutputPluginCallbacks::stream_commit_cb, OutputPluginCallbacks::stream_message_cb, OutputPluginCallbacks::stream_prepare_cb, OutputPluginCallbacks::stream_start_cb, OutputPluginCallbacks::stream_stop_cb, OutputPluginCallbacks::stream_truncate_cb, and OutputPluginCallbacks::truncate_cb.
|
static |
Definition at line 1020 of file pgoutput.c.
References check_and_fetch_column_list(), ereport, errcode(), errmsg(), ERROR, foreach_ptr, get_namespace_name(), i, RelationSyncEntry::include_gencols, TupleDescData::natts, RelationSyncEntry::publish_as_relid, RelationGetDescr, RelationGetNamespace, RelationGetRelationName, RelationIdGetRelation(), and TupleDescAttr.
Referenced by get_rel_sync_entry().
|
static |
Definition at line 2309 of file pgoutput.c.
References Assert, foreach_delete_current, foreach_xid, hash_seq_init(), hash_seq_search(), RelationSyncCache, RelationSyncEntry::schema_sent, and RelationSyncEntry::streamed_txns.
Referenced by pgoutput_stream_abort(), and pgoutput_stream_commit().
Definition at line 798 of file pgoutput.c.
References AccessShareLock, addRTEPermissionInfo(), CreateExecutorState(), EState::es_output_cid, ExecInitRangeTable(), GetCurrentCommandId(), list_make1, makeNode, NIL, RelationData::rd_rel, RelationGetRelid, RangeTblEntry::relid, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by pgoutput_row_filter_init().
|
static |
Definition at line 2011 of file pgoutput.c.
References Publication::alltables, Assert, RelationSyncEntry::attrmap, bms_free(), CacheMemoryContext, check_and_init_gencol(), RelationSyncEntry::columns, data, RelationSyncEntry::entry_cxt, RelationSyncEntry::estate, ExecDropSingleTupleTableSlot(), RelationSyncEntry::exprstate, free_attrmap(), FreeTupleDesc(), get_partition_ancestors(), get_rel_namespace(), get_rel_relispartition(), get_rel_relkind(), GetRelationPublications(), GetSchemaPublications(), GetTopMostAncestorInPublication(), HASH_ENTER, hash_search(), RelationSyncEntry::include_gencols, init_tuple_slot(), InvalidOid, lappend(), lfirst, list_free(), list_free_deep(), list_length(), list_member_oid(), llast_oid, LoadPublications(), MemoryContextDelete(), MemoryContextSwitchTo(), RelationSyncEntry::new_slot, NIL, Publication::oid, RelationSyncEntry::old_slot, pgoutput_column_list_init(), pgoutput_row_filter_init(), RelationSyncEntry::pubactions, Publication::pubactions, PublicationActions::pubdelete, PublicationActions::pubinsert, publications_valid, RelationSyncEntry::publish_as_relid, PublicationActions::pubtruncate, PublicationActions::pubupdate, Publication::pubviaroot, RelationGetRelid, RelationSyncCache, RelationSyncEntry::replicate_valid, RelationSyncEntry::schema_sent, RelationSyncEntry::streamed_txns, TupleDescData::tdrefcount, and TupleTableSlot::tts_tupleDescriptor.
Referenced by pgoutput_change(), and pgoutput_truncate().
|
static |
Definition at line 1980 of file pgoutput.c.
References list_member_xid(), and RelationSyncEntry::streamed_txns.
Referenced by maybe_send_schema().
|
static |
Definition at line 1926 of file pgoutput.c.
References Assert, CacheRegisterRelcacheCallback(), CacheRegisterSyscacheCallback(), ctl, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, rel_sync_cache_publication_cb(), rel_sync_cache_relation_cb(), and RelationSyncCache.
Referenced by pgoutput_startup().
|
static |
Definition at line 1165 of file pgoutput.c.
References RelationSyncEntry::attrmap, build_attrmap_by_name_if_req(), CacheMemoryContext, CreateTupleDescCopyConstr(), data, MakeSingleTupleTableSlot(), MemoryContextSwitchTo(), RelationSyncEntry::new_slot, RelationSyncEntry::old_slot, RelationSyncEntry::publish_as_relid, RelationClose(), RelationGetDescr, RelationGetRelid, RelationIdGetRelation(), and TTSOpsHeapTuple.
Referenced by get_rel_sync_entry().
Definition at line 1755 of file pgoutput.c.
References GetPublicationByName(), lappend(), lfirst, and NIL.
Referenced by get_rel_sync_entry().
|
static |
Definition at line 685 of file pgoutput.c.
References data, get_schema_sent_in_streamed_txn(), if(), InvalidTransactionId, LogicalDecodingContext::output_plugin_private, RelationSyncEntry::publish_as_relid, rbtxn_get_toptxn, rbtxn_is_subtxn, RelationClose(), RelationGetRelid, RelationIdGetRelation(), RelationSyncEntry::schema_sent, send_relation_and_attrs(), set_schema_sent_in_streamed_txn(), ReorderBufferChange::txn, and ReorderBufferTXN::xid.
Referenced by pgoutput_change(), and pgoutput_truncate().
|
static |
Definition at line 282 of file pgoutput.c.
References DefElem::arg, Assert, data, defGetBoolean(), defGetStreamingMode(), defGetString(), DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, IsA, lfirst, pg_strcasecmp(), PG_UINT32_MAX, SplitIdentifierString(), and strVal.
Referenced by pgoutput_startup().
|
static |
Definition at line 622 of file pgoutput.c.
References InvalidRepOriginId, logicalrep_write_begin_prepare(), ReorderBufferTXN::origin_id, ReorderBufferTXN::origin_lsn, LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginWrite(), and send_repl_origin().
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 554 of file pgoutput.c.
References LogicalDecodingContext::context, MemoryContextAllocZero(), and ReorderBufferTXN::output_plugin_private.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1438 of file pgoutput.c.
References generate_unaccent_rules::action, ReorderBufferChange::action, Assert, RelationSyncEntry::attrmap, cleanup(), RelationSyncEntry::columns, ReorderBufferChange::data, data, DEBUG1, elog, ExecDropSingleTupleTableSlot(), ExecStoreHeapTuple(), execute_attr_map_slot(), get_rel_sync_entry(), RelationSyncEntry::include_gencols, InvalidTransactionId, is_publishable_relation(), logicalrep_write_delete(), logicalrep_write_insert(), logicalrep_write_update(), MakeTupleTableSlot(), maybe_send_schema(), MemoryContextReset(), MemoryContextSwitchTo(), RelationSyncEntry::new_slot, RelationSyncEntry::old_slot, LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, ReorderBufferTXN::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginWrite(), pgoutput_row_filter(), pgoutput_send_begin(), RelationSyncEntry::pubactions, PublicationActions::pubdelete, PublicationActions::pubinsert, RelationSyncEntry::publish_as_relid, PublicationActions::pubupdate, RelationData::rd_rel, RelationClose(), RelationGetDescr, RelationGetRelid, RelationIdGetRelation(), RelationIsValid, REORDER_BUFFER_CHANGE_DELETE, REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_UPDATE, ReorderBufferChange::tp, TTSOpsVirtual, ReorderBufferChange::txn, and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1079 of file pgoutput.c.
References bms_equal(), check_and_fetch_column_list(), RelationSyncEntry::columns, data, RelationSyncEntry::entry_cxt, ereport, errcode(), errmsg(), ERROR, get_namespace_name(), RelationSyncEntry::include_gencols, lfirst, list_length(), MemoryContextSwitchTo(), pgoutput_ensure_entry_cxt(), pub_form_cols_map(), RelationSyncEntry::publish_as_relid, RelationClose(), RelationGetNamespace, RelationGetRelationName, and RelationIdGetRelation().
Referenced by get_rel_sync_entry().
|
static |
Definition at line 653 of file pgoutput.c.
References logicalrep_write_commit_prepared(), LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginUpdateProgress(), and OutputPluginWrite().
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 590 of file pgoutput.c.
References Assert, DEBUG1, elog, logicalrep_write_commit(), LogicalDecodingContext::out, ReorderBufferTXN::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginUpdateProgress(), OutputPluginWrite(), pfree(), PGOutputTxnData::sent_begin_txn, and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 851 of file pgoutput.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, data, RelationSyncEntry::entry_cxt, MemoryContextCopyAndSetIdentifier, RelationSyncEntry::publish_as_relid, RelationGetRelationName, and RelationIdGetRelation().
Referenced by pgoutput_column_list_init(), and pgoutput_row_filter_init().
|
static |
Definition at line 1678 of file pgoutput.c.
References data, if(), InvalidTransactionId, logicalrep_write_message(), LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, ReorderBufferTXN::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginWrite(), pgoutput_send_begin(), PGOutputTxnData::sent_begin_txn, and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1723 of file pgoutput.c.
References data, if(), InvalidRepOriginId, and LogicalDecodingContext::output_plugin_private.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 639 of file pgoutput.c.
References logicalrep_write_prepare(), LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginUpdateProgress(), and OutputPluginWrite().
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 667 of file pgoutput.c.
References logicalrep_write_rollback_prepared(), LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginUpdateProgress(), and OutputPluginWrite().
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1257 of file pgoutput.c.
References generate_unaccent_rules::action, Assert, DEBUG3, ExprContext::ecxt_scantuple, elog, RelationSyncEntry::estate, ExecClearTuple(), ExecStoreVirtualTuple(), RelationSyncEntry::exprstate, get_namespace_name(), GetPerTupleExprContext, i, MakeSingleTupleTableSlot(), TupleDescData::natts, pgoutput_row_filter_exec_expr(), PUBACTION_DELETE, PUBACTION_INSERT, PUBACTION_UPDATE, RelationGetDescr, RelationGetNamespace, RelationGetRelationName, REORDER_BUFFER_CHANGE_DELETE, REORDER_BUFFER_CHANGE_INSERT, REORDER_BUFFER_CHANGE_UPDATE, ResetPerTupleExprContext, slot_getallattrs(), TupleTableSlot::tts_isnull, TupleTableSlot::tts_values, TTSOpsVirtual, TupleDescAttr, and VARATT_IS_EXTERNAL_ONDISK.
Referenced by pgoutput_change().
|
static |
Definition at line 828 of file pgoutput.c.
References Assert, DatumGetBool(), DEBUG3, elog, and ExecEvalExprSwitchContext().
Referenced by pgoutput_row_filter().
|
static |
Definition at line 873 of file pgoutput.c.
References Publication::alltables, create_estate_for_relation(), data, RelationSyncEntry::entry_cxt, RelationSyncEntry::estate, ExecPrepareExpr(), RelationSyncEntry::exprstate, get_rel_namespace(), HeapTupleIsValid, idx(), lappend(), lfirst, list_free_deep(), make_orclause(), MemoryContextSwitchTo(), NIL, NUM_ROWFILTER_PUBACTIONS, ObjectIdGetDatum(), Publication::oid, pgoutput_ensure_entry_cxt(), PUBACTION_DELETE, PUBACTION_INSERT, PUBACTION_UPDATE, Publication::pubactions, PublicationActions::pubdelete, PublicationActions::pubinsert, RelationSyncEntry::publish_as_relid, PublicationActions::pubupdate, RelationClose(), RelationIdGetRelation(), ReleaseSysCache(), SearchSysCache2(), SearchSysCacheExists2, stringToNode(), SysCacheGetAttr(), and TextDatumGetCString.
Referenced by get_rel_sync_entry().
|
static |
Definition at line 568 of file pgoutput.c.
References Assert, InvalidRepOriginId, logicalrep_write_begin(), ReorderBufferTXN::origin_id, ReorderBufferTXN::origin_lsn, LogicalDecodingContext::out, ReorderBufferTXN::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginWrite(), send_repl_origin(), and PGOutputTxnData::sent_begin_txn.
Referenced by pgoutput_change(), pgoutput_message(), and pgoutput_truncate().
|
static |
Definition at line 1742 of file pgoutput.c.
References hash_destroy(), and RelationSyncCache.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 424 of file pgoutput.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CacheMemoryContext, CacheRegisterSyscacheCallback(), LogicalDecodingContext::context, data, ereport, errcode(), errmsg(), ERROR, init_rel_sync_cache(), LOGICALREP_PROTO_MAX_VERSION_NUM, LOGICALREP_PROTO_MIN_VERSION_NUM, LOGICALREP_PROTO_STREAM_PARALLEL_VERSION_NUM, LOGICALREP_PROTO_STREAM_VERSION_NUM, LOGICALREP_PROTO_TWOPHASE_VERSION_NUM, NIL, OUTPUT_PLUGIN_BINARY_OUTPUT, LogicalDecodingContext::output_plugin_options, LogicalDecodingContext::output_plugin_private, OutputPluginOptions::output_type, palloc0(), parse_output_parameters(), publication_invalidation_cb(), publications_valid, LogicalDecodingContext::streaming, LogicalDecodingContext::twophase, and LogicalDecodingContext::twophase_opt_given.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1845 of file pgoutput.c.
References ReorderBufferTXN::abort_time, Assert, cleanup_rel_sync_cache(), data, logicalrep_write_stream_abort(), LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginWrite(), rbtxn_get_toptxn, rbtxn_is_streamed, ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1878 of file pgoutput.c.
References Assert, cleanup_rel_sync_cache(), data, logicalrep_write_stream_commit(), LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginUpdateProgress(), OutputPluginWrite(), PG_USED_FOR_ASSERTS_ONLY, rbtxn_is_streamed, and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1906 of file pgoutput.c.
References Assert, logicalrep_write_stream_prepare(), LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginUpdateProgress(), OutputPluginWrite(), and rbtxn_is_streamed.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1792 of file pgoutput.c.
References Assert, data, InvalidRepOriginId, InvalidXLogRecPtr, logicalrep_write_stream_start(), ReorderBufferTXN::origin_id, LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginWrite(), rbtxn_is_streamed, send_repl_origin(), and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1824 of file pgoutput.c.
References Assert, data, logicalrep_write_stream_stop(), LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, OutputPluginPrepareWrite(), and OutputPluginWrite().
Referenced by _PG_output_plugin_init().
|
static |
Definition at line 1610 of file pgoutput.c.
References ReorderBufferChange::data, data, get_rel_sync_entry(), i, InvalidTransactionId, is_publishable_relation(), logicalrep_write_truncate(), maybe_send_schema(), MemoryContextReset(), MemoryContextSwitchTo(), LogicalDecodingContext::out, LogicalDecodingContext::output_plugin_private, ReorderBufferTXN::output_plugin_private, OutputPluginPrepareWrite(), OutputPluginWrite(), palloc0(), pgoutput_send_begin(), RelationSyncEntry::pubactions, RelationSyncEntry::publish_as_relid, PublicationActions::pubtruncate, RelationData::rd_rel, RelationGetRelid, ReorderBufferChange::truncate, ReorderBufferChange::txn, and ReorderBufferTXN::xid.
Referenced by _PG_output_plugin_init().
Definition at line 1777 of file pgoutput.c.
References arg, publications_valid, and rel_sync_cache_publication_cb().
Referenced by pgoutput_startup().
Definition at line 2395 of file pgoutput.c.
References hash_seq_init(), hash_seq_search(), RelationSyncCache, and RelationSyncEntry::replicate_valid.
Referenced by init_rel_sync_cache(), and publication_invalidation_cb().
Definition at line 2344 of file pgoutput.c.
References HASH_FIND, hash_search(), hash_seq_init(), hash_seq_search(), OidIsValid, RelationSyncCache, and RelationSyncEntry::replicate_valid.
Referenced by init_rel_sync_cache().
|
static |
Definition at line 756 of file pgoutput.c.
References RelationSyncEntry::columns, FirstGenbkiObjectId, i, RelationSyncEntry::include_gencols, logicalrep_should_publish_column(), logicalrep_write_rel(), logicalrep_write_typ(), TupleDescData::natts, LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginWrite(), RelationGetDescr, and TupleDescAttr.
Referenced by maybe_send_schema().
|
static |
Definition at line 2421 of file pgoutput.c.
References logicalrep_write_origin(), LogicalDecodingContext::out, OutputPluginPrepareWrite(), OutputPluginWrite(), and replorigin_by_oid().
Referenced by pgoutput_begin_prepare_txn(), pgoutput_send_begin(), and pgoutput_stream_start().
|
static |
Definition at line 1990 of file pgoutput.c.
References CacheMemoryContext, lappend_xid(), MemoryContextSwitchTo(), and RelationSyncEntry::streamed_txns.
Referenced by maybe_send_schema().
PG_MODULE_MAGIC |
Definition at line 38 of file pgoutput.c.
|
static |
Definition at line 82 of file pgoutput.c.
Referenced by get_rel_sync_entry(), pgoutput_startup(), and publication_invalidation_cb().
|
static |
Definition at line 213 of file pgoutput.c.
Referenced by cleanup_rel_sync_cache(), get_rel_sync_entry(), init_rel_sync_cache(), pgoutput_shutdown(), rel_sync_cache_publication_cb(), and rel_sync_cache_relation_cb().