PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/sysattr.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_type.h"
#include "libpq/pqformat.h"
#include "replication/logicalproto.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
Go to the source code of this file.
Macros | |
#define | LOGICALREP_IS_REPLICA_IDENTITY 1 |
#define | MESSAGE_TRANSACTIONAL (1<<0) |
#define | TRUNCATE_CASCADE (1<<0) |
#define | TRUNCATE_RESTART_SEQS (1<<1) |
const char * logicalrep_message_type | ( | LogicalRepMsgType | action | ) |
Definition at line 1196 of file proto.c.
References generate_unaccent_rules::action, LOGICAL_REP_MSG_BEGIN, LOGICAL_REP_MSG_BEGIN_PREPARE, LOGICAL_REP_MSG_COMMIT, LOGICAL_REP_MSG_COMMIT_PREPARED, LOGICAL_REP_MSG_DELETE, LOGICAL_REP_MSG_INSERT, LOGICAL_REP_MSG_MESSAGE, LOGICAL_REP_MSG_ORIGIN, LOGICAL_REP_MSG_PREPARE, LOGICAL_REP_MSG_RELATION, LOGICAL_REP_MSG_ROLLBACK_PREPARED, LOGICAL_REP_MSG_STREAM_ABORT, LOGICAL_REP_MSG_STREAM_COMMIT, LOGICAL_REP_MSG_STREAM_PREPARE, LOGICAL_REP_MSG_STREAM_START, LOGICAL_REP_MSG_STREAM_STOP, LOGICAL_REP_MSG_TRUNCATE, LOGICAL_REP_MSG_TYPE, LOGICAL_REP_MSG_UPDATE, and snprintf.
Referenced by apply_error_callback().
|
static |
Definition at line 972 of file proto.c.
References LogicalRepRelation::attkeys, LogicalRepRelation::attnames, LogicalRepRelation::atttyps, bms_add_member(), i, LOGICALREP_IS_REPLICA_IDENTITY, LogicalRepRelation::natts, palloc(), pq_getmsgbyte(), pq_getmsgint(), pq_getmsgstring(), and pstrdup().
Referenced by logicalrep_read_rel().
void logicalrep_read_begin | ( | StringInfo | in, |
LogicalRepBeginData * | begin_data | ||
) |
Definition at line 62 of file proto.c.
References LogicalRepBeginData::committime, elog, ERROR, LogicalRepBeginData::final_lsn, InvalidXLogRecPtr, pq_getmsgint(), pq_getmsgint64(), and LogicalRepBeginData::xid.
Referenced by apply_handle_begin().
void logicalrep_read_begin_prepare | ( | StringInfo | in, |
LogicalRepPreparedTxnData * | begin_data | ||
) |
Definition at line 133 of file proto.c.
References elog, LogicalRepPreparedTxnData::end_lsn, ERROR, LogicalRepPreparedTxnData::gid, InvalidXLogRecPtr, pq_getmsgint(), pq_getmsgint64(), pq_getmsgstring(), LogicalRepPreparedTxnData::prepare_lsn, LogicalRepPreparedTxnData::prepare_time, strlcpy(), and LogicalRepPreparedTxnData::xid.
Referenced by apply_handle_begin_prepare().
void logicalrep_read_commit | ( | StringInfo | in, |
LogicalRepCommitData * | commit_data | ||
) |
Definition at line 97 of file proto.c.
References LogicalRepCommitData::commit_lsn, LogicalRepCommitData::committime, elog, LogicalRepCommitData::end_lsn, ERROR, pq_getmsgbyte(), and pq_getmsgint64().
Referenced by apply_handle_commit().
void logicalrep_read_commit_prepared | ( | StringInfo | in, |
LogicalRepCommitPreparedTxnData * | prepare_data | ||
) |
Definition at line 266 of file proto.c.
References LogicalRepCommitPreparedTxnData::commit_lsn, LogicalRepCommitPreparedTxnData::commit_time, elog, LogicalRepCommitPreparedTxnData::end_lsn, ERROR, LogicalRepCommitPreparedTxnData::gid, InvalidXLogRecPtr, pq_getmsgbyte(), pq_getmsgint(), pq_getmsgint64(), pq_getmsgstring(), strlcpy(), and LogicalRepCommitPreparedTxnData::xid.
Referenced by apply_handle_commit_prepared().
LogicalRepRelId logicalrep_read_delete | ( | StringInfo | in, |
LogicalRepTupleData * | oldtup | ||
) |
Definition at line 554 of file proto.c.
References generate_unaccent_rules::action, elog, ERROR, logicalrep_read_tuple(), pq_getmsgbyte(), and pq_getmsgint().
Referenced by apply_handle_delete().
LogicalRepRelId logicalrep_read_insert | ( | StringInfo | in, |
LogicalRepTupleData * | newtup | ||
) |
Definition at line 425 of file proto.c.
References generate_unaccent_rules::action, elog, ERROR, logicalrep_read_tuple(), pq_getmsgbyte(), and pq_getmsgint().
Referenced by apply_handle_insert().
|
static |
Definition at line 1034 of file proto.c.
References pq_getmsgstring().
Referenced by logicalrep_read_rel(), and logicalrep_read_typ().
char * logicalrep_read_origin | ( | StringInfo | in, |
XLogRecPtr * | origin_lsn | ||
) |
Definition at line 389 of file proto.c.
References pq_getmsgint64(), pq_getmsgstring(), and pstrdup().
void logicalrep_read_prepare | ( | StringInfo | in, |
LogicalRepPreparedTxnData * | prepare_data | ||
) |
Definition at line 227 of file proto.c.
References logicalrep_read_prepare_common().
Referenced by apply_handle_prepare().
|
static |
Definition at line 198 of file proto.c.
References elog, LogicalRepPreparedTxnData::end_lsn, ERROR, LogicalRepPreparedTxnData::gid, InvalidTransactionId, InvalidXLogRecPtr, pq_getmsgbyte(), pq_getmsgint(), pq_getmsgint64(), pq_getmsgstring(), LogicalRepPreparedTxnData::prepare_lsn, LogicalRepPreparedTxnData::prepare_time, strlcpy(), and LogicalRepPreparedTxnData::xid.
Referenced by logicalrep_read_prepare(), and logicalrep_read_stream_prepare().
LogicalRepRelation * logicalrep_read_rel | ( | StringInfo | in | ) |
Definition at line 690 of file proto.c.
References logicalrep_read_attrs(), logicalrep_read_namespace(), LogicalRepRelation::nspname, palloc(), pq_getmsgbyte(), pq_getmsgint(), pq_getmsgstring(), pstrdup(), LogicalRepRelation::relname, LogicalRepRelation::remoteid, and LogicalRepRelation::replident.
Referenced by apply_handle_relation().
void logicalrep_read_rollback_prepared | ( | StringInfo | in, |
LogicalRepRollbackPreparedTxnData * | rollback_data | ||
) |
Definition at line 324 of file proto.c.
References elog, ERROR, LogicalRepRollbackPreparedTxnData::gid, InvalidXLogRecPtr, pq_getmsgbyte(), pq_getmsgint(), pq_getmsgint64(), pq_getmsgstring(), LogicalRepRollbackPreparedTxnData::prepare_end_lsn, LogicalRepRollbackPreparedTxnData::prepare_time, LogicalRepRollbackPreparedTxnData::rollback_end_lsn, LogicalRepRollbackPreparedTxnData::rollback_time, strlcpy(), and LogicalRepRollbackPreparedTxnData::xid.
Referenced by apply_handle_rollback_prepared().
void logicalrep_read_stream_abort | ( | StringInfo | in, |
LogicalRepStreamAbortData * | abort_data, | ||
bool | read_abort_info | ||
) |
Definition at line 1171 of file proto.c.
References LogicalRepStreamAbortData::abort_lsn, LogicalRepStreamAbortData::abort_time, Assert, InvalidXLogRecPtr, pq_getmsgint(), pq_getmsgint64(), LogicalRepStreamAbortData::subxid, and LogicalRepStreamAbortData::xid.
Referenced by apply_handle_stream_abort().
TransactionId logicalrep_read_stream_commit | ( | StringInfo | in, |
LogicalRepCommitData * | commit_data | ||
) |
Definition at line 1116 of file proto.c.
References LogicalRepCommitData::commit_lsn, LogicalRepCommitData::committime, elog, LogicalRepCommitData::end_lsn, ERROR, pq_getmsgbyte(), pq_getmsgint(), and pq_getmsgint64().
Referenced by apply_handle_stream_commit().
void logicalrep_read_stream_prepare | ( | StringInfo | in, |
LogicalRepPreparedTxnData * | prepare_data | ||
) |
Definition at line 364 of file proto.c.
References logicalrep_read_prepare_common().
Referenced by apply_handle_stream_prepare().
TransactionId logicalrep_read_stream_start | ( | StringInfo | in, |
bool * | first_segment | ||
) |
Definition at line 1066 of file proto.c.
References Assert, pq_getmsgbyte(), and pq_getmsgint().
Referenced by apply_handle_stream_start().
List * logicalrep_read_truncate | ( | StringInfo | in, |
bool * | cascade, | ||
bool * | restart_seqs | ||
) |
Definition at line 608 of file proto.c.
References i, lappend_oid(), NIL, pq_getmsgint(), TRUNCATE_CASCADE, and TRUNCATE_RESTART_SEQS.
Referenced by apply_handle_truncate().
|
static |
Definition at line 850 of file proto.c.
References LogicalRepTupleData::colstatus, LogicalRepTupleData::colvalues, elog, ERROR, i, initStringInfoFromString(), len, LOGICALREP_COLUMN_BINARY, LOGICALREP_COLUMN_NULL, LOGICALREP_COLUMN_TEXT, LOGICALREP_COLUMN_UNCHANGED, LogicalRepTupleData::ncols, palloc(), palloc0(), pq_copymsgbytes(), pq_getmsgbyte(), pq_getmsgint(), and value.
Referenced by logicalrep_read_delete(), logicalrep_read_insert(), and logicalrep_read_update().
void logicalrep_read_typ | ( | StringInfo | in, |
LogicalRepTyp * | ltyp | ||
) |
Definition at line 746 of file proto.c.
References logicalrep_read_namespace(), LogicalRepTyp::nspname, pq_getmsgint(), pq_getmsgstring(), pstrdup(), LogicalRepTyp::remoteid, and LogicalRepTyp::typname.
Referenced by apply_handle_type().
LogicalRepRelId logicalrep_read_update | ( | StringInfo | in, |
bool * | has_oldtuple, | ||
LogicalRepTupleData * | oldtup, | ||
LogicalRepTupleData * | newtup | ||
) |
Definition at line 482 of file proto.c.
References generate_unaccent_rules::action, elog, ERROR, logicalrep_read_tuple(), pq_getmsgbyte(), and pq_getmsgint().
Referenced by apply_handle_update().
bool logicalrep_should_publish_column | ( | Form_pg_attribute | att, |
Bitmapset * | columns, | ||
bool | include_gencols | ||
) |
Definition at line 1265 of file proto.c.
References bms_is_member().
Referenced by logicalrep_write_attrs(), logicalrep_write_tuple(), and send_relation_and_attrs().
|
static |
Definition at line 910 of file proto.c.
References bms_free(), bms_is_member(), FirstLowInvalidHeapAttributeNumber, i, LOGICALREP_IS_REPLICA_IDENTITY, logicalrep_should_publish_column(), NameStr, TupleDescData::natts, pq_sendbyte(), pq_sendint16(), pq_sendint32(), pq_sendstring(), RelationData::rd_rel, RelationGetDescr, RelationGetIdentityKeyBitmap(), and TupleDescAttr().
Referenced by logicalrep_write_rel().
void logicalrep_write_begin | ( | StringInfo | out, |
ReorderBufferTXN * | txn | ||
) |
Definition at line 48 of file proto.c.
References ReorderBufferTXN::commit_time, ReorderBufferTXN::final_lsn, LOGICAL_REP_MSG_BEGIN, pq_sendbyte(), pq_sendint32(), pq_sendint64(), ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by pgoutput_send_begin().
void logicalrep_write_begin_prepare | ( | StringInfo | out, |
ReorderBufferTXN * | txn | ||
) |
Definition at line 115 of file proto.c.
References ReorderBufferTXN::end_lsn, ReorderBufferTXN::final_lsn, ReorderBufferTXN::gid, LOGICAL_REP_MSG_BEGIN_PREPARE, pq_sendbyte(), pq_sendint32(), pq_sendint64(), pq_sendstring(), ReorderBufferTXN::prepare_time, ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by pgoutput_begin_prepare_txn().
void logicalrep_write_commit | ( | StringInfo | out, |
ReorderBufferTXN * | txn, | ||
XLogRecPtr | commit_lsn | ||
) |
Definition at line 77 of file proto.c.
References ReorderBufferTXN::commit_time, ReorderBufferTXN::end_lsn, LOGICAL_REP_MSG_COMMIT, pq_sendbyte(), pq_sendint64(), and ReorderBufferTXN::xact_time.
Referenced by pgoutput_commit_txn().
void logicalrep_write_commit_prepared | ( | StringInfo | out, |
ReorderBufferTXN * | txn, | ||
XLogRecPtr | commit_lsn | ||
) |
Definition at line 236 of file proto.c.
References Assert, ReorderBufferTXN::commit_time, ReorderBufferTXN::end_lsn, ReorderBufferTXN::gid, LOGICAL_REP_MSG_COMMIT_PREPARED, pq_sendbyte(), pq_sendint32(), pq_sendint64(), pq_sendstring(), ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by pgoutput_commit_prepared_txn().
void logicalrep_write_delete | ( | StringInfo | out, |
TransactionId | xid, | ||
Relation | rel, | ||
TupleTableSlot * | oldslot, | ||
bool | binary, | ||
Bitmapset * | columns, | ||
bool | include_gencols | ||
) |
Definition at line 523 of file proto.c.
References Assert, LOGICAL_REP_MSG_DELETE, logicalrep_write_tuple(), pq_sendbyte(), pq_sendint32(), RelationData::rd_rel, RelationGetRelid, and TransactionIdIsValid.
Referenced by pgoutput_change().
void logicalrep_write_insert | ( | StringInfo | out, |
TransactionId | xid, | ||
Relation | rel, | ||
TupleTableSlot * | newslot, | ||
bool | binary, | ||
Bitmapset * | columns, | ||
bool | include_gencols | ||
) |
Definition at line 402 of file proto.c.
References LOGICAL_REP_MSG_INSERT, logicalrep_write_tuple(), pq_sendbyte(), pq_sendint32(), RelationGetRelid, and TransactionIdIsValid.
Referenced by pgoutput_change().
void logicalrep_write_message | ( | StringInfo | out, |
TransactionId | xid, | ||
XLogRecPtr | lsn, | ||
bool | transactional, | ||
const char * | prefix, | ||
Size | sz, | ||
const char * | message | ||
) |
Definition at line 633 of file proto.c.
References LOGICAL_REP_MSG_MESSAGE, MESSAGE_TRANSACTIONAL, pq_sendbyte(), pq_sendbytes(), pq_sendint32(), pq_sendint64(), pq_sendint8(), pq_sendstring(), and TransactionIdIsValid.
Referenced by pgoutput_message().
|
static |
Definition at line 1014 of file proto.c.
References elog, ERROR, get_namespace_name(), nspid, pq_sendbyte(), and pq_sendstring().
Referenced by logicalrep_write_rel(), and logicalrep_write_typ().
void logicalrep_write_origin | ( | StringInfo | out, |
const char * | origin, | ||
XLogRecPtr | origin_lsn | ||
) |
Definition at line 373 of file proto.c.
References LOGICAL_REP_MSG_ORIGIN, pq_sendbyte(), pq_sendint64(), and pq_sendstring().
Referenced by send_repl_origin().
void logicalrep_write_prepare | ( | StringInfo | out, |
ReorderBufferTXN * | txn, | ||
XLogRecPtr | prepare_lsn | ||
) |
Definition at line 186 of file proto.c.
References LOGICAL_REP_MSG_PREPARE, and logicalrep_write_prepare_common().
Referenced by pgoutput_prepare_txn().
|
static |
Definition at line 154 of file proto.c.
References Assert, ReorderBufferTXN::end_lsn, ReorderBufferTXN::gid, pq_sendbyte(), pq_sendint32(), pq_sendint64(), pq_sendstring(), ReorderBufferTXN::prepare_time, rbtxn_prepared, TransactionIdIsValid, type, ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by logicalrep_write_prepare(), and logicalrep_write_stream_prepare().
void logicalrep_write_rel | ( | StringInfo | out, |
TransactionId | xid, | ||
Relation | rel, | ||
Bitmapset * | columns, | ||
bool | include_gencols | ||
) |
Definition at line 660 of file proto.c.
References LOGICAL_REP_MSG_RELATION, logicalrep_write_attrs(), logicalrep_write_namespace(), pq_sendbyte(), pq_sendint32(), pq_sendstring(), RelationData::rd_rel, RelationGetNamespace, RelationGetRelationName, RelationGetRelid, relname, and TransactionIdIsValid.
Referenced by send_relation_and_attrs().
void logicalrep_write_rollback_prepared | ( | StringInfo | out, |
ReorderBufferTXN * | txn, | ||
XLogRecPtr | prepare_end_lsn, | ||
TimestampTz | prepare_time | ||
) |
Definition at line 292 of file proto.c.
References Assert, ReorderBufferTXN::commit_time, ReorderBufferTXN::end_lsn, ReorderBufferTXN::gid, LOGICAL_REP_MSG_ROLLBACK_PREPARED, pq_sendbyte(), pq_sendint32(), pq_sendint64(), pq_sendstring(), ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by pgoutput_rollback_prepared_txn().
void logicalrep_write_stream_abort | ( | StringInfo | out, |
TransactionId | xid, | ||
TransactionId | subxid, | ||
XLogRecPtr | abort_lsn, | ||
TimestampTz | abort_time, | ||
bool | write_abort_info | ||
) |
Definition at line 1145 of file proto.c.
References Assert, LOGICAL_REP_MSG_STREAM_ABORT, pq_sendbyte(), pq_sendint32(), pq_sendint64(), and TransactionIdIsValid.
Referenced by pgoutput_stream_abort().
void logicalrep_write_stream_commit | ( | StringInfo | out, |
ReorderBufferTXN * | txn, | ||
XLogRecPtr | commit_lsn | ||
) |
Definition at line 1091 of file proto.c.
References Assert, ReorderBufferTXN::commit_time, ReorderBufferTXN::end_lsn, LOGICAL_REP_MSG_STREAM_COMMIT, pq_sendbyte(), pq_sendint32(), pq_sendint64(), TransactionIdIsValid, ReorderBufferTXN::xact_time, and ReorderBufferTXN::xid.
Referenced by pgoutput_stream_commit().
void logicalrep_write_stream_prepare | ( | StringInfo | out, |
ReorderBufferTXN * | txn, | ||
XLogRecPtr | prepare_lsn | ||
) |
Definition at line 352 of file proto.c.
References LOGICAL_REP_MSG_STREAM_PREPARE, and logicalrep_write_prepare_common().
Referenced by pgoutput_stream_prepare_txn().
void logicalrep_write_stream_start | ( | StringInfo | out, |
TransactionId | xid, | ||
bool | first_segment | ||
) |
Definition at line 1048 of file proto.c.
References Assert, LOGICAL_REP_MSG_STREAM_START, pq_sendbyte(), pq_sendint32(), and TransactionIdIsValid.
Referenced by pgoutput_stream_start().
void logicalrep_write_stream_stop | ( | StringInfo | out | ) |
Definition at line 1082 of file proto.c.
References LOGICAL_REP_MSG_STREAM_STOP, and pq_sendbyte().
Referenced by pgoutput_stream_stop().
void logicalrep_write_truncate | ( | StringInfo | out, |
TransactionId | xid, | ||
int | nrelids, | ||
Oid | relids[], | ||
bool | cascade, | ||
bool | restart_seqs | ||
) |
Definition at line 576 of file proto.c.
References i, LOGICAL_REP_MSG_TRUNCATE, pq_sendbyte(), pq_sendint32(), pq_sendint8(), TransactionIdIsValid, TRUNCATE_CASCADE, and TRUNCATE_RESTART_SEQS.
Referenced by pgoutput_truncate().
|
static |
Definition at line 759 of file proto.c.
References elog, ERROR, GETSTRUCT, HeapTupleIsValid, i, len, LOGICALREP_COLUMN_BINARY, LOGICALREP_COLUMN_NULL, LOGICALREP_COLUMN_TEXT, LOGICALREP_COLUMN_UNCHANGED, logicalrep_should_publish_column(), TupleDescData::natts, ObjectIdGetDatum(), OidIsValid, OidOutputFunctionCall(), OidSendFunctionCall(), pfree(), pq_sendbyte(), pq_sendbytes(), pq_sendcountedtext(), pq_sendint(), pq_sendint16(), RelationGetDescr, ReleaseSysCache(), SearchSysCache1(), slot_getallattrs(), TupleTableSlot::tts_isnull, TupleTableSlot::tts_values, TupleDescAttr(), values, VARATT_IS_EXTERNAL_ONDISK, VARDATA, VARHDRSZ, and VARSIZE.
Referenced by logicalrep_write_delete(), logicalrep_write_insert(), and logicalrep_write_update().
void logicalrep_write_typ | ( | StringInfo | out, |
TransactionId | xid, | ||
Oid | typoid | ||
) |
Definition at line 715 of file proto.c.
References elog, ERROR, getBaseType(), GETSTRUCT, HeapTupleIsValid, LOGICAL_REP_MSG_TYPE, logicalrep_write_namespace(), NameStr, ObjectIdGetDatum(), pq_sendbyte(), pq_sendint32(), pq_sendstring(), ReleaseSysCache(), SearchSysCache1(), and TransactionIdIsValid.
Referenced by send_relation_and_attrs().
void logicalrep_write_update | ( | StringInfo | out, |
TransactionId | xid, | ||
Relation | rel, | ||
TupleTableSlot * | oldslot, | ||
TupleTableSlot * | newslot, | ||
bool | binary, | ||
Bitmapset * | columns, | ||
bool | include_gencols | ||
) |
Definition at line 447 of file proto.c.
References Assert, LOGICAL_REP_MSG_UPDATE, logicalrep_write_tuple(), pq_sendbyte(), pq_sendint32(), RelationData::rd_rel, RelationGetRelid, and TransactionIdIsValid.
Referenced by pgoutput_change().