diff --git a/src/common/backend/catalog/Makefile b/src/common/backend/catalog/Makefile index edd16c09099473452d0c6c663bd9c390d0903ed9..2f833600ae67e749e884be24d306475d31734777 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 a202f72c68be84e755c03e0e64f268b7b68aaa30..e08907e8815658142d890a8f4331df1870d73f43 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 bbff51b44ff9c3c005e7faf759dc35c91d231813..a752e50f864468bb7ec514a3e815a55ca4e688a7 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 0c8295d705560d6f194d65b7a3b88b349bc69904..f1b3ae5fc542e9c1a69df706cb227fe5a400a8fe 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 9d4678414cded2d74e8b28fc60fd2f1ee6301a73..cf2988c958ec1f156bdd7c32c14ee17c02a62e28 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 0000000000000000000000000000000000000000..4784037faf6b8bfac00eb626b9ad40d477487285 --- /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 0000000000000000000000000000000000000000..8404f0ff899687846f99491b2d1424dc58387ab2 --- /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 0000000000000000000000000000000000000000..8404f0ff899687846f99491b2d1424dc58387ab2 --- /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 0000000000000000000000000000000000000000..0ec2b89af60c2db1c4c48c07c5ab703c91b334b1 --- /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 0000000000000000000000000000000000000000..0ec2b89af60c2db1c4c48c07c5ab703c91b334b1 --- /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 a1ea2e7be0c5719d25bff291d3f7bdab7dd8628d..fbce95cc690e044196c694fa13b8550d39a4d64b 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,