This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 1562a7f97ca Refactor SystemSchemaBuilderRule. (#30358)
1562a7f97ca is described below
commit 1562a7f97ca330cd6cf013ee7f9a4680493f9409
Author: Cong Hu <[email protected]>
AuthorDate: Mon Mar 4 16:27:05 2024 +0800
Refactor SystemSchemaBuilderRule. (#30358)
* Refactor SystemSchemaBuilderRule.
* Fix the code problem proposed in code review.
* Move shardingsphere system schema resources to infra database core.
---
.../from/impl/SimpleTableSegmentBinder.java | 4 +-
.../schema/builder/SystemSchemaBuilder.java | 19 +-
.../schema/builder/SystemSchemaBuilderRule.java | 250 ---------------------
.../schema/builder/SystemSchemaMetadata.java | 149 ++++++++++++
.../builder/SystemSchemaBuilderRuleTest.java | 105 ---------
.../schema/builder/SystemSchemaMetadataTest.java | 88 ++++++++
.../shardingsphere/cluster_information.yaml | 0
.../shardingsphere/sharding_table_statistics.yaml | 0
.../shardingsphere/cluster_information.yaml | 27 ---
.../shardingsphere/sharding_table_statistics.yaml | 69 ------
.../shardingsphere/cluster_information.yaml | 27 ---
.../shardingsphere/sharding_table_statistics.yaml | 69 ------
.../metadata/watcher/MetaDataChangedWatcher.java | 16 +-
.../MySQLInformationSchemaExecutorFactory.java | 4 +-
.../admin/MySQLMySQLSchemaExecutorFactory.java | 4 +-
.../MySQLPerformanceSchemaExecutorFactory.java | 4 +-
.../admin/MySQLSysSchemaExecutorFactory.java | 4 +-
.../admin/OpenGaussAdminExecutorCreator.java | 6 +-
.../admin/PostgreSQLAdminExecutorCreator.java | 6 +-
19 files changed, 263 insertions(+), 588 deletions(-)
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/from/impl/SimpleTableSegmentBinder.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/from/impl/SimpleTableSegmentBinder.java
index e0c945b2051..5a6738feb02 100644
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/from/impl/SimpleTableSegmentBinder.java
+++
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/from/impl/SimpleTableSegmentBinder.java
@@ -30,7 +30,7 @@ import
org.apache.shardingsphere.infra.database.postgresql.type.PostgreSQLDataba
import org.apache.shardingsphere.infra.exception.TableNotExistsException;
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
@@ -139,7 +139,7 @@ public final class SimpleTableSegmentBinder {
if ("dual".equalsIgnoreCase(tableName)) {
return;
}
- if (SystemSchemaBuilderRule.isSystemTable(schemaName, tableName)) {
+ if (SystemSchemaMetadata.isSystemTable(schemaName, tableName)) {
return;
}
ShardingSpherePreconditions.checkState(statementBinderContext.getMetaData().containsDatabase(databaseName)
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
index ac98511e526..1a80efdb542 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilder.java
@@ -35,9 +35,7 @@ import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.Map;
-import java.util.Optional;
import java.util.Properties;
/**
@@ -48,7 +46,7 @@ public final class SystemSchemaBuilder {
/**
* Build system schema.
- *
+ *
* @param databaseName database name
* @param databaseType database type
* @param props configuration properties
@@ -60,7 +58,7 @@ public final class SystemSchemaBuilder {
boolean isSystemSchemaMetaDataEnabled =
isSystemSchemaMetaDataEnabled(props.getProps());
YamlTableSwapper swapper = new YamlTableSwapper();
for (String each : getSystemSchemas(databaseName, databaseType,
systemDatabase)) {
- result.put(each.toLowerCase(), createSchema(each,
getSchemaStreams(each, databaseType), swapper, isSystemSchemaMetaDataEnabled));
+ result.put(each.toLowerCase(), createSchema(each,
SystemSchemaMetadata.getSchemaStreams(databaseType.getType(), each), swapper,
isSystemSchemaMetaDataEnabled));
}
return result;
}
@@ -76,19 +74,6 @@ public final class SystemSchemaBuilder {
return
systemDatabase.getSystemDatabaseSchemaMap().getOrDefault(databaseName,
Collections.emptyList());
}
- private static Collection<InputStream> getSchemaStreams(final String
schemaName, final DatabaseType databaseType) {
- Optional<SystemSchemaBuilderRule> builderRuleOptional =
SystemSchemaBuilderRule.findBuilderRule(databaseType.getType(), schemaName);
- if (!builderRuleOptional.isPresent()) {
- return Collections.emptyList();
- }
- SystemSchemaBuilderRule builderRule = builderRuleOptional.get();
- Collection<InputStream> result = new LinkedList<>();
- for (String each : builderRule.getTables()) {
-
result.add(SystemSchemaBuilder.class.getClassLoader().getResourceAsStream("schema/"
+ databaseType.getType().toLowerCase() + "/" + schemaName + "/" + each +
".yaml"));
- }
- return result;
- }
-
private static ShardingSphereSchema createSchema(final String schemaName,
final Collection<InputStream> schemaStreams, final YamlTableSwapper swapper,
final boolean
isSystemSchemaMetadataEnabled) {
Map<String, ShardingSphereTable> tables = new
LinkedHashMap<>(schemaStreams.size(), 1F);
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
deleted file mode 100644
index 11055c7435b..00000000000
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.metadata.database.schema.builder;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * System schema builder rule.
- */
-@RequiredArgsConstructor
-@Getter
-public enum SystemSchemaBuilderRule {
-
- MYSQL_INFORMATION_SCHEMA("MySQL", "information_schema", new
HashSet<>(Arrays.asList("character_sets",
"collation_character_set_applicability", "collations", "column_privileges",
"columns",
- "engines", "events", "files", "global_status", "global_variables",
- "innodb_buffer_page", "innodb_buffer_page_lru",
"innodb_buffer_pool_stats", "innodb_cmp", "innodb_cmp_per_index",
"innodb_cmp_per_index_reset", "innodb_cmp_reset",
- "innodb_cmpmem", "innodb_cmpmem_reset", "innodb_ft_being_deleted",
- "innodb_ft_config", "innodb_ft_default_stopword",
"innodb_ft_deleted", "innodb_ft_index_cache", "innodb_ft_index_table",
"innodb_lock_waits", "innodb_locks",
- "innodb_metrics", "innodb_sys_columns", "innodb_sys_datafiles",
- "innodb_sys_fields", "innodb_sys_foreign",
"innodb_sys_foreign_cols", "innodb_sys_indexes", "innodb_sys_tables",
"innodb_sys_tablespaces",
- "innodb_sys_tablestats", "innodb_sys_virtual",
"innodb_temp_table_info", "innodb_trx", "key_column_usage", "optimizer_trace",
"parameters", "partitions", "plugins",
- "processlist", "profiling", "referential_constraints", "routines",
"schema_privileges", "schemata", "session_status", "session_variables",
"statistics",
- "table_constraints", "table_privileges", "tables", "tablespaces",
"triggers", "user_privileges", "views"))),
-
- MYSQL_MYSQL("MySQL", "mysql", new HashSet<>(Arrays.asList("columns_priv",
"db", "engine_cost", "event", "func", "general_log", "gtid_executed",
- "help_category", "help_keyword", "help_relation",
- "help_topic", "innodb_index_stats", "innodb_table_stats",
"ndb_binlog_index", "plugin", "proc", "procs_priv", "proxies_priv",
"server_cost", "servers",
- "slave_master_info", "slave_relay_log_info", "slave_worker_info",
"slow_log", "tables_priv", "time_zone", "time_zone_leap_second",
- "time_zone_name", "time_zone_transition",
"time_zone_transition_type", "user"))),
-
- MYSQL_PERFORMANCE_SCHEMA("MySQL", "performance_schema", new
HashSet<>(Arrays.asList("accounts", "cond_instances", "events_stages_current",
"events_stages_history", "events_stages_history_long",
- "events_stages_summary_by_account_by_event_name",
"events_stages_summary_by_host_by_event_name",
"events_stages_summary_by_thread_by_event_name",
- "events_stages_summary_by_user_by_event_name",
"events_stages_summary_global_by_event_name", "events_statements_current",
"events_statements_history", "events_statements_history_long",
- "events_statements_summary_by_account_by_event_name",
"events_statements_summary_by_digest",
"events_statements_summary_by_host_by_event_name",
"events_statements_summary_by_program",
- "events_statements_summary_by_thread_by_event_name",
"events_statements_summary_by_user_by_event_name",
"events_statements_summary_global_by_event_name",
- "events_transactions_current", "events_transactions_history",
"events_transactions_history_long",
"events_transactions_summary_by_account_by_event_name",
- "events_transactions_summary_by_host_by_event_name",
"events_transactions_summary_by_thread_by_event_name",
"events_transactions_summary_by_user_by_event_name",
- "events_transactions_summary_global_by_event_name",
"events_waits_current", "events_waits_history", "events_waits_history_long",
"events_waits_summary_by_account_by_event_name",
- "events_waits_summary_by_host_by_event_name",
"events_waits_summary_by_instance",
"events_waits_summary_by_thread_by_event_name",
"events_waits_summary_by_user_by_event_name",
- "events_waits_summary_global_by_event_name", "file_instances",
"file_summary_by_event_name", "file_summary_by_instance", "global_status",
"global_variables", "host_cache", "hosts",
- "memory_summary_by_account_by_event_name",
"memory_summary_by_host_by_event_name",
"memory_summary_by_thread_by_event_name",
"memory_summary_by_user_by_event_name",
- "memory_summary_global_by_event_name", "metadata_locks",
"mutex_instances", "objects_summary_global_by_type", "performance_timers",
"prepared_statements_instances",
- "replication_applier_configuration", "replication_applier_status",
"replication_applier_status_by_coordinator",
"replication_applier_status_by_worker",
- "replication_connection_configuration",
"replication_connection_status", "replication_group_member_stats",
"replication_group_members", "rwlock_instances",
"session_account_connect_attrs",
- "session_connect_attrs", "session_status", "session_variables",
"setup_actors", "setup_consumers", "setup_instruments", "setup_objects",
"setup_timers", "socket_instances",
- "socket_summary_by_event_name", "socket_summary_by_instance",
"status_by_account", "status_by_host", "status_by_thread", "status_by_user",
"table_handles",
- "table_io_waits_summary_by_index_usage",
"table_io_waits_summary_by_table", "table_lock_waits_summary_by_table",
"threads", "user_variables_by_thread", "users", "variables_by_thread"))),
-
- MYSQL_SYS("MySQL", "sys",
- new HashSet<>(Arrays.asList("host_summary",
"host_summary_by_file_io", "host_summary_by_file_io_type",
"host_summary_by_stages", "host_summary_by_statement_latency",
- "host_summary_by_statement_type",
"innodb_buffer_stats_by_schema", "innodb_buffer_stats_by_table",
"innodb_lock_waits",
- "io_by_thread_by_latency", "io_global_by_file_by_bytes",
"io_global_by_file_by_latency", "io_global_by_wait_by_bytes",
"io_global_by_wait_by_latency", "latest_file_io",
- "memory_by_host_by_current_bytes",
"memory_by_thread_by_current_bytes", "memory_by_user_by_current_bytes",
- "memory_global_by_current_bytes", "memory_global_total",
"metrics", "processlist", "ps_check_lost_instrumentation",
"schema_auto_increment_columns", "schema_index_statistics",
- "schema_object_overview", "schema_redundant_indexes",
- "schema_table_lock_waits", "schema_table_statistics",
"schema_table_statistics_with_buffer", "schema_tables_with_full_table_scans",
"schema_unused_indexes", "session",
- "session_ssl_status", "statement_analysis",
"statements_with_errors_or_warnings",
- "statements_with_full_table_scans",
"statements_with_runtimes_in_95th_percentile", "statements_with_sorting",
"statements_with_temp_tables", "sys_config", "user_summary",
- "user_summary_by_file_io", "user_summary_by_file_io_type",
"user_summary_by_stages",
- "user_summary_by_statement_latency",
"user_summary_by_statement_type", "version",
"wait_classes_global_by_avg_latency", "wait_classes_global_by_latency",
- "waits_by_host_by_latency", "waits_by_user_by_latency",
"waits_global_by_latency"))),
-
- MYSQL_SHARDING_SPHERE("MySQL", "shardingsphere", new
HashSet<>(Arrays.asList("sharding_table_statistics", "cluster_information"))),
-
- POSTGRESQL_INFORMATION_SCHEMA("PostgreSQL", "information_schema",
- new HashSet<>(Arrays.asList("_pg_foreign_data_wrappers",
"_pg_foreign_servers", "_pg_foreign_table_columns", "_pg_foreign_tables",
"_pg_user_mappings", "administrable_role_authorizations",
- "applicable_roles", "attributes", "character_sets",
- "check_constraint_routine_usage", "check_constraints",
"collation_character_set_applicability", "collations", "column_column_usage",
"column_domain_usage", "column_options",
- "column_privileges", "column_udt_usage",
- "columns", "constraint_column_usage",
"constraint_table_usage", "data_type_privileges", "domain_constraints",
"domain_udt_usage", "domains", "element_types", "enabled_roles",
- "foreign_data_wrapper_options", "foreign_data_wrappers",
"foreign_server_options", "foreign_servers", "foreign_table_options",
"foreign_tables", "information_schema_catalog_name",
- "key_column_usage", "parameters",
- "referential_constraints", "role_column_grants",
"role_routine_grants", "role_table_grants", "role_udt_grants",
"role_usage_grants", "routine_column_usage", "routine_privileges",
- "routine_routine_usage",
- "routine_sequence_usage", "routine_table_usage",
"routines", "schemata", "sequences", "sql_features", "sql_implementation_info",
"sql_parts", "sql_sizing",
- "table_constraints", "table_privileges", "tables",
"transforms", "triggered_update_columns", "triggers", "udt_privileges",
"usage_privileges", "user_defined_types",
- "user_mapping_options", "user_mappings",
"view_column_usage", "view_routine_usage", "view_table_usage", "views"))),
-
- POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog",
- new HashSet<>(Arrays.asList("pg_aggregate", "pg_am", "pg_amop",
"pg_amproc", "pg_attrdef", "pg_attribute", "pg_auth_members", "pg_authid",
"pg_available_extension_versions",
- "pg_available_extensions", "pg_backend_memory_contexts",
"pg_cast", "pg_class", "pg_collation", "pg_config", "pg_constraint",
"pg_conversion", "pg_cursors",
- "pg_database", "pg_db_role_setting", "pg_default_acl",
"pg_depend", "pg_description", "pg_enum", "pg_event_trigger", "pg_extension",
"pg_file_settings",
- "pg_foreign_data_wrapper", "pg_foreign_server",
"pg_foreign_table", "pg_group", "pg_hba_file_rules", "pg_index", "pg_indexes",
"pg_inherits", "pg_init_privs",
- "pg_language", "pg_largeobject",
"pg_largeobject_metadata", "pg_locks", "pg_matviews", "pg_namespace",
"pg_opclass", "pg_operator", "pg_opfamily",
- "pg_partitioned_table", "pg_policies", "pg_policy",
"pg_prepared_statements", "pg_prepared_xacts", "pg_proc", "pg_publication",
"pg_publication_rel", "pg_publication_tables",
- "pg_range", "pg_replication_origin",
"pg_replication_origin_status", "pg_replication_slots", "pg_rewrite",
"pg_roles", "pg_rules", "pg_seclabel", "pg_seclabels",
- "pg_sequence", "pg_sequences", "pg_settings", "pg_shadow",
"pg_shdepend", "pg_shdescription", "pg_shmem_allocations", "pg_shseclabel",
"pg_stat_activity",
- "pg_stat_all_indexes", "pg_stat_all_tables",
"pg_stat_archiver", "pg_stat_bgwriter", "pg_stat_database",
"pg_stat_database_conflicts", "pg_stat_gssapi", "pg_stat_progress_analyze",
- "pg_stat_progress_basebackup",
- "pg_stat_progress_cluster", "pg_stat_progress_copy",
"pg_stat_progress_create_index", "pg_stat_progress_vacuum",
"pg_stat_replication", "pg_stat_replication_slots", "pg_stat_slru",
- "pg_stat_ssl", "pg_stat_subscription",
- "pg_stat_sys_indexes", "pg_stat_sys_tables",
"pg_stat_user_functions", "pg_stat_user_indexes", "pg_stat_user_tables",
"pg_stat_wal", "pg_stat_wal_receiver",
- "pg_stat_xact_all_tables", "pg_stat_xact_sys_tables",
- "pg_stat_xact_user_functions", "pg_stat_xact_user_tables",
"pg_statio_all_indexes", "pg_statio_all_sequences", "pg_statio_all_tables",
"pg_statio_sys_indexes",
- "pg_statio_sys_sequences", "pg_statio_sys_tables",
"pg_statio_user_indexes",
- "pg_statio_user_sequences", "pg_statio_user_tables",
"pg_statistic", "pg_statistic_ext", "pg_statistic_ext_data", "pg_stats",
"pg_stats_ext", "pg_stats_ext_exprs",
- "pg_subscription",
- "pg_subscription_rel", "pg_tables", "pg_tablespace",
"pg_timezone_abbrevs", "pg_timezone_names", "pg_transform", "pg_trigger",
"pg_ts_config", "pg_ts_config_map",
- "pg_ts_dict", "pg_ts_parser", "pg_ts_template", "pg_type",
"pg_user", "pg_user_mapping", "pg_user_mappings", "pg_views"))),
-
- POSTGRESQL_SHARDING_SPHERE("PostgreSQL", "shardingsphere", new
HashSet<>(Arrays.asList("sharding_table_statistics", "cluster_information"))),
-
- OPEN_GAUSS_INFORMATION_SCHEMA("openGauss", "information_schema",
- new HashSet<>(Arrays.asList("_pg_foreign_data_wrappers",
"_pg_foreign_servers", "_pg_foreign_table_columns", "_pg_foreign_tables",
"_pg_user_mappings", "administrable_role_authorizations",
- "applicable_roles", "attributes", "character_sets",
- "check_constraint_routine_usage", "check_constraints",
"collation_character_set_applicability", "collations", "column_domain_usage",
"column_options", "column_privileges",
- "column_udt_usage", "columns",
- "constraint_column_usage", "constraint_table_usage",
"data_type_privileges", "domain_constraints", "domain_udt_usage", "domains",
"element_types", "enabled_roles",
- "foreign_data_wrapper_options",
- "foreign_data_wrappers", "foreign_server_options",
"foreign_servers", "foreign_table_options", "foreign_tables",
"information_schema_catalog_name", "key_column_usage",
- "parameters", "referential_constraints",
- "role_column_grants", "role_routine_grants",
"role_table_grants", "role_udt_grants", "role_usage_grants",
"routine_privileges", "routines", "schemata", "sequences",
- "sql_features", "sql_implementation_info",
"sql_languages", "sql_packages", "sql_parts", "sql_sizing",
"sql_sizing_profiles", "table_constraints", "table_privileges",
- "tables", "triggered_update_columns", "triggers",
"udt_privileges", "usage_privileges", "user_defined_types",
"user_mapping_options", "user_mappings", "view_column_usage",
- "view_routine_usage", "view_table_usage", "views"))),
-
- OPEN_GAUSS_PG_CATALOG("openGauss", "pg_catalog", new
HashSet<>(Arrays.asList("get_global_prepared_xacts",
"gs_all_control_group_info", "gs_asp", "gs_auditing", "gs_auditing_access",
- "gs_auditing_policy", "gs_auditing_policy_access",
"gs_auditing_policy_filters", "gs_auditing_policy_privileges",
- "gs_auditing_privilege", "gs_client_global_keys",
"gs_client_global_keys_args", "gs_cluster_resource_info", "gs_column_keys",
"gs_column_keys_args", "gs_comm_proxy_thread_status",
- "gs_db_privilege", "gs_db_privileges",
- "gs_encrypted_columns", "gs_encrypted_proc", "gs_file_stat",
"gs_get_control_group_info", "gs_global_chain", "gs_global_config",
"gs_gsc_memory_detail", "gs_instance_time",
- "gs_job_argument",
- "gs_job_attribute", "gs_labels", "gs_lsc_memory_detail",
"gs_masking", "gs_masking_policy", "gs_masking_policy_actions",
"gs_masking_policy_filters", "gs_matview", "gs_matview_dependency",
- "gs_matviews", "gs_model_warehouse", "gs_obsscaninfo",
"gs_opt_model", "gs_os_run_info", "gs_package", "gs_policy_label",
"gs_recyclebin", "gs_redo_stat",
- "gs_session_cpu_statistics", "gs_session_memory",
"gs_session_memory_context", "gs_session_memory_detail",
"gs_session_memory_statistics", "gs_session_stat", "gs_session_time",
- "gs_shared_memory_detail", "gs_sql_count",
- "gs_stat_session_cu", "gs_thread_memory_context",
"gs_total_memory_detail", "gs_total_nodegroup_memory_detail",
"gs_txn_snapshot", "gs_uid", "gs_wlm_cgroup_info",
- "gs_wlm_ec_operator_history", "gs_wlm_ec_operator_info",
- "gs_wlm_ec_operator_statistics", "gs_wlm_instance_history",
"gs_wlm_operator_history", "gs_wlm_operator_info",
"gs_wlm_operator_statistics", "gs_wlm_plan_encoding_table",
- "gs_wlm_plan_operator_history", "gs_wlm_plan_operator_info",
"gs_wlm_rebuild_user_resource_pool",
- "gs_wlm_resource_pool", "gs_wlm_session_history",
"gs_wlm_session_info", "gs_wlm_session_info_all",
"gs_wlm_session_query_info_all", "gs_wlm_session_statistics",
"gs_wlm_user_info",
- "gs_wlm_user_resource_history", "gs_wlm_workload_records",
- "mpp_tables", "pg_aggregate", "pg_am", "pg_amop", "pg_amproc",
"pg_app_workloadgroup_mapping", "pg_attrdef", "pg_attribute", "pg_auth_history",
- "pg_auth_members", "pg_authid", "pg_available_extension_versions",
"pg_available_extensions", "pg_cast", "pg_class", "pg_collation",
"pg_comm_delay", "pg_comm_recv_stream",
- "pg_comm_send_stream", "pg_comm_status", "pg_constraint",
"pg_control_group_config", "pg_conversion", "pg_cursors", "pg_database",
"pg_db_role_setting", "pg_default_acl",
- "pg_depend", "pg_description", "pg_directory", "pg_enum",
"pg_ext_stats", "pg_extension", "pg_extension_data_source",
"pg_foreign_data_wrapper", "pg_foreign_server",
- "pg_foreign_table", "pg_get_invalid_backends",
"pg_get_senders_catchup_time", "pg_group", "pg_gtt_attached_pids",
"pg_gtt_relstats", "pg_gtt_stats", "pg_hashbucket", "pg_index",
- "pg_indexes", "pg_inherits", "pg_job", "pg_job_proc",
"pg_language", "pg_largeobject", "pg_largeobject_metadata", "pg_locks",
"pg_namespace",
- "pg_node_env", "pg_object", "pg_obsscaninfo", "pg_opclass",
"pg_operator", "pg_opfamily", "pg_os_threads", "pg_partition", "pg_pltemplate",
- "pg_prepared_statements", "pg_prepared_xacts", "pg_proc",
"pg_publication", "pg_publication_rel", "pg_publication_tables", "pg_range",
"pg_replication_origin",
- "pg_replication_origin_status",
- "pg_replication_slots", "pg_resource_pool", "pg_rewrite",
"pg_rlspolicies", "pg_rlspolicy", "pg_roles", "pg_rules", "pg_running_xacts",
"pg_seclabel",
- "pg_seclabels", "pg_session_iostat", "pg_session_wlmstat",
"pg_settings", "pg_shadow", "pg_shdepend", "pg_shdescription", "pg_shseclabel",
"pg_stat_activity",
- "pg_stat_activity_ng", "pg_stat_all_indexes",
"pg_stat_all_tables", "pg_stat_bad_block", "pg_stat_bgwriter",
"pg_stat_database", "pg_stat_database_conflicts", "pg_stat_replication",
- "pg_stat_subscription",
- "pg_stat_sys_indexes", "pg_stat_sys_tables",
"pg_stat_user_functions", "pg_stat_user_indexes", "pg_stat_user_tables",
"pg_stat_xact_all_tables", "pg_stat_xact_sys_tables",
- "pg_stat_xact_user_functions", "pg_stat_xact_user_tables",
- "pg_statio_all_indexes", "pg_statio_all_sequences",
"pg_statio_all_tables", "pg_statio_sys_indexes", "pg_statio_sys_sequences",
"pg_statio_sys_tables", "pg_statio_user_indexes",
- "pg_statio_user_sequences", "pg_statio_user_tables",
- "pg_statistic", "pg_statistic_ext", "pg_stats", "pg_subscription",
"pg_synonym", "pg_tables", "pg_tablespace", "pg_tde_info",
"pg_thread_wait_status",
- "pg_timezone_abbrevs", "pg_timezone_names",
"pg_total_memory_detail", "pg_total_user_resource_info",
"pg_total_user_resource_info_oid", "pg_trigger", "pg_ts_config",
"pg_ts_config_map",
- "pg_ts_dict",
- "pg_ts_parser", "pg_ts_template", "pg_type", "pg_user",
"pg_user_mapping", "pg_user_mappings", "pg_user_status", "pg_variable_info",
"pg_views",
- "pg_wlm_statistics", "pg_workload_group", "pgxc_class",
"pgxc_group", "pgxc_node", "pgxc_prepared_xacts", "pgxc_slice",
"pgxc_thread_wait_status", "plan_table",
- "plan_table_data", "statement_history", "streaming_cont_query",
"streaming_stream", "streaming_reaper_status", "sys_dummy"))),
-
- OPEN_GAUSS_BLOCKCHAIN("openGauss", "blockchain", Collections.emptySet()),
-
- OPEN_GAUSS_CSTORE("openGauss", "cstore", Collections.emptySet()),
-
- OPEN_GAUSS_DB4AI("openGauss", "db4ai", Collections.emptySet()),
-
- OPEN_GAUSS_DBE_PERF("openGauss", "dbe_perf", Collections.emptySet()),
-
- OPEN_GAUSS_DBE_PLDEBUGGER("openGauss", "dbe_pldebugger",
Collections.emptySet()),
-
- OPEN_GAUSS_GAUSSDB("openGauss", "gaussdb", Collections.emptySet()),
-
- OPEN_GAUSS_ORACLE("openGauss", "oracle", Collections.emptySet()),
-
- OPEN_GAUSS_PKG_SERVICE("openGauss", "pkg_service", Collections.emptySet()),
-
- OPEN_GAUSS_SNAPSHOT("openGauss", "snapshot", Collections.emptySet()),
-
- OPEN_GAUSS_PLDEVELOPER("openGauss", "dbe_pldeveloper",
Collections.emptySet()),
-
- OPEN_GAUSS_PG_TOAST("openGauss", "pg_toast", Collections.emptySet()),
-
- OPEN_GAUSS_PKG_UTIL("openGauss", "pkg_util", Collections.emptySet()),
-
- OPEN_GAUSS_SQLADVISOR("openGauss", "sqladvisor", Collections.emptySet()),
-
- OPEN_GAUSS_SHARDING_SPHERE("openGauss", "shardingsphere", new
HashSet<>(Arrays.asList("sharding_table_statistics", "cluster_information")));
-
- private static final Map<String, SystemSchemaBuilderRule>
SCHEMA_PATH_SYSTEM_SCHEMA_BUILDER_RULE_MAP = new HashMap<>(values().length, 1F);
-
- private final String databaseType;
-
- private final String schema;
-
- private final Collection<String> tables;
-
- static {
- for (SystemSchemaBuilderRule each : values()) {
-
SCHEMA_PATH_SYSTEM_SCHEMA_BUILDER_RULE_MAP.put(each.getDatabaseType() + "." +
each.getSchema(), each);
- }
- }
-
- /**
- * Value of builder rule.
- *
- * @param databaseType database type
- * @param schema schema
- * @return builder rule
- */
- public static Optional<SystemSchemaBuilderRule> findBuilderRule(final
String databaseType, final String schema) {
- String schemaPath = databaseType + "." + schema;
- return
Optional.ofNullable(SCHEMA_PATH_SYSTEM_SCHEMA_BUILDER_RULE_MAP.get(schemaPath));
- }
-
- /**
- * Judge whether current table is system table or not.
- *
- * @param schema schema
- * @param tableName table name
- * @return whether current table is system table or not
- */
- public static boolean isSystemTable(final String schema, final String
tableName) {
- for (SystemSchemaBuilderRule each : values()) {
- if (each.getSchema().equals(schema) &&
each.getTables().contains(tableName)) {
- return true;
- }
- }
- return false;
- }
-}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaMetadata.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaMetadata.java
new file mode 100644
index 00000000000..925763d8b44
--- /dev/null
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaMetadata.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.database.schema.builder;
+
+import com.cedarsoftware.util.CaseInsensitiveMap;
+import com.cedarsoftware.util.CaseInsensitiveSet;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import
org.apache.shardingsphere.infra.util.directory.ClasspathResourceDirectoryReader;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * System schema metadata.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class SystemSchemaMetadata {
+
+ private static final Map<String, Map<String, Collection<String>>>
DATABASE_TYPE_SCHEMA_TABLE_MAP;
+
+ private static final Map<String, Map<String, Collection<String>>>
DATABASE_TYPE_SCHEMA_RESOURCE_MAP;
+
+ private static final String COMMON = "common";
+
+ static {
+ List<String> resourceNames;
+ try (Stream<String> resourceNameStream =
ClasspathResourceDirectoryReader.read("schema")) {
+ resourceNames = resourceNameStream.collect(Collectors.toList());
+ }
+ DATABASE_TYPE_SCHEMA_TABLE_MAP =
resourceNames.stream().map(resourceName ->
resourceName.split("/")).collect(Collectors.groupingBy(path -> path[1],
CaseInsensitiveMap::new,
+ Collectors.groupingBy(path -> path[2],
CaseInsensitiveMap::new, Collectors.mapping(path ->
StringUtils.removeEnd(path[3], ".yaml"),
+ Collectors.toCollection(CaseInsensitiveSet::new)))));
+ DATABASE_TYPE_SCHEMA_RESOURCE_MAP =
resourceNames.stream().map(resourceName ->
resourceName.split("/")).collect(Collectors.groupingBy(path -> path[1],
CaseInsensitiveMap::new,
+ Collectors.groupingBy(path -> path[2],
CaseInsensitiveMap::new, Collectors.mapping(path -> String.join("/", path),
+ Collectors.toCollection(CaseInsensitiveSet::new)))));
+ }
+
+ /**
+ * Judge whether current table is system table or not.
+ *
+ * @param schema schema
+ * @param tableName table name
+ * @return whether current table is system table or not
+ */
+ public static boolean isSystemTable(final String schema, final String
tableName) {
+ for (Entry<String, Map<String, Collection<String>>> entry :
DATABASE_TYPE_SCHEMA_TABLE_MAP.entrySet()) {
+ if (Optional.ofNullable(entry.getValue().get(schema)).map(tables
-> tables.contains(tableName)).orElse(false)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Judge whether current table is system table or not.
+ *
+ * @param databaseType database type
+ * @param schema schema
+ * @param tableName table name
+ * @return whether current table is system table or not
+ */
+ public static boolean isSystemTable(final String databaseType, final
String schema, final String tableName) {
+ return
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(databaseType)).map(schemas
-> schemas.get(schema)).map(tables -> tables.contains(tableName)).orElse(false)
+ ||
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(COMMON)).map(schemas ->
schemas.get(schema)).map(tables -> tables.contains(tableName)).orElse(false);
+ }
+
+ /**
+ * Judge whether current table is system table or not.
+ *
+ * @param databaseType database type
+ * @param schema schema
+ * @param tableNames table names
+ * @return whether current table is system table or not
+ */
+ public static boolean isSystemTable(final String databaseType, final
String schema, final Collection<String> tableNames) {
+ Collection<String> databaseTypeTables =
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(databaseType)).map(schemas
-> schemas.get(schema)).orElse(Collections.emptyList());
+ Collection<String> commonTables =
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(COMMON)).map(schemas ->
schemas.get(schema)).orElse(Collections.emptyList());
+ for (final String each : tableNames) {
+ if (!databaseTypeTables.contains(each) &&
!commonTables.contains(each)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Get tables.
+ *
+ * @param databaseType database type
+ * @param schema schema
+ * @return optional tables
+ */
+ public static Collection<String> getTables(final String databaseType,
final String schema) {
+ Collection<String> result = new LinkedList<>();
+
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(databaseType)).map(schemas
-> schemas.get(schema)).ifPresent(result::addAll);
+
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(COMMON)).map(schemas ->
schemas.get(schema)).ifPresent(result::addAll);
+ return result;
+ }
+
+ /**
+ * Get schema streams.
+ *
+ * @param databaseType database type
+ * @param schema schema
+ * @return inputStream collection
+ */
+ public static Collection<InputStream> getSchemaStreams(final String
databaseType, final String schema) {
+ Collection<InputStream> result = new LinkedList<>();
+ getSchemaStreamsInternal(databaseType,
schema).ifPresent(result::addAll);
+ getSchemaStreamsInternal(COMMON, schema).ifPresent(result::addAll);
+ return result;
+ }
+
+ private static Optional<Collection<InputStream>>
getSchemaStreamsInternal(final String databaseType, final String schema) {
+ return
Optional.ofNullable(DATABASE_TYPE_SCHEMA_RESOURCE_MAP.get(databaseType)).map(schemas
-> schemas.get(schema)).map(resources -> {
+ Collection<InputStream> result = new LinkedList<>();
+ for (String each : resources) {
+
result.add(SystemSchemaMetadata.class.getClassLoader().getResourceAsStream(each));
+ }
+ return result;
+ });
+ }
+}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
deleted file mode 100644
index a97f61ed4a1..00000000000
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.metadata.database.schema.builder;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class SystemSchemaBuilderRuleTest {
-
- @Test
- void assertValueOfSchemaPathSuccess() {
- Optional<SystemSchemaBuilderRule> actualInformationSchema =
SystemSchemaBuilderRule.findBuilderRule("MySQL", "information_schema");
- assertTrue(actualInformationSchema.isPresent());
- assertThat(actualInformationSchema.get(),
is(SystemSchemaBuilderRule.MYSQL_INFORMATION_SCHEMA));
- assertThat(actualInformationSchema.get().getTables().size(), is(61));
- Optional<SystemSchemaBuilderRule> actualMySQLSchema =
SystemSchemaBuilderRule.findBuilderRule("MySQL", "mysql");
- assertTrue(actualMySQLSchema.isPresent());
- assertThat(actualMySQLSchema.get(),
is(SystemSchemaBuilderRule.MYSQL_MYSQL));
- assertThat(actualMySQLSchema.get().getTables().size(), is(31));
- Optional<SystemSchemaBuilderRule> actualPerformanceSchema =
SystemSchemaBuilderRule.findBuilderRule("MySQL", "performance_schema");
- assertTrue(actualPerformanceSchema.isPresent());
- assertThat(actualPerformanceSchema.get(),
is(SystemSchemaBuilderRule.MYSQL_PERFORMANCE_SCHEMA));
- assertThat(actualPerformanceSchema.get().getTables().size(), is(87));
- Optional<SystemSchemaBuilderRule> actualSysSchema =
SystemSchemaBuilderRule.findBuilderRule("MySQL", "sys");
- assertTrue(actualSysSchema.isPresent());
- assertThat(actualSysSchema.get(),
is(SystemSchemaBuilderRule.MYSQL_SYS));
- assertThat(actualSysSchema.get().getTables().size(), is(53));
- Optional<SystemSchemaBuilderRule> actualPgInformationSchema =
SystemSchemaBuilderRule.findBuilderRule("PostgreSQL", "information_schema");
- assertTrue(actualPgInformationSchema.isPresent());
- assertThat(actualPgInformationSchema.get(),
is(SystemSchemaBuilderRule.POSTGRESQL_INFORMATION_SCHEMA));
- assertThat(actualPgInformationSchema.get().getTables().size(), is(69));
- Optional<SystemSchemaBuilderRule> actualPgCatalog =
SystemSchemaBuilderRule.findBuilderRule("PostgreSQL", "pg_catalog");
- assertTrue(actualPgCatalog.isPresent());
- assertThat(actualPgCatalog.get(),
is(SystemSchemaBuilderRule.POSTGRESQL_PG_CATALOG));
- assertThat(actualPgCatalog.get().getTables().size(), is(134));
- Optional<SystemSchemaBuilderRule> actualOgInformationSchema =
SystemSchemaBuilderRule.findBuilderRule("openGauss", "information_schema");
- assertTrue(actualOgInformationSchema.isPresent());
- assertThat(actualOgInformationSchema.get(),
is(SystemSchemaBuilderRule.OPEN_GAUSS_INFORMATION_SCHEMA));
- assertThat(actualOgInformationSchema.get().getTables().size(), is(66));
- Optional<SystemSchemaBuilderRule> actualOgPgCatalog =
SystemSchemaBuilderRule.findBuilderRule("openGauss", "pg_catalog");
- assertTrue(actualOgPgCatalog.isPresent());
- assertThat(actualOgPgCatalog.get(),
is(SystemSchemaBuilderRule.OPEN_GAUSS_PG_CATALOG));
- assertThat(actualOgPgCatalog.get().getTables().size(), is(240));
-
- }
-
- @Test
- void assertNullableValueOfSchemaPath() {
- Optional<SystemSchemaBuilderRule> unknownSchema =
SystemSchemaBuilderRule.findBuilderRule("UnKnown", "public");
- assertFalse(unknownSchema.isPresent());
- }
-
- @Test
- void assertIsisSystemTable() {
- assertTrue(SystemSchemaBuilderRule.isSystemTable("information_schema",
"columns"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_database"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_tables"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_aggregate"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_am"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_amop"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_amproc"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_attrdef"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_attribute"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_auth_members"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_authid"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_available_extension_versions"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_available_extensions"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_backend_memory_contexts"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_cast"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_range"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_replication_origin"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_rewrite"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_seclabel"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_sequence"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_roles"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_user_mapping"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_stat_database_conflicts"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_stat_gssapi"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_stat_progress_analyze"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_stat_progress_basebackup"));
- assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog",
"pg_stat_progress_cluster"));
- assertFalse(SystemSchemaBuilderRule.isSystemTable("sharding_db",
"t_order"));
- }
-}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaMetadataTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaMetadataTest.java
new file mode 100644
index 00000000000..91fe9f559c4
--- /dev/null
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaMetadataTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.database.schema.builder;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class SystemSchemaMetadataTest {
+
+ @Test
+ void assertValueOfSchemaPathSuccess() {
+ Collection<String> actualInformationSchema =
SystemSchemaMetadata.getTables("MySQL", "information_schema");
+ assertThat(actualInformationSchema.size(), is(61));
+ Collection<String> actualMySQLSchema =
SystemSchemaMetadata.getTables("MySQL", "mysql");
+ assertThat(actualMySQLSchema.size(), is(31));
+ Collection<String> actualPerformanceSchema =
SystemSchemaMetadata.getTables("MySQL", "performance_schema");
+ assertThat(actualPerformanceSchema.size(), is(87));
+ Collection<String> actualSysSchema =
SystemSchemaMetadata.getTables("MySQL", "sys");
+ assertThat(actualSysSchema.size(), is(54));
+ Collection<String> actualShardingSphereSchema =
SystemSchemaMetadata.getTables("MySQL", "shardingsphere");
+ assertThat(actualShardingSphereSchema.size(), is(2));
+ Collection<String> actualPgInformationSchema =
SystemSchemaMetadata.getTables("PostgreSQL", "information_schema");
+ assertThat(actualPgInformationSchema.size(), is(69));
+ Collection<String> actualPgCatalog =
SystemSchemaMetadata.getTables("PostgreSQL", "pg_catalog");
+ assertThat(actualPgCatalog.size(), is(134));
+ Collection<String> actualOgInformationSchema =
SystemSchemaMetadata.getTables("openGauss", "information_schema");
+ assertThat(actualOgInformationSchema.size(), is(66));
+ Collection<String> actualOgPgCatalog =
SystemSchemaMetadata.getTables("openGauss", "pg_catalog");
+ assertThat(actualOgPgCatalog.size(), is(240));
+
+ }
+
+ @Test
+ void assertIsisSystemTable() {
+ assertTrue(SystemSchemaMetadata.isSystemTable("information_schema",
"columns"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_database"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_tables"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_aggregate"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog", "pg_am"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_amop"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_amproc"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_attrdef"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_attribute"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_auth_members"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_authid"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_available_extension_versions"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_available_extensions"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_backend_memory_contexts"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_cast"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_range"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_replication_origin"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_rewrite"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_seclabel"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_sequence"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_roles"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_user_mapping"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_stat_database_conflicts"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_stat_gssapi"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_stat_progress_analyze"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_stat_progress_basebackup"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("pg_catalog",
"pg_stat_progress_cluster"));
+ assertFalse(SystemSchemaMetadata.isSystemTable("sharding_db",
"t_order"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("shardingsphere",
"cluster_information"));
+ assertTrue(SystemSchemaMetadata.isSystemTable("shardingsphere",
"sharding_table_statistics"));
+ assertFalse(SystemSchemaMetadata.isSystemTable("shardingsphere",
"nonexistent"));
+ }
+}
diff --git
a/infra/database/type/mysql/src/main/resources/schema/mysql/shardingsphere/cluster_information.yaml
b/infra/database/core/src/main/resources/schema/common/shardingsphere/cluster_information.yaml
similarity index 100%
rename from
infra/database/type/mysql/src/main/resources/schema/mysql/shardingsphere/cluster_information.yaml
rename to
infra/database/core/src/main/resources/schema/common/shardingsphere/cluster_information.yaml
diff --git
a/infra/database/type/mysql/src/main/resources/schema/mysql/shardingsphere/sharding_table_statistics.yaml
b/infra/database/core/src/main/resources/schema/common/shardingsphere/sharding_table_statistics.yaml
similarity index 100%
rename from
infra/database/type/mysql/src/main/resources/schema/mysql/shardingsphere/sharding_table_statistics.yaml
rename to
infra/database/core/src/main/resources/schema/common/shardingsphere/sharding_table_statistics.yaml
diff --git
a/infra/database/type/opengauss/src/main/resources/schema/opengauss/shardingsphere/cluster_information.yaml
b/infra/database/type/opengauss/src/main/resources/schema/opengauss/shardingsphere/cluster_information.yaml
deleted file mode 100644
index 5dbbfa14230..00000000000
---
a/infra/database/type/opengauss/src/main/resources/schema/opengauss/shardingsphere/cluster_information.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-name: cluster_information
-
-columns:
- version:
- caseSensitive: false
- dataType: 12
- generated: false
- name: version
- primaryKey: false
- visible: true
diff --git
a/infra/database/type/opengauss/src/main/resources/schema/opengauss/shardingsphere/sharding_table_statistics.yaml
b/infra/database/type/opengauss/src/main/resources/schema/opengauss/shardingsphere/sharding_table_statistics.yaml
deleted file mode 100644
index bdacd40b740..00000000000
---
a/infra/database/type/opengauss/src/main/resources/schema/opengauss/shardingsphere/sharding_table_statistics.yaml
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-name: sharding_table_statistics
-
-columns:
- id:
- caseSensitive: false
- dataType: 4
- generated: false
- name: id
- primaryKey: true
- visible: true
- logic_database_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: logic_database_name
- primaryKey: false
- visible: true
- logic_table_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: logic_table_name
- primaryKey: false
- visible: true
- actual_database_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: actual_database_name
- primaryKey: false
- visible: true
- actual_table_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: actual_table_name
- primaryKey: false
- visible: true
- row_count:
- caseSensitive: false
- dataType: 3
- generated: false
- name: row_count
- primaryKey: false
- visible: true
- size:
- caseSensitive: false
- dataType: 3
- generated: false
- name: size
- primaryKey: false
- visible: true
diff --git
a/infra/database/type/postgresql/src/main/resources/schema/postgresql/shardingsphere/cluster_information.yaml
b/infra/database/type/postgresql/src/main/resources/schema/postgresql/shardingsphere/cluster_information.yaml
deleted file mode 100644
index 5dbbfa14230..00000000000
---
a/infra/database/type/postgresql/src/main/resources/schema/postgresql/shardingsphere/cluster_information.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-name: cluster_information
-
-columns:
- version:
- caseSensitive: false
- dataType: 12
- generated: false
- name: version
- primaryKey: false
- visible: true
diff --git
a/infra/database/type/postgresql/src/main/resources/schema/postgresql/shardingsphere/sharding_table_statistics.yaml
b/infra/database/type/postgresql/src/main/resources/schema/postgresql/shardingsphere/sharding_table_statistics.yaml
deleted file mode 100644
index bdacd40b740..00000000000
---
a/infra/database/type/postgresql/src/main/resources/schema/postgresql/shardingsphere/sharding_table_statistics.yaml
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-name: sharding_table_statistics
-
-columns:
- id:
- caseSensitive: false
- dataType: 4
- generated: false
- name: id
- primaryKey: true
- visible: true
- logic_database_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: logic_database_name
- primaryKey: false
- visible: true
- logic_table_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: logic_table_name
- primaryKey: false
- visible: true
- actual_database_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: actual_database_name
- primaryKey: false
- visible: true
- actual_table_name:
- caseSensitive: false
- dataType: 12
- generated: false
- name: actual_table_name
- primaryKey: false
- visible: true
- row_count:
- caseSensitive: false
- dataType: 3
- generated: false
- name: row_count
- primaryKey: false
- visible: true
- size:
- caseSensitive: false
- dataType: 3
- generated: false
- name: size
- primaryKey: false
- visible: true
diff --git
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
index 60fbaae8e21..0ba578ac58b 100644
---
a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
+++
b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/metadata/watcher/MetaDataChangedWatcher.java
@@ -21,29 +21,29 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import
org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
+import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import
org.apache.shardingsphere.infra.yaml.config.swapper.resource.YamlDataSourceConfigurationSwapper;
import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapperEngine;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import
org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereTable;
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereView;
import org.apache.shardingsphere.infra.yaml.schema.swapper.YamlTableSwapper;
import org.apache.shardingsphere.infra.yaml.schema.swapper.YamlViewSwapper;
import org.apache.shardingsphere.metadata.persist.node.DatabaseMetaDataNode;
-import org.apache.shardingsphere.infra.rule.event.GovernanceEvent;
+import org.apache.shardingsphere.mode.event.DataChangedEvent;
+import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
+import org.apache.shardingsphere.mode.event.schema.TableMetaDataChangedEvent;
+import org.apache.shardingsphere.mode.event.schema.ViewMetaDataChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcher;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.datasource.DataSourceNodesChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.datasource.DataSourceUnitsChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.config.event.rule.RuleConfigurationsChangedEvent;
-import org.apache.shardingsphere.mode.event.schema.TableMetaDataChangedEvent;
-import org.apache.shardingsphere.mode.event.schema.ViewMetaDataChangedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseAddedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseDeletedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaAddedEvent;
import
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaDeletedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent;
-import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import java.util.Arrays;
import java.util.Collection;
@@ -108,7 +108,7 @@ public final class MetaDataChangedWatcher implements
GovernanceWatcher<Governanc
}
Optional<String> tableName =
DatabaseMetaDataNode.getTableName(event.getKey());
Optional<String> viewName =
DatabaseMetaDataNode.getViewName(event.getKey());
- return tableName.isPresent() &&
!SystemSchemaBuilderRule.isSystemTable(databaseName.get(), tableName.get()) ||
viewName.isPresent();
+ return tableName.isPresent() &&
!SystemSchemaMetadata.isSystemTable(databaseName.get(), tableName.get()) ||
viewName.isPresent();
}
private Optional<GovernanceEvent> createDatabaseChangedEvent(final
DataChangedEvent event) {
diff --git
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLInformationSchemaExecutorFactory.java
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLInformationSchemaExecutorFactory.java
index f1bb9ba5cc4..580a8216a24 100644
---
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLInformationSchemaExecutorFactory.java
+++
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLInformationSchemaExecutorFactory.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.backend.mysql.handler.admin;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetaDataExecutor.DefaultDatabaseMetaDataExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.proxy.backend.mysql.handler.admin.executor.information.SelectInformationSchemataExecutor;
@@ -53,7 +53,7 @@ public final class MySQLInformationSchemaExecutorFactory {
if (SCHEMATA_TABLE.equalsIgnoreCase(tableName)) {
return Optional.of(new
SelectInformationSchemataExecutor(sqlStatement, sql, parameters));
}
- if
(SystemSchemaBuilderRule.MYSQL_INFORMATION_SCHEMA.getTables().contains(tableName.toLowerCase()))
{
+ if (SystemSchemaMetadata.isSystemTable("mysql", "information_schema",
tableName)) {
return Optional.of(new DefaultDatabaseMetaDataExecutor(sql,
parameters));
}
return Optional.empty();
diff --git
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLMySQLSchemaExecutorFactory.java
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLMySQLSchemaExecutorFactory.java
index 9e93df2109d..c550cf0a6c1 100644
---
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLMySQLSchemaExecutorFactory.java
+++
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLMySQLSchemaExecutorFactory.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.backend.mysql.handler.admin;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetaDataExecutor.DefaultDatabaseMetaDataExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
@@ -47,7 +47,7 @@ public final class MySQLMySQLSchemaExecutorFactory {
return Optional.empty();
}
String tableName = ((SimpleTableSegment)
sqlStatement.getFrom()).getTableName().getIdentifier().getValue();
- if
(SystemSchemaBuilderRule.MYSQL_MYSQL.getTables().contains(tableName.toLowerCase()))
{
+ if (SystemSchemaMetadata.isSystemTable("mysql", "mysql", tableName)) {
return Optional.of(new DefaultDatabaseMetaDataExecutor(sql,
parameters));
}
return Optional.empty();
diff --git
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLPerformanceSchemaExecutorFactory.java
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLPerformanceSchemaExecutorFactory.java
index 450f7e40fb1..8baaa1308e4 100644
---
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLPerformanceSchemaExecutorFactory.java
+++
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLPerformanceSchemaExecutorFactory.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.backend.mysql.handler.admin;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetaDataExecutor.DefaultDatabaseMetaDataExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
@@ -47,7 +47,7 @@ public final class MySQLPerformanceSchemaExecutorFactory {
return Optional.empty();
}
String tableName = ((SimpleTableSegment)
sqlStatement.getFrom()).getTableName().getIdentifier().getValue();
- if
(SystemSchemaBuilderRule.MYSQL_PERFORMANCE_SCHEMA.getTables().contains(tableName.toLowerCase()))
{
+ if (SystemSchemaMetadata.isSystemTable("mysql", "performance_schema",
tableName)) {
return Optional.of(new DefaultDatabaseMetaDataExecutor(sql,
parameters));
}
return Optional.empty();
diff --git
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLSysSchemaExecutorFactory.java
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLSysSchemaExecutorFactory.java
index 2c438520c6d..14104aa8af3 100644
---
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLSysSchemaExecutorFactory.java
+++
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLSysSchemaExecutorFactory.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.backend.mysql.handler.admin;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetaDataExecutor.DefaultDatabaseMetaDataExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
@@ -47,7 +47,7 @@ public final class MySQLSysSchemaExecutorFactory {
return Optional.empty();
}
String tableName = ((SimpleTableSegment)
sqlStatement.getFrom()).getTableName().getIdentifier().getValue();
- if
(SystemSchemaBuilderRule.MYSQL_SYS.getTables().contains(tableName.toLowerCase()))
{
+ if (SystemSchemaMetadata.isSystemTable("mysql", "sys", tableName)) {
return Optional.of(new DefaultDatabaseMetaDataExecutor(sql,
parameters));
}
return Optional.empty();
diff --git
a/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
index 4db99904965..e9c1c8d9ab7 100644
---
a/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
+++
b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetaDataExecutor.DefaultDatabaseMetaDataExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutorCreator;
@@ -95,8 +95,8 @@ public final class OpenGaussAdminExecutorCreator implements
DatabaseAdminExecuto
private boolean isPassThroughSystemCatalogQuery(final SQLStatementContext
sqlStatementContext) {
Collection<String> tableNames =
sqlStatementContext.getTablesContext().getTableNames();
- return !tableNames.isEmpty() &&
(SystemSchemaBuilderRule.OPEN_GAUSS_INFORMATION_SCHEMA.getTables().containsAll(tableNames)
- ||
SystemSchemaBuilderRule.OPEN_GAUSS_PG_CATALOG.getTables().containsAll(tableNames));
+ return !tableNames.isEmpty() &&
(SystemSchemaMetadata.isSystemTable("opengauss", "information_schema",
tableNames)
+ || SystemSchemaMetadata.isSystemTable("opengauss",
"pg_catalog", tableNames));
}
@Override
diff --git
a/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
b/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
index 1646e222cd6..2999534c34b 100644
---
a/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
+++
b/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.postgresql.handler.admin;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaMetadata;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.AbstractDatabaseMetaDataExecutor.DefaultDatabaseMetaDataExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutor;
import
org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminExecutorCreator;
@@ -70,8 +70,8 @@ public final class PostgreSQLAdminExecutorCreator implements
DatabaseAdminExecut
if (!selectedTableNames.isEmpty() &&
KERNEL_SUPPORTED_TABLES.containsAll(selectedTableNames)) {
return Optional.empty();
}
- if (!selectedTableNames.isEmpty() &&
(SystemSchemaBuilderRule.POSTGRESQL_INFORMATION_SCHEMA.getTables().containsAll(selectedTableNames)
- ||
SystemSchemaBuilderRule.POSTGRESQL_PG_CATALOG.getTables().containsAll(selectedTableNames)))
{
+ if (!selectedTableNames.isEmpty() &&
(SystemSchemaMetadata.isSystemTable("postgresql", "information_schema",
selectedTableNames)
+ || SystemSchemaMetadata.isSystemTable("postgresql",
"pg_catalog", selectedTableNames))) {
return Optional.of(new DefaultDatabaseMetaDataExecutor(sql,
parameters));
}
}