mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Allow logical replication to transfer data in binary format.
This patch adds a "binary" option to CREATE/ALTER SUBSCRIPTION. When that's set, the publisher will send data using the data type's typsend function if any, rather than typoutput. This is generally faster, if slightly less robust. As committed, we won't try to transfer user-defined array or composite types in binary, for fear that type OIDs won't match at the subscriber. This might be changed later, but it seems like fit material for a follow-on patch. Dave Cramer, reviewed by Daniel Gustafsson, Petr Jelinek, and others; adjusted some by me Discussion: https://postgr.es/m/CADK3HH+R3xMn=8t3Ct+uD+qJ1KD=Hbif5NFMJ+d5DkoCzp6Vgw@mail.gmail.com
This commit is contained in:
@@ -30,12 +30,19 @@
|
||||
/* Tuple coming via logical replication. */
|
||||
typedef struct LogicalRepTupleData
|
||||
{
|
||||
/* column values in text format, or NULL for a null value: */
|
||||
char *values[MaxTupleAttributeNumber];
|
||||
/* markers for changed/unchanged column values: */
|
||||
bool changed[MaxTupleAttributeNumber];
|
||||
/* Array of StringInfos, one per column; some may be unused */
|
||||
StringInfoData *colvalues;
|
||||
/* Array of markers for null/unchanged/text/binary, one per column */
|
||||
char *colstatus;
|
||||
} LogicalRepTupleData;
|
||||
|
||||
/* Possible values for LogicalRepTupleData.colstatus[colnum] */
|
||||
/* These values are also used in the on-the-wire protocol */
|
||||
#define LOGICALREP_COLUMN_NULL 'n'
|
||||
#define LOGICALREP_COLUMN_UNCHANGED 'u'
|
||||
#define LOGICALREP_COLUMN_TEXT 't'
|
||||
#define LOGICALREP_COLUMN_BINARY 'b' /* added in PG14 */
|
||||
|
||||
typedef uint32 LogicalRepRelId;
|
||||
|
||||
/* Relation information */
|
||||
@@ -87,15 +94,15 @@ extern void logicalrep_write_origin(StringInfo out, const char *origin,
|
||||
XLogRecPtr origin_lsn);
|
||||
extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn);
|
||||
extern void logicalrep_write_insert(StringInfo out, Relation rel,
|
||||
HeapTuple newtuple);
|
||||
HeapTuple newtuple, bool binary);
|
||||
extern LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup);
|
||||
extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
|
||||
HeapTuple newtuple);
|
||||
HeapTuple newtuple, bool binary);
|
||||
extern LogicalRepRelId logicalrep_read_update(StringInfo in,
|
||||
bool *has_oldtuple, LogicalRepTupleData *oldtup,
|
||||
LogicalRepTupleData *newtup);
|
||||
extern void logicalrep_write_delete(StringInfo out, Relation rel,
|
||||
HeapTuple oldtuple);
|
||||
HeapTuple oldtuple, bool binary);
|
||||
extern LogicalRepRelId logicalrep_read_delete(StringInfo in,
|
||||
LogicalRepTupleData *oldtup);
|
||||
extern void logicalrep_write_truncate(StringInfo out, int nrelids, Oid relids[],
|
||||
|
||||
Reference in New Issue
Block a user