PostgreSQL Source Code git master
|
#include "access/xact.h"
#include "executor/tuptable.h"
#include "replication/reorderbuffer.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | LogicalRepTupleData |
struct | LogicalRepRelation |
struct | LogicalRepTyp |
struct | LogicalRepBeginData |
struct | LogicalRepCommitData |
struct | LogicalRepPreparedTxnData |
struct | LogicalRepCommitPreparedTxnData |
struct | LogicalRepRollbackPreparedTxnData |
struct | LogicalRepStreamAbortData |
Macros | |
#define | LOGICALREP_PROTO_MIN_VERSION_NUM 1 |
#define | LOGICALREP_PROTO_VERSION_NUM 1 |
#define | LOGICALREP_PROTO_STREAM_VERSION_NUM 2 |
#define | LOGICALREP_PROTO_TWOPHASE_VERSION_NUM 3 |
#define | LOGICALREP_PROTO_STREAM_PARALLEL_VERSION_NUM 4 |
#define | LOGICALREP_PROTO_MAX_VERSION_NUM LOGICALREP_PROTO_STREAM_PARALLEL_VERSION_NUM |
#define | LOGICALREP_COLUMN_NULL 'n' |
#define | LOGICALREP_COLUMN_UNCHANGED 'u' |
#define | LOGICALREP_COLUMN_TEXT 't' |
#define | LOGICALREP_COLUMN_BINARY 'b' /* added in PG14 */ |
Typedefs | |
typedef enum LogicalRepMsgType | LogicalRepMsgType |
typedef struct LogicalRepTupleData | LogicalRepTupleData |
typedef uint32 | LogicalRepRelId |
typedef struct LogicalRepRelation | LogicalRepRelation |
typedef struct LogicalRepTyp | LogicalRepTyp |
typedef struct LogicalRepBeginData | LogicalRepBeginData |
typedef struct LogicalRepCommitData | LogicalRepCommitData |
typedef struct LogicalRepPreparedTxnData | LogicalRepPreparedTxnData |
typedef struct LogicalRepCommitPreparedTxnData | LogicalRepCommitPreparedTxnData |
typedef struct LogicalRepRollbackPreparedTxnData | LogicalRepRollbackPreparedTxnData |
typedef struct LogicalRepStreamAbortData | LogicalRepStreamAbortData |
Enumerations | |
enum | LogicalRepMsgType { LOGICAL_REP_MSG_BEGIN = 'B' , LOGICAL_REP_MSG_COMMIT = 'C' , LOGICAL_REP_MSG_ORIGIN = 'O' , LOGICAL_REP_MSG_INSERT = 'I' , LOGICAL_REP_MSG_UPDATE = 'U' , LOGICAL_REP_MSG_DELETE = 'D' , LOGICAL_REP_MSG_TRUNCATE = 'T' , LOGICAL_REP_MSG_RELATION = 'R' , LOGICAL_REP_MSG_TYPE = 'Y' , LOGICAL_REP_MSG_MESSAGE = 'M' , LOGICAL_REP_MSG_BEGIN_PREPARE = 'b' , LOGICAL_REP_MSG_PREPARE = 'P' , LOGICAL_REP_MSG_COMMIT_PREPARED = 'K' , LOGICAL_REP_MSG_ROLLBACK_PREPARED = 'r' , LOGICAL_REP_MSG_STREAM_START = 'S' , LOGICAL_REP_MSG_STREAM_STOP = 'E' , LOGICAL_REP_MSG_STREAM_COMMIT = 'c' , LOGICAL_REP_MSG_STREAM_ABORT = 'A' , LOGICAL_REP_MSG_STREAM_PREPARE = 'p' } |
#define LOGICALREP_COLUMN_BINARY 'b' /* added in PG14 */ |
Definition at line 99 of file logicalproto.h.
#define LOGICALREP_COLUMN_NULL 'n' |
Definition at line 96 of file logicalproto.h.
#define LOGICALREP_COLUMN_TEXT 't' |
Definition at line 98 of file logicalproto.h.
#define LOGICALREP_COLUMN_UNCHANGED 'u' |
Definition at line 97 of file logicalproto.h.
#define LOGICALREP_PROTO_MAX_VERSION_NUM LOGICALREP_PROTO_STREAM_PARALLEL_VERSION_NUM |
Definition at line 45 of file logicalproto.h.
#define LOGICALREP_PROTO_MIN_VERSION_NUM 1 |
Definition at line 40 of file logicalproto.h.
#define LOGICALREP_PROTO_STREAM_PARALLEL_VERSION_NUM 4 |
Definition at line 44 of file logicalproto.h.
#define LOGICALREP_PROTO_STREAM_VERSION_NUM 2 |
Definition at line 42 of file logicalproto.h.
#define LOGICALREP_PROTO_TWOPHASE_VERSION_NUM 3 |
Definition at line 43 of file logicalproto.h.
#define LOGICALREP_PROTO_VERSION_NUM 1 |
Definition at line 41 of file logicalproto.h.
typedef struct LogicalRepBeginData LogicalRepBeginData |
typedef struct LogicalRepCommitData LogicalRepCommitData |
typedef struct LogicalRepCommitPreparedTxnData LogicalRepCommitPreparedTxnData |
typedef enum LogicalRepMsgType LogicalRepMsgType |
typedef struct LogicalRepPreparedTxnData LogicalRepPreparedTxnData |
typedef struct LogicalRepRelation LogicalRepRelation |
typedef uint32 LogicalRepRelId |
Definition at line 101 of file logicalproto.h.
typedef struct LogicalRepStreamAbortData LogicalRepStreamAbortData |
typedef struct LogicalRepTupleData LogicalRepTupleData |
typedef struct LogicalRepTyp LogicalRepTyp |
enum LogicalRepMsgType |
Definition at line 57 of file logicalproto.h.
const char * logicalrep_message_type | ( | LogicalRepMsgType | action | ) |
Definition at line 1209 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().
void logicalrep_read_begin | ( | StringInfo | in, |
LogicalRepBeginData * | begin_data | ||
) |
Definition at line 63 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 134 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 98 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 267 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 561 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 428 of file proto.c.
References generate_unaccent_rules::action, elog, ERROR, logicalrep_read_tuple(), pq_getmsgbyte(), and pq_getmsgint().
Referenced by apply_handle_insert().
char * logicalrep_read_origin | ( | StringInfo | in, |
XLogRecPtr * | origin_lsn | ||
) |
Definition at line 390 of file proto.c.
References pq_getmsgint64(), pq_getmsgstring(), and pstrdup().
void logicalrep_read_prepare | ( | StringInfo | in, |
LogicalRepPreparedTxnData * | prepare_data | ||
) |
Definition at line 228 of file proto.c.
References logicalrep_read_prepare_common().
Referenced by apply_handle_prepare().
LogicalRepRelation * logicalrep_read_rel | ( | StringInfo | in | ) |
Definition at line 698 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 325 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 1184 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 1129 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 365 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 1079 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 615 of file proto.c.
References i, lappend_oid(), NIL, pq_getmsgint(), TRUNCATE_CASCADE, and TRUNCATE_RESTART_SEQS.
Referenced by apply_handle_truncate().
void logicalrep_read_typ | ( | StringInfo | in, |
LogicalRepTyp * | ltyp | ||
) |
Definition at line 754 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 487 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, | ||
PublishGencolsType | include_gencols_type | ||
) |
Definition at line 1279 of file proto.c.
References bms_is_member().
Referenced by logicalrep_write_attrs(), logicalrep_write_tuple(), and send_relation_and_attrs().
void logicalrep_write_begin | ( | StringInfo | out, |
ReorderBufferTXN * | txn | ||
) |
Definition at line 49 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 116 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 78 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 237 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, | ||
PublishGencolsType | include_gencols_type | ||
) |
Definition at line 528 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, | ||
PublishGencolsType | include_gencols_type | ||
) |
Definition at line 403 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 640 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().
void logicalrep_write_origin | ( | StringInfo | out, |
const char * | origin, | ||
XLogRecPtr | origin_lsn | ||
) |
Definition at line 374 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 187 of file proto.c.
References LOGICAL_REP_MSG_PREPARE, and logicalrep_write_prepare_common().
Referenced by pgoutput_prepare_txn().
void logicalrep_write_rel | ( | StringInfo | out, |
TransactionId | xid, | ||
Relation | rel, | ||
Bitmapset * | columns, | ||
PublishGencolsType | include_gencols_type | ||
) |
Definition at line 667 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 293 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 1158 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 1104 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 353 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 1061 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 1095 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 583 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().
void logicalrep_write_typ | ( | StringInfo | out, |
TransactionId | xid, | ||
Oid | typoid | ||
) |
Definition at line 723 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, | ||
PublishGencolsType | include_gencols_type | ||
) |
Definition at line 450 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().