Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b9bf23a

Browse files
committed
Fix filtering of unsupported relations in logical replication
In the pgoutput plugin, skip changes for relations that are not publishable, per is_publishable_class(). This concerns in particular materialized views and information_schema tables. While those relations cannot be part of a publication, per existing checks, they will be considered by a FOR ALL TABLES publication. A subscription would not actually apply changes for those relations, again per existing checks, but trying to match incoming changes to local tables on the subscriber would lead to errors if no matching local table exists. Skipping those changes on the publisher avoids sending useless changes and eliminates the error. Bug: #15044 Reported-by: Chad Trabant <chad@iris.washington.edu> Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>
1 parent 0222e89 commit b9bf23a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/backend/catalog/pg_publication.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ is_publishable_class(Oid relid, Form_pg_class reltuple)
105105
relid >= FirstNormalObjectId;
106106
}
107107

108+
/*
109+
* Another variant of this, taking a Relation.
110+
*/
111+
bool
112+
is_publishable_relation(Relation rel)
113+
{
114+
return is_publishable_class(RelationGetRelid(rel), rel->rd_rel);
115+
}
116+
108117

109118
/*
110119
* SQL-callable variant of the above

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
264264
MemoryContext old;
265265
RelationSyncEntry *relentry;
266266

267+
if (!is_publishable_relation(relation))
268+
return;
269+
267270
relentry = get_rel_sync_entry(data, RelationGetRelid(relation));
268271

269272
/* First check the table filter */

src/include/catalog/pg_publication.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ extern List *GetPublicationRelations(Oid pubid);
9393
extern List *GetAllTablesPublications(void);
9494
extern List *GetAllTablesPublicationRelations(void);
9595

96+
extern bool is_publishable_relation(Relation rel);
9697
extern ObjectAddress publication_add_relation(Oid pubid, Relation targetrel,
9798
bool if_not_exists);
9899

0 commit comments

Comments
 (0)