From 974d7e8726d1e326b75321f6af809c3dd4881d49 Mon Sep 17 00:00:00 2001 From: TotaJ Date: Thu, 16 Dec 2021 17:27:04 +0800 Subject: [PATCH] Fix acl error. --- src/common/backend/catalog/aclchk.cpp | 2 + src/common/backend/parser/gram.y | 18 +++---- src/common/backend/utils/cache/syscache.cpp | 5 ++ .../storage/replication/logical/origin.cpp | 2 +- .../catalog/pg_publication_namespace.h | 47 ------------------- src/include/utils/acl.h | 4 +- 6 files changed, 19 insertions(+), 59 deletions(-) delete mode 100644 src/include/catalog/pg_publication_namespace.h diff --git a/src/common/backend/catalog/aclchk.cpp b/src/common/backend/catalog/aclchk.cpp index d4514bb4f..7a9bd5643 100644 --- a/src/common/backend/catalog/aclchk.cpp +++ b/src/common/backend/catalog/aclchk.cpp @@ -4727,6 +4727,8 @@ static const char* const not_owner_msg[MAX_ACL_KIND] = { gettext_noop("must be owner of column encryption key %s"), /* ACL_KIND_GLOBAL_SETTING */ gettext_noop("must be owner of client master key %s"), + /* ACL_KIND_PACKAGE */ + gettext_noop("must be owner of package %s"), /* ACL_KIND_PUBLICATION */ gettext_noop("must be owner of publication %s"), /* ACL_KIND_SUBSCRIPTION */ diff --git a/src/common/backend/parser/gram.y b/src/common/backend/parser/gram.y index 046e9bc38..f26a6d1cb 100644 --- a/src/common/backend/parser/gram.y +++ b/src/common/backend/parser/gram.y @@ -335,8 +335,8 @@ static Node *make_node_from_scanbuf(int start_pos, int end_pos, core_yyscan_t yy CreateAppWorkloadGroupMappingStmt AlterAppWorkloadGroupMappingStmt DropAppWorkloadGroupMappingStmt MergeStmt PurgeStmt CreateMatViewStmt RefreshMatViewStmt CreateWeakPasswordDictionaryStmt DropWeakPasswordDictionaryStmt - CreatePublicationStmt AlterPublicationStmt - CreateSubscriptionStmt AlterSubscriptionStmt DropSubscriptionStmt + CreatePublicationStmt AlterPublicationStmt + CreateSubscriptionStmt AlterSubscriptionStmt DropSubscriptionStmt /* */ /* SNAPSHOTS */ @@ -988,7 +988,7 @@ stmt : | AlterForeignTableStmt | AlterFunctionStmt | AlterProcedureStmt - | AlterPublicationStmt + | AlterPublicationStmt | AlterGroupStmt | AlterNodeGroupStmt | AlterNodeStmt @@ -998,7 +998,7 @@ stmt : | AlterResourcePoolStmt | AlterSeqStmt | AlterSchemaStmt - | AlterSubscriptionStmt + | AlterSubscriptionStmt | AlterTableStmt | AlterSystemStmt | AlterCompositeTypeStmt @@ -1050,7 +1050,7 @@ stmt : | CreateRlsPolicyStmt | CreatePLangStmt | CreateProcedureStmt - | CreatePublicationStmt + | CreatePublicationStmt | CreateKeyStmt | CreatePolicyLabelStmt | CreateWeakPasswordDictionaryStmt @@ -1067,7 +1067,7 @@ stmt : | CreateSchemaStmt | CreateSeqStmt | CreateStmt - | CreateSubscriptionStmt + | CreateSubscriptionStmt | CreateSynonymStmt | CreateTableSpaceStmt | CreateTrigStmt @@ -1101,7 +1101,7 @@ stmt : | DropResourcePoolStmt | DropRuleStmt | DropStmt - | DropSubscriptionStmt + | DropSubscriptionStmt | DropSynonymStmt | DropTableSpaceStmt | DropTrigStmt @@ -13278,7 +13278,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId n->newowner = $6; $$ = (Node *)n; } - | ALTER PUBLICATION name OWNER TO RoleId + | ALTER PUBLICATION name OWNER TO RoleId { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); n->objectType = OBJECT_PUBLICATION; @@ -21863,7 +21863,7 @@ unreserved_keyword: | PRIVILEGES | PROCEDURAL | PROFILE - | PUBLICATION + | PUBLICATION | PUBLISH | PURGE | QUERY diff --git a/src/common/backend/utils/cache/syscache.cpp b/src/common/backend/utils/cache/syscache.cpp index ecc51b426..08d898e16 100644 --- a/src/common/backend/utils/cache/syscache.cpp +++ b/src/common/backend/utils/cache/syscache.cpp @@ -878,6 +878,11 @@ void InitCatalogCachePhase2(void) Assert(u_sess->syscache_cxt.CacheInitialized); for (cacheId = 0; cacheId < SysCacheSize; cacheId++) { + /* + * We create pg_subscription in upgrade-post script, cause the relmap is full(check apply_map_update), + * and pg_subscription is a shared relation. When we do upgrade, before commit, we can't init cache for + * pg_subscription, cause the pg_subscription is not created yet. + */ if (t_thrd.proc->workingVersionNum < PUBLICATION_VERSION_NUM && (cacheId == SUBSCRIPTIONNAME || cacheId == SUBSCRIPTIONOID)) { continue; diff --git a/src/gausskernel/storage/replication/logical/origin.cpp b/src/gausskernel/storage/replication/logical/origin.cpp index e435d26ee..36da812b1 100644 --- a/src/gausskernel/storage/replication/logical/origin.cpp +++ b/src/gausskernel/storage/replication/logical/origin.cpp @@ -498,7 +498,7 @@ void CheckPointReplicationOrigin(void) if (unlikely(stat("pg_logical", &st) != 0)) { /* maybe other threads have created this directory, so check the errno again */ - if ((0 != mkdir("pg_logical", S_IRWXU)) && (errno != EEXIST)) { + if ((mkdir("pg_logical", S_IRWXU) != 0) && (errno != EEXIST)) { ereport(PANIC, (errcode_for_file_access(), errmsg("could not create directory \"pg_logical\": %m"))); } } diff --git a/src/include/catalog/pg_publication_namespace.h b/src/include/catalog/pg_publication_namespace.h deleted file mode 100644 index 8dfe3a922..000000000 --- a/src/include/catalog/pg_publication_namespace.h +++ /dev/null @@ -1,47 +0,0 @@ -/*------------------------------------------------------------------------- - * - * pg_publication_namespace.h - * definition of the system catalog for mappings between schemas and - * publications (pg_publication_namespace) - * - * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * src/include/catalog/pg_publication_namespace.h - * - * NOTES - * The Catalog.pm module reads this file and derives schema - * information. - * - *------------------------------------------------------------------------- - */ -#ifndef PG_PUBLICATION_NAMESPACE_H -#define PG_PUBLICATION_NAMESPACE_H - -#include "catalog/genbki.h" -// #include "catalog/pg_publication_namespace_d.h" - - -/* ---------------- - * pg_publication_namespace definition. cpp turns this into - * typedef struct FormData_pg_publication_namespace - * ---------------- - */ -CATALOG(pg_publication_namespace,8901,PublicationNamespaceRelationId) -{ - Oid oid; /* oid */ - Oid pnpubid BKI_LOOKUP(pg_publication); /* Oid of the publication */ - Oid pnnspid BKI_LOOKUP(pg_namespace); /* Oid of the schema */ -} FormData_pg_publication_namespace; - -/* ---------------- - * Form_pg_publication_namespace corresponds to a pointer to a tuple with - * the format of pg_publication_namespace relation. - * ---------------- - */ -typedef FormData_pg_publication_namespace *Form_pg_publication_namespace; - -DECLARE_UNIQUE_INDEX_PKEY(pg_publication_namespace_oid_index, 8902, PublicationNamespaceObjectIndexId, on pg_publication_namespace using btree(oid oid_ops)); -DECLARE_UNIQUE_INDEX(pg_publication_namespace_pnnspid_pnpubid_index, 8903, PublicationNamespacePnnspidPnpubidIndexId, on pg_publication_namespace using btree(pnnspid oid_ops, pnpubid oid_ops)); - -#endif /* PG_PUBLICATION_NAMESPACE_H */ diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index f68931322..226e7428e 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -272,8 +272,8 @@ typedef enum AclObjectKind { ACL_KIND_COLUMN_SETTING, /* column setting */ ACL_KIND_GLOBAL_SETTING, /* master client key */ ACL_KIND_PACKAGE, /* pg_package */ - ACL_KIND_PUBLICATION, /* pg_publication */ - ACL_KIND_SUBSCRIPTION, /* pg_subscription */ + ACL_KIND_PUBLICATION, /* pg_publication */ + ACL_KIND_SUBSCRIPTION, /* pg_subscription */ MAX_ACL_KIND /* MUST BE LAST */ } AclObjectKind;