You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2023/06/17 07:52:10 UTC
[shardingsphere] branch master updated: add PostgreSQL pg_catalog.pg_user_mapping table empty query #26154 (#26352)
This is an automated email from the ASF dual-hosted git repository.
chengzhang 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 698db2c1957 add PostgreSQL pg_catalog.pg_user_mapping table empty query #26154 (#26352)
698db2c1957 is described below
commit 698db2c1957da1afbfea3fbef096933f541ef117
Author: qywang <12...@users.noreply.github.com>
AuthorDate: Sat Jun 17 15:52:03 2023 +0800
add PostgreSQL pg_catalog.pg_user_mapping table empty query #26154 (#26352)
* add pg_user_mapping
* fix name problem
---
.../schema/builder/SystemSchemaBuilderRule.java | 2 +-
.../postgresql/pg_catalog/pg_user_mapping.yaml | 52 ++++++++++++++++++++++
.../builder/SystemSchemaBuilderRuleTest.java | 3 +-
.../schema/builder/SystemSchemaBuilderTest.java | 2 +-
...elect_postgresql_pg_catalog_pg_user_mapping.xml | 25 +++++++++++
.../dql/dql-integration-select-system-schema.xml | 4 ++
6 files changed, 85 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 13674ac74a7..6916305c309 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
@@ -77,7 +77,7 @@ 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_aggregate", "pg_am", "pg_amop", "pg_amproc", "pg_attrdef", "pg_class", "pg_database", "pg_tables", "pg_inherits",
- "pg_tablespace", "pg_trigger", "pg_namespace", "pg_roles"))),
+ "pg_tablespace", "pg_trigger", "pg_namespace", "pg_roles", "pg_user_mapping"))),
POSTGRESQL_SHARDING_SPHERE("PostgreSQL", "shardingsphere", new HashSet<>(Arrays.asList("sharding_table_statistics", "cluster_information"))),
diff --git a/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_user_mapping.yaml b/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_user_mapping.yaml
new file mode 100644
index 00000000000..bab23c18809
--- /dev/null
+++ b/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_user_mapping.yaml
@@ -0,0 +1,52 @@
+#
+# 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_user_mapping
+columns:
+ oid:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: oid
+ primaryKey: false
+ visible: true
+ umuser:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: umuser
+ primaryKey: false
+ visible: true
+ umserver:
+ caseSensitive: true
+ dataType: -5
+ generated: false
+ name: umserver
+ primaryKey: false
+ visible: true
+ umoptions:
+ caseSensitive: true
+ dataType: 2003
+ generated: false
+ name: umoptions
+ primaryKey: false
+ visible: true
+indexes:
+ pg_user_mapping_oid_index:
+ name: pg_user_mapping_oid_index
+ pg_user_mapping_user_server_index:
+ name: pg_user_mapping_user_server_index
\ No newline at end of file
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
index 7a2f7100212..3f1ac318600 100644
--- 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
@@ -42,7 +42,7 @@ class SystemSchemaBuilderRuleTest {
assertThat(actualPerformanceSchema.getTables().size(), is(87));
SystemSchemaBuilderRule actualPgCatalog = SystemSchemaBuilderRule.valueOf(new PostgreSQLDatabaseType().getType(), "pg_catalog");
assertThat(actualPgCatalog, is(SystemSchemaBuilderRule.POSTGRESQL_PG_CATALOG));
- assertThat(actualPgCatalog.getTables().size(), is(13));
+ assertThat(actualPgCatalog.getTables().size(), is(14));
}
@Test
@@ -61,6 +61,7 @@ class SystemSchemaBuilderRuleTest {
assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog", "pg_amproc"));
assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog", "pg_attrdef"));
assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog", "pg_roles"));
+ assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog", "pg_user_mapping"));
assertFalse(SystemSchemaBuilderRule.isSystemTable("sharding_db", "t_order"));
}
}
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 c1488f39e81..8f82fdd3e03 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
@@ -55,7 +55,7 @@ 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(13));
+ assertThat(actual.get("pg_catalog").getTables().size(), is(14));
assertThat(actual.get("shardingsphere").getTables().size(), is(2));
}
diff --git a/test/e2e/sql/src/test/resources/cases/dql/dataset/db/select_postgresql_pg_catalog_pg_user_mapping.xml b/test/e2e/sql/src/test/resources/cases/dql/dataset/db/select_postgresql_pg_catalog_pg_user_mapping.xml
new file mode 100644
index 00000000000..f51839f071c
--- /dev/null
+++ b/test/e2e/sql/src/test/resources/cases/dql/dataset/db/select_postgresql_pg_catalog_pg_user_mapping.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ 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.
+ -->
+
+<dataset>
+ <metadata>
+ <column name="oid" />
+ <column name="umuser" />
+ <column name="umserver" />
+ <column name="umoptions" />
+ </metadata>
+</dataset>
diff --git a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
index b4e342ce5d1..3156f65f130 100644
--- a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
+++ b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
@@ -737,4 +737,8 @@
<test-case sql="SELECT * FROM pg_catalog.pg_attrdef" db-types="PostgreSQL" scenario-types="db">
<assertion expected-data-file="select_postgresql_pg_catalog_pg_attrdef.xml" />
</test-case>
+
+ <test-case sql="SELECT * FROM pg_catalog.pg_user_mapping" db-types="PostgreSQL" scenario-types="db">
+ <assertion expected-data-file="select_postgresql_pg_catalog_pg_user_mapping.xml" />
+ </test-case>
</integration-test-cases>