From 42c8f42a15158730936b8f836c374689fabd4488 Mon Sep 17 00:00:00 2001 From: not-enter Date: Sun, 18 Dec 2022 14:36:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=8D=87=E7=BA=A7=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=B3=BB=E7=BB=9F=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/catalog/Makefile | 4 ++-- src/common/backend/utils/cache/relcache.cpp | 11 +++++++++ src/common/backend/utils/cache/syscache.cpp | 11 +++++++++ src/include/catalog/catversion.h | 2 +- src/include/catalog/indexing.h | 5 ++++ src/include/catalog/pg_ogmac_seclabel.h | 24 +++++++++++++++++++ .../rollback_catalog_maindb_92_781.sql | 4 ++++ .../rollback_catalog_otherdb_92_781.sql | 4 ++++ .../upgrade_catalog_maindb_92_781.sql | 13 ++++++++++ .../upgrade_catalog_otherdb_92_781.sql | 13 ++++++++++ src/include/utils/syscache.h | 2 ++ 11 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/include/catalog/pg_ogmac_seclabel.h create mode 100644 src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_781.sql create mode 100644 src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_781.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_781.sql create mode 100644 src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_781.sql diff --git a/src/common/backend/catalog/Makefile b/src/common/backend/catalog/Makefile index edd16c0909..2f833600ae 100644 --- a/src/common/backend/catalog/Makefile +++ b/src/common/backend/catalog/Makefile @@ -55,7 +55,7 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\ gs_masking_policy.h gs_masking_policy_actions.h gs_masking_policy_filters.h \ gs_encrypted_columns.h gs_column_keys.h gs_column_keys_args.h \ gs_client_global_keys.h gs_client_global_keys_args.h gs_encrypted_proc.h\ - pg_job.h gs_asp.h pg_job_proc.h pg_extension_data_source.h pg_statistic_ext.h pg_object.h pg_synonym.h \ + pg_job.h gs_asp.h pg_job_proc.h pg_extension_data_source.h pg_statistic_ext.h pg_object.h pg_ogmac_seclabel.h pg_synonym.h \ toasting.h indexing.h gs_obsscaninfo.h pg_directory.h pg_hashbucket.h gs_global_chain.h gs_global_config.h\ pg_streaming_stream.h pg_streaming_cont_query.h pg_streaming_reaper_status.h gs_matview.h\ gs_matview_dependency.h pgxc_slice.h gs_opt_model.h gs_model.h\ @@ -103,7 +103,7 @@ install-data: $(BKIFILES) installdirs $(INSTALL_DATA) $(call vpathsearch,postgres.bki) '$(DESTDIR)$(datadir)/postgres.bki' $(INSTALL_DATA) $(call vpathsearch,postgres.description) '$(DESTDIR)$(datadir)/postgres.description' $(INSTALL_DATA) $(call vpathsearch,postgres.shdescription) '$(DESTDIR)$(datadir)/postgres.shdescription' - $(INSTALL_DATA) $(srcdir)/../../../../../privategauss/kernel/catalog/private_system_views.sql '$(DESTDIR)$(datadir)/private_system_views.sql' + $(INSTALL_DATA) $(srcdir)/../../../../../privategauss/kernel/catalog/private_system_views.sql '$(DESTDIR)$(datadir)/private_system_views.sql' $(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql' $(INSTALL_DATA) $(srcdir)/performance_views.sql '$(DESTDIR)$(datadir)/performance_views.sql' $(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql' diff --git a/src/common/backend/utils/cache/relcache.cpp b/src/common/backend/utils/cache/relcache.cpp index a202f72c68..e08907e881 100644 --- a/src/common/backend/utils/cache/relcache.cpp +++ b/src/common/backend/utils/cache/relcache.cpp @@ -84,6 +84,7 @@ #include "catalog/pg_largeobject_metadata.h" #include "catalog/pg_namespace.h" #include "catalog/pg_object.h" +#include "catalog/pg_ogmac_seclabel.h" #include "catalog/pg_opclass.h" #include "catalog/pg_operator.h" #include "catalog/pg_opfamily.h" @@ -290,6 +291,7 @@ static const FormData_pg_attribute Desc_pg_extension_data_source[Natts_pg_extens Schema_pg_extension_data_source}; static const FormData_pg_attribute Desc_pg_directory[Natts_pg_directory] = {Schema_pg_directory}; static const FormData_pg_attribute Desc_pg_obsscaninfo[Natts_pg_obsscaninfo] = {Schema_pg_obsscaninfo}; +static const FormData_pg_attribute Desc_pg_ogmac_seclabel[Natts_pg_ogmac_seclabel] = {Schema_pg_ogmac_seclabel}; static const FormData_pg_attribute Desc_pgxc_class[Natts_pgxc_class] = {Schema_pgxc_class}; static const FormData_pg_attribute Desc_pgxc_group[Natts_pgxc_group] = {Schema_pgxc_group}; static const FormData_pg_attribute Desc_pgxc_node[Natts_pgxc_node] = {Schema_pgxc_node}; @@ -765,6 +767,15 @@ static struct CatalogRelationBuildParam catalogBuildParam[CATALOG_NUM] = {{Defau Desc_pg_shseclabel, false, true}, + {SecurityLabelRelationId, + "pg_ogmac_seclabel", + SecurityLabel_Rowtype_Id, + false, + false, + Natts_pg_ogmac_seclabel, + Desc_pg_ogmac_seclabel, + false, + true}, {SecLabelRelationId, "pg_seclabel", SecLabelRelation_Rowtype_Id, diff --git a/src/common/backend/utils/cache/syscache.cpp b/src/common/backend/utils/cache/syscache.cpp index bbff51b44f..a752e50f86 100644 --- a/src/common/backend/utils/cache/syscache.cpp +++ b/src/common/backend/utils/cache/syscache.cpp @@ -110,6 +110,7 @@ #include "catalog/pg_publication_rel.h" #include "catalog/pg_replication_origin.h" #include "catalog/pg_subscription_rel.h" +#include "catalog/pg_ogmac_seclabel.h" /* --------------------------------------------------------------------------- @@ -608,6 +609,16 @@ const cachedesc cacheinfo[] = { 2, {Anum_pg_rewrite_ev_class, Anum_pg_rewrite_rulename, 0, 0}, 1024}, + {SecurityLabelRelationId, /* SECURITYLABELNAME */ + SecurityLabelNameIndexId, + 1, + {Anum_pg_ogmac_seclabel_label_name, 0, 0, 0}, + 4}, + {SecurityLabelRelationId, /* SECURITYLABOID */ + SecurityLabelOidIndexId, + 1, + {ObjectIdAttributeNumber, 0, 0, 0}, + 4}, {StatisticRelationId, /* STATRELKINDATTINH (For pg_statistic single-column stats) */ StatisticRelidKindAttnumInhIndexId, 4, diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 0c8295d705..f1b3ae5fc5 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -62,6 +62,6 @@ #define NAILED_IN_CATALOG_NUM 8 -#define CATALOG_NUM 107 +#define CATALOG_NUM 108 #endif diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 9d4678414c..cf2988c958 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -238,6 +238,11 @@ DECLARE_INDEX(pg_proc_proname_all_args_nsp_index, 9666, on pg_proc using btree(p DECLARE_INDEX(pg_proc_proname_args_nsp_new_index, 9378, on pg_proc using btree(proname name_ops, proargtypes oidvector_ops, pronamespace oid_ops, propackageid oid_ops)); #define ProcedureNameArgsNspNewIndexId 9378 +DECLARE_UNIQUE_INDEX(pg_security_label_name_index, 6146, on pg_ogmac_seclabel using btree(label_name name_ops)); +#define SecurityLabelNameIndexId 6146 +DECLARE_UNIQUE_INDEX(pg_security_label_oid_index, 6147, on pg_ogmac_seclabel using btree(oid oid_ops)); +#define SecurityLabelOidIndexId 6147 + DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index, 2692, on pg_rewrite using btree(oid oid_ops)); #define RewriteOidIndexId 2692 DECLARE_UNIQUE_INDEX(pg_rewrite_rel_rulename_index, 2693, on pg_rewrite using btree(ev_class oid_ops, rulename name_ops)); diff --git a/src/include/catalog/pg_ogmac_seclabel.h b/src/include/catalog/pg_ogmac_seclabel.h new file mode 100644 index 0000000000..4784037faf --- /dev/null +++ b/src/include/catalog/pg_ogmac_seclabel.h @@ -0,0 +1,24 @@ +#ifndef PG_OGMAC_SECLABEL_H +#define PG_OGMAC_SECLABEL_H +#include "postgres.h" +#include "catalog/genbki.h" + +#define SecurityLabelRelationId 6144 +#define SecurityLabel_Rowtype_Id 6145 +#define Natts_pg_ogmac_seclabel 3 + +CATALOG(pg_ogmac_seclabel,6144) BKI_SCHEMA_MACRO +{ + NameData label_name; + int8 label_flag; +#ifdef CATALOG_VARLEN + text label_content; +#endif +} FormData_pg_ogmac_seclabel; +typedef FormData_pg_ogmac_seclabel *Form_pg_ogmac_seclabel; + +#define Anum_pg_ogmac_seclabel_label_name 1 +#define Anum_pg_ogmac_seclabel_label_flag 2 +#define Anum_pg_ogmac_seclabel_label_content 3 + +#endif diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_781.sql b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_781.sql new file mode 100644 index 0000000000..8404f0ff89 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_maindb/rollback_catalog_maindb_92_781.sql @@ -0,0 +1,4 @@ +DROP INDEX IF EXISTS pg_security_label_name_index; +DROP INDEX IF EXISTS pg_security_label_oid_index; + +DROP TABLE IF EXISTS pg_catalog.pg_ogmac_seclabel; diff --git a/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_781.sql b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_781.sql new file mode 100644 index 0000000000..8404f0ff89 --- /dev/null +++ b/src/include/catalog/upgrade_sql/rollback_catalog_otherdb/rollback_catalog_otherdb_92_781.sql @@ -0,0 +1,4 @@ +DROP INDEX IF EXISTS pg_security_label_name_index; +DROP INDEX IF EXISTS pg_security_label_oid_index; + +DROP TABLE IF EXISTS pg_catalog.pg_ogmac_seclabel; diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_781.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_781.sql new file mode 100644 index 0000000000..0ec2b89af6 --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_maindb/upgrade_catalog_maindb_92_781.sql @@ -0,0 +1,13 @@ +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6144, 6145, 0, 0; +CREATE TABLE IF NOT EXISTS pg_catalog.pg_ogmac_seclabel +( + label_name name NOT NULL, + label_flag bigint NOT NULL, + label_content text +)WITH OIDS; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6146; +CREATE UNIQUE INDEX pg_security_label_name_index ON pg_ogmac_seclabel USING btree(label_name name_ops); + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6147; +CREATE UNIQUE INDEX pg_security_label_oid_index ON pg_ogmac_seclabel USING btree(oid oid_ops); diff --git a/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_781.sql b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_781.sql new file mode 100644 index 0000000000..0ec2b89af6 --- /dev/null +++ b/src/include/catalog/upgrade_sql/upgrade_catalog_otherdb/upgrade_catalog_otherdb_92_781.sql @@ -0,0 +1,13 @@ +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 6144, 6145, 0, 0; +CREATE TABLE IF NOT EXISTS pg_catalog.pg_ogmac_seclabel +( + label_name name NOT NULL, + label_flag bigint NOT NULL, + label_content text +)WITH OIDS; + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6146; +CREATE UNIQUE INDEX pg_security_label_name_index ON pg_ogmac_seclabel USING btree(label_name name_ops); + +SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 6147; +CREATE UNIQUE INDEX pg_security_label_oid_index ON pg_ogmac_seclabel USING btree(oid oid_ops); diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index a1ea2e7be0..fbce95cc69 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -122,6 +122,8 @@ enum SysCacheIdentifier { RELNAMENSP, RELOID, RULERELNAME, + SECURITYLABELNAME, + SECURITYLABELOID, STATRELKINDATTINH, /* single column statistics */ STATRELKINDKEYINH, /* multi column statistics */ STREAMCQDEFRELID, -- Gitee