pg13-init-RelationSyncEntry-properly.patch
application/octet-stream
Filename: pg13-init-RelationSyncEntry-properly.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/replication/pgoutput/pgoutput.c | 16 | 5 |
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 5b33b31515..30cb4e03aa 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -685,7 +685,22 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
Assert(entry != NULL);
/* Not found means schema wasn't sent */
- if (!found || !entry->replicate_valid)
+ if (!found)
+ {
+ /*
+ * Make the new entry valid enough for the callbacks to look at, in
+ * case any of them get invoked during the more complicated
+ * initialization steps below.
+ */
+ entry->schema_sent = false;
+ entry->replicate_valid = false;
+ entry->pubactions.pubinsert = entry->pubactions.pubupdate =
+ entry->pubactions.pubdelete = entry->pubactions.pubtruncate = false;
+ entry->publish_as_relid = InvalidOid;
+ entry->map = NULL; /* will be set by maybe_send_schema() if needed */
+ }
+
+ if (!entry->replicate_valid)
{
List *pubids = GetRelationPublications(relid);
ListCell *lc;
@@ -782,13 +797,9 @@ get_rel_sync_entry(PGOutputData *data, Oid relid)
list_free(pubids);
entry->publish_as_relid = publish_as_relid;
- entry->map = NULL; /* will be set by maybe_send_schema() if needed */
entry->replicate_valid = true;
}
- if (!found)
- entry->schema_sent = false;
-
return entry;
}