From 872dfb5da2e62134cb8286f3a0ce2897a141db17 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 29 Jul 2022 09:06:26 +1000 Subject: [PATCH v1] Functions 'is_publishable_class' and 'is_publishable_relation' should be together. --- src/backend/catalog/pg_publication.c | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index ade3bf3..7af903d 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -112,35 +112,6 @@ check_publication_add_schema(Oid schemaid) } /* - * Returns if relation represented by oid and Form_pg_class entry - * is publishable. - * - * Does same checks as the above, but does not need relation to be opened - * and also does not throw errors. - * - * XXX This also excludes all tables with relid < FirstNormalObjectId, - * ie all tables created during initdb. This mainly affects the preinstalled - * information_schema. IsCatalogRelationOid() only excludes tables with - * relid < FirstUnpinnedObjectId, making that test rather redundant, - * but really we should get rid of the FirstNormalObjectId test not - * IsCatalogRelationOid. We can't do so today because we don't want - * information_schema tables to be considered publishable; but this test - * is really inadequate for that, since the information_schema could be - * dropped and reloaded and then it'll be considered publishable. The best - * long-term solution may be to add a "relispublishable" bool to pg_class, - * and depend on that instead of OID checks. - */ -static bool -is_publishable_class(Oid relid, Form_pg_class reltuple) -{ - return (reltuple->relkind == RELKIND_RELATION || - reltuple->relkind == RELKIND_PARTITIONED_TABLE) && - !IsCatalogRelationOid(relid) && - reltuple->relpersistence == RELPERSISTENCE_PERMANENT && - relid >= FirstNormalObjectId; -} - -/* * Filter out the partitions whose parent tables were also specified in * the publication. */ @@ -180,6 +151,35 @@ filter_partitions(List *relids) } /* + * Returns if relation represented by oid and Form_pg_class entry + * is publishable. + * + * Does same checks as the above, but does not need relation to be opened + * and also does not throw errors. + * + * XXX This also excludes all tables with relid < FirstNormalObjectId, + * ie all tables created during initdb. This mainly affects the preinstalled + * information_schema. IsCatalogRelationOid() only excludes tables with + * relid < FirstUnpinnedObjectId, making that test rather redundant, + * but really we should get rid of the FirstNormalObjectId test not + * IsCatalogRelationOid. We can't do so today because we don't want + * information_schema tables to be considered publishable; but this test + * is really inadequate for that, since the information_schema could be + * dropped and reloaded and then it'll be considered publishable. The best + * long-term solution may be to add a "relispublishable" bool to pg_class, + * and depend on that instead of OID checks. + */ +static bool +is_publishable_class(Oid relid, Form_pg_class reltuple) +{ + return (reltuple->relkind == RELKIND_RELATION || + reltuple->relkind == RELKIND_PARTITIONED_TABLE) && + !IsCatalogRelationOid(relid) && + reltuple->relpersistence == RELPERSISTENCE_PERMANENT && + relid >= FirstNormalObjectId; +} + +/* * Another variant of this, taking a Relation. */ bool -- 1.8.3.1