You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/11/10 08:59:30 UTC
[shardingsphere] branch master updated: Add pg_class and pg_namespace metadata for og and pg. (#22057)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 492f59f0514 Add pg_class and pg_namespace metadata for og and pg. (#22057)
492f59f0514 is described below
commit 492f59f0514c21675a67025aa3adb487a70f836b
Author: Chuxin Chen <ch...@qq.com>
AuthorDate: Thu Nov 10 16:59:22 2022 +0800
Add pg_class and pg_namespace metadata for og and pg. (#22057)
* Support postgres/openGauss \d
* Add pg_class and pg_namespace metadata for og.
---
.../schema/builder/SystemSchemaBuilderRule.java | 4 +-
.../schema/opengauss/pg_catalog/pg_class.yaml | 346 +++++++++++++++++++++
.../schema/opengauss/pg_catalog/pg_namespace.yaml | 72 +++++
.../schema/postgresql/pg_catalog/pg_namespace.yaml | 56 ++++
.../schema/builder/SystemSchemaBuilderTest.java | 13 +-
5 files changed, 488 insertions(+), 3 deletions(-)
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
index 2d2823ee61e..933e864386e 100644
--- 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
@@ -48,13 +48,13 @@ public enum SystemSchemaBuilderRule {
POSTGRESQL_INFORMATION_SCHEMA("PostgreSQL", "information_schema", new HashSet<>(Arrays.asList("columns", "tables", "views"))),
- POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog", new HashSet<>(Arrays.asList("pg_class", "pg_database", "pg_inherits", "pg_tablespace", "pg_trigger"))),
+ POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog", new HashSet<>(Arrays.asList("pg_class", "pg_database", "pg_inherits", "pg_tablespace", "pg_trigger", "pg_namespace"))),
POSTGRESQL_SHARDING_SPHERE("PostgreSQL", "shardingsphere", new HashSet<>(Collections.singleton("sharding_table_statistics"))),
OPEN_GAUSS_INFORMATION_SCHEMA("openGauss", "information_schema", Collections.emptySet()),
- OPEN_GAUSS_PG_CATALOG("openGauss", "pg_catalog", Collections.emptySet()),
+ OPEN_GAUSS_PG_CATALOG("openGauss", "pg_catalog", new HashSet<>(Arrays.asList("pg_class", "pg_namespace"))),
OPEN_GAUSS_BLOCKCHAIN("openGauss", "blockchain", Collections.emptySet()),
diff --git a/infra/common/src/main/resources/schema/opengauss/pg_catalog/pg_class.yaml b/infra/common/src/main/resources/schema/opengauss/pg_catalog/pg_class.yaml
new file mode 100644
index 00000000000..0d59b0b1f54
--- /dev/null
+++ b/infra/common/src/main/resources/schema/opengauss/pg_catalog/pg_class.yaml
@@ -0,0 +1,346 @@
+#
+# 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: pg_class
+columns:
+ relname:
+ caseSensitive: true
+ dataType: 12
+ generated: false
+ name: relname
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relnamespace:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relnamespace
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reltype:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reltype
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reloftype:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reloftype
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relowner:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relowner
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relam:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relam
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relfilenode:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relfilenode
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reltablespace:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reltablespace
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relpages:
+ caseSensitive: true
+ dataType: 8
+ generated: false
+ name: relpages
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reltuples:
+ caseSensitive: true
+ dataType: 8
+ generated: false
+ name: reltuples
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relallvisible:
+ caseSensitive: true
+ dataType: 4
+ generated: false
+ name: relallvisible
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reltoastrelid:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reltoastrelid
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reltoastidxid:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reltoastidxid
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reldeltarelid:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reldeltarelid
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reldeltaidx:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: reldeltaidx
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relcudescrelid:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relcudescrelid
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relcudescidx:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relcudescidx
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhasindex:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhasindex
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relisshared:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relisshared
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relpersistence:
+ caseSensitive: true
+ dataType: 1
+ generated: false
+ name: relpersistence
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relkind:
+ caseSensitive: true
+ dataType: 1
+ generated: false
+ name: relkind
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relnatts:
+ caseSensitive: true
+ dataType: 5
+ generated: false
+ name: relnatts
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relchecks:
+ caseSensitive: true
+ dataType: 5
+ generated: false
+ name: relchecks
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhasoids:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhasoids
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhaspkey:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhaspkey
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhasrules:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhasrules
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhastriggers:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhastriggers
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhassubclass:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhassubclass
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relcmprs:
+ caseSensitive: true
+ dataType: -6
+ generated: false
+ name: relcmprs
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relhasclusterkey:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relhasclusterkey
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relrowmovement:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: relrowmovement
+ primaryKey: false
+ unsigned: false
+ visible: true
+ parttype:
+ caseSensitive: true
+ dataType: 1
+ generated: false
+ name: parttype
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relfrozenxid:
+ caseSensitive: true
+ dataType: 1111
+ generated: false
+ name: relfrozenxid
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relacl:
+ caseSensitive: true
+ dataType: 2003
+ generated: false
+ name: relacl
+ primaryKey: false
+ unsigned: false
+ visible: true
+ reloptions:
+ caseSensitive: true
+ dataType: 2003
+ generated: false
+ name: reloptions
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relreplident:
+ caseSensitive: true
+ dataType: 1
+ generated: false
+ name: relreplident
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relfrozenxid64:
+ caseSensitive: true
+ dataType: 1111
+ generated: false
+ name: relfrozenxid64
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relbucket:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: relbucket
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relbucketkey:
+ caseSensitive: true
+ dataType: 1111
+ generated: false
+ name: relbucketkey
+ primaryKey: false
+ unsigned: false
+ visible: true
+ relminmxid:
+ caseSensitive: true
+ dataType: 1111
+ generated: false
+ name: relminmxid
+ primaryKey: false
+ unsigned: false
+ visible: true
+indexes:
+ pg_class_oid_index:
+ name: pg_class_oid_index
+ pg_class_relname_nsp_index:
+ name: pg_class_relname_nsp_index
+ pg_class_tblspc_relfilenode_index:
+ name: pg_class_tblspc_relfilenode_index
diff --git a/infra/common/src/main/resources/schema/opengauss/pg_catalog/pg_namespace.yaml b/infra/common/src/main/resources/schema/opengauss/pg_catalog/pg_namespace.yaml
new file mode 100644
index 00000000000..dca6fe0dfec
--- /dev/null
+++ b/infra/common/src/main/resources/schema/opengauss/pg_catalog/pg_namespace.yaml
@@ -0,0 +1,72 @@
+#
+# 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: pg_namespace
+columns:
+ nspname:
+ caseSensitive: true
+ dataType: 12
+ generated: false
+ name: nspname
+ primaryKey: false
+ unsigned: false
+ visible: true
+ nspowner:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: nspowner
+ primaryKey: false
+ unsigned: false
+ visible: true
+ nsptimeline:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: nsptimeline
+ primaryKey: false
+ unsigned: false
+ visible: true
+ nspacl:
+ caseSensitive: true
+ dataType: 2003
+ generated: false
+ name: nspacl
+ primaryKey: false
+ unsigned: false
+ visible: true
+ in_redistribution:
+ caseSensitive: true
+ dataType: 1
+ generated: false
+ name: in_redistribution
+ primaryKey: false
+ unsigned: false
+ visible: true
+ nspblockchain:
+ caseSensitive: true
+ dataType: -7
+ generated: false
+ name: nspblockchain
+ primaryKey: false
+ unsigned: false
+ visible: true
+indexes:
+ pg_namespace_nspname_index:
+ name: pg_namespace_nspname_index
+ pg_namespace_oid_index:
+ name: pg_namespace_oid_index
diff --git a/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_namespace.yaml b/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_namespace.yaml
new file mode 100644
index 00000000000..a2b23528767
--- /dev/null
+++ b/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_namespace.yaml
@@ -0,0 +1,56 @@
+#
+# 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: pg_namespace
+columns:
+ oid:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: oid
+ primaryKey: true
+ unsigned: false
+ visible: true
+ nspname:
+ caseSensitive: true
+ dataType: 12
+ generated: false
+ name: nspname
+ primaryKey: false
+ unsigned: false
+ visible: true
+ nspowner:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: nspowner
+ primaryKey: false
+ unsigned: false
+ visible: true
+ nspacl:
+ caseSensitive: true
+ dataType: 2003
+ generated: false
+ name: nspacl
+ primaryKey: false
+ unsigned: false
+ visible: true
+indexes:
+ pg_namespace_nspname_index:
+ name: pg_namespace_nspname_index
+ pg_namespace_oid_index:
+ name: pg_namespace_oid_index
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
index 9c928c6bf1a..4c03a861c44 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.metadata.database.schema.builder;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import org.junit.Test;
@@ -46,7 +47,17 @@ public final class SystemSchemaBuilderTest {
assertTrue(actual.containsKey("pg_catalog"));
assertTrue(actual.containsKey("shardingsphere"));
assertThat(actual.get("information_schema").getTables().size(), is(3));
- assertThat(actual.get("pg_catalog").getTables().size(), is(5));
+ assertThat(actual.get("pg_catalog").getTables().size(), is(6));
+ assertThat(actual.get("shardingsphere").getTables().size(), is(1));
+ }
+
+ @Test
+ public void assertBuildForOpenGaussSQL() {
+ Map<String, ShardingSphereSchema> actual = SystemSchemaBuilder.build("sharding_db", new OpenGaussDatabaseType());
+ assertThat(actual.size(), is(16));
+ assertTrue(actual.containsKey("pg_catalog"));
+ assertTrue(actual.containsKey("shardingsphere"));
+ assertThat(actual.get("pg_catalog").getTables().size(), is(2));
assertThat(actual.get("shardingsphere").getTables().size(), is(1));
}
}