From 9ecc9fe672ca0ab91dcf8bf76cbc74ca793d3232 Mon Sep 17 00:00:00 2001 From: Dave Cramer Date: Wed, 30 Oct 2019 09:58:59 -0400 Subject: [PATCH 4/4] get relid inside of logical_read_insert --- src/backend/replication/logical/proto.c | 6 ++++-- src/backend/replication/logical/worker.c | 4 ++-- src/include/replication/logicalproto.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index 8859aa8e79..9164d36edc 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -161,18 +161,20 @@ logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple, bool b * * Fills the new tuple. */ -void +LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup) { char action; + LogicalRepRelId relid; + relid = pq_getmsgint(in, 4); action = pq_getmsgbyte(in); if (action != 'N') elog(ERROR, "expected new tuple but got %d", action); logicalrep_read_tuple(in, newtup); - + return relid; } /* diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 6d5c0c1ce1..8ad61d9ffb 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -620,10 +620,10 @@ apply_handle_insert(StringInfo s) ensure_transaction(); /* read the relation id */ - relid = pq_getmsgint(s, 4); + relid = logicalrep_read_insert(s, &newtup); rel = logicalrep_rel_open(relid, RowExclusiveLock); - logicalrep_read_insert(s, &newtup); + if (!should_apply_changes_for_rel(rel)) { diff --git a/src/include/replication/logicalproto.h b/src/include/replication/logicalproto.h index 4d1b7e8c4f..b299a2c226 100644 --- a/src/include/replication/logicalproto.h +++ b/src/include/replication/logicalproto.h @@ -91,7 +91,7 @@ extern void logicalrep_write_origin(StringInfo out, const char *origin, extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn); extern void logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple, bool binary_basetypes); -extern void logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup); +extern LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup); extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple, HeapTuple newtuple, bool binary_basetypes); extern void logicalrep_read_update(StringInfo in, -- 2.20.1 (Apple Git-117)