You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/03/29 01:31:18 UTC

[shardingsphere] branch master updated: Add MySQL and PostgreSQL system schema loading logic (#16435)

This is an automated email from the ASF dual-hosted git repository.

panjuan 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 59d2d73  Add MySQL and PostgreSQL system schema loading logic (#16435)
59d2d73 is described below

commit 59d2d730c1b3d7cfac37b893f9f82a1a04b365e0
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Tue Mar 29 09:30:01 2022 +0800

    Add MySQL and PostgreSQL system schema loading logic (#16435)
---
 .../infra/binder/SQLStatementContextFactory.java   |  18 +-
 .../statement/dml/InsertStatementContext.java      |  18 +-
 .../statement/dml/SelectStatementContext.java      |  18 +-
 .../infra/database/type/DatabaseType.java          |  27 +-
 .../database/type/dialect/H2DatabaseType.java      |  14 +-
 .../database/type/dialect/MariaDBDatabaseType.java |  10 +-
 .../database/type/dialect/MySQLDatabaseType.java   |  18 +-
 .../type/dialect/OpenGaussDatabaseType.java        |  10 +-
 .../database/type/dialect/OracleDatabaseType.java  |  14 +-
 .../type/dialect/PostgreSQLDatabaseType.java       |  17 +-
 .../database/type/dialect/SQL92DatabaseType.java   |  10 +-
 .../type/dialect/SQLServerDatabaseType.java        |  10 +-
 .../infra/metadata/ShardingSphereMetaData.java     |  11 +-
 .../builder/dialect/MySQLSystemSchemaBuilder.java  |  19 +-
 .../dialect/PostgreSQLSystemSchemaBuilder.java     |  21 +-
 .../builder/spi/DialectSystemSchemaBuilder.java    |  13 +
 .../resources/schema/mysql/information_schema.yaml |  16 +
 .../src/main/resources/schema/mysql/mysql.yaml     |  16 +
 .../resources/schema/mysql/performance_schema.yaml |  16 +
 .../src/main/resources/schema/mysql/sys.yaml       |  16 +
 .../schema/postgresql/information_schema.yaml      | 423 +++++++++++++++++++++
 .../resources/schema/postgresql/pg_catalog.yaml    | 148 +++++++
 .../type/dialect/MySQLDatabaseTypeTest.java        |  16 +-
 .../type/dialect/PostgreSQLDatabaseTypeTest.java   |  15 +-
 .../executor/FederationExecutorFactory.java        |   6 +-
 .../original/OriginalFilterableExecutor.java       |   8 +-
 .../table/FilterableTableScanExecutor.java         |   9 +-
 .../driver/executor/DriverExecutor.java            |   2 +-
 .../mode/metadata/MetaDataContextsBuilder.java     |  14 +-
 .../cluster/ClusterContextManagerBuilder.java      |   2 +-
 .../StandaloneContextManagerBuilder.java           |   2 +-
 .../jdbc/JDBCDatabaseCommunicationEngine.java      |  21 +-
 .../text/TextProtocolBackendHandlerFactory.java    |   4 +-
 .../admin/mysql/executor/ShowTablesExecutor.java   |   2 +-
 .../impl/SchemaAssignedDatabaseBackendHandler.java |  17 +-
 .../ral/advanced/PreviewDistSQLBackendHandler.java |   2 +-
 .../DatabaseCommunicationEngineFactoryTest.java    |  12 +-
 .../jdbc/JDBCDatabaseCommunicationEngineTest.java  |  20 +-
 .../SchemaAssignedDatabaseBackendHandlerTest.java  |   4 +-
 .../frontend/fixture/FixtureDatabaseType.java      |  10 +-
 .../protocol/fixture/DummyDatabaseType.java        |  10 +-
 41 files changed, 905 insertions(+), 154 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
index 1947175..ae1474d 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
@@ -107,11 +107,11 @@ public final class SQLStatementContextFactory {
      *
      * @param metaDataMap metaData map
      * @param sqlStatement SQL statement
-     * @param defaultSchemaName default schema name
+     * @param defaultDatabaseName default database name
      * @return SQL statement context
      */
-    public static SQLStatementContext<?> newInstance(final Map<String, ShardingSphereMetaData> metaDataMap, final SQLStatement sqlStatement, final String defaultSchemaName) {
-        return newInstance(metaDataMap, Collections.emptyList(), sqlStatement, defaultSchemaName);
+    public static SQLStatementContext<?> newInstance(final Map<String, ShardingSphereMetaData> metaDataMap, final SQLStatement sqlStatement, final String defaultDatabaseName) {
+        return newInstance(metaDataMap, Collections.emptyList(), sqlStatement, defaultDatabaseName);
     }
     
     /**
@@ -120,13 +120,13 @@ public final class SQLStatementContextFactory {
      * @param metaDataMap metaData map
      * @param parameters SQL parameters
      * @param sqlStatement SQL statement
-     * @param defaultSchemaName default schema name
+     * @param defaultDatabaseName default database name
      * @return SQL statement context
      */
     public static SQLStatementContext<?> newInstance(final Map<String, ShardingSphereMetaData> metaDataMap, final List<Object> parameters,
-                                                     final SQLStatement sqlStatement, final String defaultSchemaName) {
+                                                     final SQLStatement sqlStatement, final String defaultDatabaseName) {
         if (sqlStatement instanceof DMLStatement) {
-            return getDMLStatementContext(metaDataMap, parameters, (DMLStatement) sqlStatement, defaultSchemaName);
+            return getDMLStatementContext(metaDataMap, parameters, (DMLStatement) sqlStatement, defaultDatabaseName);
         }
         if (sqlStatement instanceof DDLStatement) {
             return getDDLStatementContext((DDLStatement) sqlStatement);
@@ -141,9 +141,9 @@ public final class SQLStatementContextFactory {
     }
     
     private static SQLStatementContext<?> getDMLStatementContext(final Map<String, ShardingSphereMetaData> metaDataMap, final List<Object> parameters,
-                                                                 final DMLStatement sqlStatement, final String defaultSchemaName) {
+                                                                 final DMLStatement sqlStatement, final String defaultDatabaseName) {
         if (sqlStatement instanceof SelectStatement) {
-            return new SelectStatementContext(metaDataMap, parameters, (SelectStatement) sqlStatement, defaultSchemaName);
+            return new SelectStatementContext(metaDataMap, parameters, (SelectStatement) sqlStatement, defaultDatabaseName);
         }
         if (sqlStatement instanceof UpdateStatement) {
             return new UpdateStatementContext((UpdateStatement) sqlStatement);
@@ -152,7 +152,7 @@ public final class SQLStatementContextFactory {
             return new DeleteStatementContext((DeleteStatement) sqlStatement);
         }
         if (sqlStatement instanceof InsertStatement) {
-            return new InsertStatementContext(metaDataMap, parameters, (InsertStatement) sqlStatement, defaultSchemaName);
+            return new InsertStatementContext(metaDataMap, parameters, (InsertStatement) sqlStatement, defaultDatabaseName);
         }
         if (sqlStatement instanceof CallStatement) {
             return new CallStatementContext((CallStatement) sqlStatement);
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java
index 5f77820..d335afa 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java
@@ -64,7 +64,7 @@ public final class InsertStatementContext extends CommonSQLStatementContext<Inse
     
     private final Map<String, ShardingSphereMetaData> metaDataMap;
     
-    private final String defaultSchemaName;
+    private final String defaultDatabaseName;
     
     private final List<String> insertColumnNames;
     
@@ -79,18 +79,18 @@ public final class InsertStatementContext extends CommonSQLStatementContext<Inse
     private GeneratedKeyContext generatedKeyContext;
     
     public InsertStatementContext(final Map<String, ShardingSphereMetaData> metaDataMap, final List<Object> parameters,
-                                  final InsertStatement sqlStatement, final String defaultSchemaName) {
+                                  final InsertStatement sqlStatement, final String defaultDatabaseName) {
         super(sqlStatement);
         this.metaDataMap = metaDataMap;
-        this.defaultSchemaName = defaultSchemaName;
+        this.defaultDatabaseName = defaultDatabaseName;
         insertColumnNames = getInsertColumnNames();
         valueExpressions = getAllValueExpressions(sqlStatement);
         AtomicInteger parametersOffset = new AtomicInteger(0);
         insertValueContexts = getInsertValueContexts(parameters, parametersOffset, valueExpressions);
-        insertSelectContext = getInsertSelectContext(metaDataMap, parameters, parametersOffset, defaultSchemaName).orElse(null);
+        insertSelectContext = getInsertSelectContext(metaDataMap, parameters, parametersOffset, defaultDatabaseName).orElse(null);
         onDuplicateKeyUpdateValueContext = getOnDuplicateKeyUpdateValueContext(parameters, parametersOffset).orElse(null);
         tablesContext = new TablesContext(getAllSimpleTableSegments(), getDatabaseType());
-        ShardingSphereSchema schema = getSchema(metaDataMap, defaultSchemaName);
+        ShardingSphereSchema schema = getSchema(metaDataMap, defaultDatabaseName);
         columnNames = useDefaultColumns() ? schema.getAllColumnNames(sqlStatement.getTable().getTableName().getIdentifier().getValue()) : insertColumnNames;
         generatedKeyContext = new GeneratedKeyContextEngine(sqlStatement, schema)
                 .createGenerateKeyContext(insertColumnNames, getAllValueExpressions(sqlStatement), parameters).orElse(null);
@@ -122,12 +122,12 @@ public final class InsertStatementContext extends CommonSQLStatementContext<Inse
     }
     
     private Optional<InsertSelectContext> getInsertSelectContext(final Map<String, ShardingSphereMetaData> metaDataMap, final List<Object> parameters, 
-                                                                 final AtomicInteger parametersOffset, final String defaultSchemaName) {
+                                                                 final AtomicInteger parametersOffset, final String defaultDatabaseName) {
         if (!getSqlStatement().getInsertSelect().isPresent()) {
             return Optional.empty();
         }
         SubquerySegment insertSelectSegment = getSqlStatement().getInsertSelect().get();
-        SelectStatementContext selectStatementContext = new SelectStatementContext(metaDataMap, parameters, insertSelectSegment.getSelect(), defaultSchemaName);
+        SelectStatementContext selectStatementContext = new SelectStatementContext(metaDataMap, parameters, insertSelectSegment.getSelect(), defaultDatabaseName);
         InsertSelectContext insertSelectContext = new InsertSelectContext(selectStatementContext, parameters, parametersOffset.get());
         parametersOffset.addAndGet(insertSelectContext.getParameterCount());
         return Optional.of(insertSelectContext);
@@ -269,9 +269,9 @@ public final class InsertStatementContext extends CommonSQLStatementContext<Inse
     public void setUpParameters(final List<Object> parameters) {
         AtomicInteger parametersOffset = new AtomicInteger(0);
         insertValueContexts = getInsertValueContexts(parameters, parametersOffset, valueExpressions);
-        insertSelectContext = getInsertSelectContext(metaDataMap, parameters, parametersOffset, defaultSchemaName).orElse(null);
+        insertSelectContext = getInsertSelectContext(metaDataMap, parameters, parametersOffset, defaultDatabaseName).orElse(null);
         onDuplicateKeyUpdateValueContext = getOnDuplicateKeyUpdateValueContext(parameters, parametersOffset).orElse(null);
-        ShardingSphereSchema schema = getSchema(metaDataMap, defaultSchemaName);
+        ShardingSphereSchema schema = getSchema(metaDataMap, defaultDatabaseName);
         generatedKeyContext = new GeneratedKeyContextEngine(getSqlStatement(), schema).createGenerateKeyContext(insertColumnNames, valueExpressions, parameters).orElse(null);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
index bd40fd0..7c229b0 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
@@ -102,13 +102,13 @@ public final class SelectStatementContext extends CommonSQLStatementContext<Sele
     private PaginationContext paginationContext;
     
     public SelectStatementContext(final Map<String, ShardingSphereMetaData> metaDataMap, final List<Object> parameters,
-                                  final SelectStatement sqlStatement, final String defaultSchemaName) {
+                                  final SelectStatement sqlStatement, final String defaultDatabaseName) {
         super(sqlStatement);
         extractWhereSegments(whereSegments, sqlStatement);
         ColumnExtractor.extractColumnSegments(columnSegments, whereSegments);
-        subqueryContexts = createSubqueryContexts(metaDataMap, parameters, defaultSchemaName);
+        subqueryContexts = createSubqueryContexts(metaDataMap, parameters, defaultDatabaseName);
         tablesContext = new TablesContext(getAllTableSegments(), subqueryContexts, getDatabaseType());
-        ShardingSphereSchema schema = getSchema(metaDataMap, defaultSchemaName);
+        ShardingSphereSchema schema = getSchema(metaDataMap, defaultDatabaseName);
         groupByContext = new GroupByContextEngine().createGroupByContext(sqlStatement);
         orderByContext = new OrderByContextEngine().createOrderBy(sqlStatement, groupByContext);
         projectionsContext = new ProjectionsContextEngine(schema, getDatabaseType())
@@ -117,22 +117,22 @@ public final class SelectStatementContext extends CommonSQLStatementContext<Sele
     }
     
     private Map<Integer, SelectStatementContext> createSubqueryContexts(final Map<String, ShardingSphereMetaData> metaDataMap, 
-                                                                        final List<Object> parameters, final String defaultSchemaName) {
+                                                                        final List<Object> parameters, final String defaultDatabaseName) {
         Collection<SubquerySegment> subquerySegments = SubqueryExtractUtil.getSubquerySegments(getSqlStatement());
         Map<Integer, SelectStatementContext> result = new HashMap<>(subquerySegments.size(), 1);
         for (SubquerySegment each : subquerySegments) {
-            SelectStatementContext subqueryContext = new SelectStatementContext(metaDataMap, parameters, each.getSelect(), defaultSchemaName);
+            SelectStatementContext subqueryContext = new SelectStatementContext(metaDataMap, parameters, each.getSelect(), defaultDatabaseName);
             subqueryContext.setSubqueryType(each.getSubqueryType());
             result.put(each.getStartIndex(), subqueryContext);
         }
         return result;
     }
     
-    private ShardingSphereSchema getSchema(final Map<String, ShardingSphereMetaData> metaDataMap, final String defaultSchemaName) {
-        String schemaName = tablesContext.getDatabaseName().orElse(defaultSchemaName);
-        ShardingSphereMetaData metaData = metaDataMap.get(schemaName);
+    private ShardingSphereSchema getSchema(final Map<String, ShardingSphereMetaData> metaDataMap, final String defaultDatabaseName) {
+        String databaseName = tablesContext.getDatabaseName().orElse(defaultDatabaseName);
+        ShardingSphereMetaData metaData = metaDataMap.get(databaseName);
         if (null == metaData) {
-            throw new SchemaNotExistedException(schemaName);
+            throw new SchemaNotExistedException(databaseName);
         }
         return metaData.getSchema();
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseType.java
index a5dec25..85a395c 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/DatabaseType.java
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Collection;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -70,11 +69,18 @@ public interface DatabaseType {
     Optional<String> getDataSourceClassName();
     
     /**
-     * Get system schemas.
+     * Get system databases.
      * 
+     * @return system databases
+     */
+    Collection<String> getSystemDatabases();
+    
+    /**
+     * Get system schemas.
+     *
      * @return system schemas
      */
-    Map<String, Collection<String>> getSystemSchemas();
+    Collection<String> getSystemSchemas();
     
     /**
      * Get schema.
@@ -110,19 +116,4 @@ public interface DatabaseType {
      */
     default void handleRollbackOnly(final boolean rollbackOnly, final SQLStatement statement) throws SQLException {
     }
-    
-    /**
-     * Judge whether contains system schema or not.
-     * 
-     * @param schemaName schema name
-     * @return whether contains system schema or not
-     */
-    default boolean containsSystemSchema(final String schemaName) {
-        for (Collection<String> each : getSystemSchemas().values()) {
-            if (each.contains(schemaName)) {
-                return true;
-            }
-        }
-        return false;
-    }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/H2DatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/H2DatabaseType.java
index 12d4477..363585a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/H2DatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/H2DatabaseType.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -59,12 +58,17 @@ public final class H2DatabaseType implements BranchDatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public DatabaseType getTrunkDatabaseType() {
+        return DatabaseTypeRegistry.getActualDatabaseType("MySQL");
     }
     
     @Override
-    public DatabaseType getTrunkDatabaseType() {
-        return DatabaseTypeRegistry.getActualDatabaseType("MySQL");
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MariaDBDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MariaDBDatabaseType.java
index 6f57384..659086d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MariaDBDatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MariaDBDatabaseType.java
@@ -25,7 +25,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -64,7 +63,12 @@ public final class MariaDBDatabaseType implements BranchDatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseType.java
index f15d14e..7ae18fe 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseType.java
@@ -24,8 +24,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -33,6 +31,8 @@ import java.util.Optional;
  */
 public final class MySQLDatabaseType implements DatabaseType {
     
+    private static final Collection<String> SYSTEM_DATABASES = Sets.newHashSet("information_schema", "performance_schema", "mysql", "sys");
+    
     @Override
     public String getName() {
         return "MySQL";
@@ -59,12 +59,12 @@ public final class MySQLDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        Map<String, Collection<String>> result = new LinkedHashMap<>();
-        result.put("information_schema", Sets.newHashSet("information_schema"));
-        result.put("performance_schema", Sets.newHashSet("performance_schema"));
-        result.put("mysql", Sets.newHashSet("mysql"));
-        result.put("sys", Sets.newHashSet("sys"));
-        return result;
+    public Collection<String> getSystemDatabases() {
+        return SYSTEM_DATABASES;
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return SYSTEM_DATABASES;
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OpenGaussDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OpenGaussDatabaseType.java
index 1c10d7c..2e12ddf 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OpenGaussDatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OpenGaussDatabaseType.java
@@ -28,7 +28,6 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -69,7 +68,12 @@ public final class OpenGaussDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OracleDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OracleDatabaseType.java
index 282d334..c6ce9b0 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OracleDatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OracleDatabaseType.java
@@ -25,7 +25,6 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -69,12 +68,17 @@ public final class OracleDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public String formatTableNamePattern(final String tableNamePattern) {
+        return tableNamePattern.toUpperCase();
     }
     
     @Override
-    public String formatTableNamePattern(final String tableNamePattern) {
-        return tableNamePattern.toUpperCase();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseType.java
index 5c90b3f..df3ca3d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseType.java
@@ -29,8 +29,6 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -38,6 +36,10 @@ import java.util.Optional;
  */
 public final class PostgreSQLDatabaseType implements DatabaseType {
     
+    private static final Collection<String> SYSTEM_DATABASES = Sets.newHashSet("postgres");
+    
+    private static final Collection<String> SYSTEM_SCHEMAS = Sets.newHashSet("information_schema", "pg_catalog");
+    
     @Override
     public String getName() {
         return "PostgreSQL";
@@ -71,9 +73,12 @@ public final class PostgreSQLDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        Map<String, Collection<String>> result = new LinkedHashMap<>();
-        result.put("postgres", Sets.newHashSet("information_schema", "pg_catalog"));
-        return result;
+    public Collection<String> getSystemDatabases() {
+        return SYSTEM_DATABASES;
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return SYSTEM_SCHEMAS;
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQL92DatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQL92DatabaseType.java
index 48f645b..30aa869 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQL92DatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQL92DatabaseType.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -57,7 +56,12 @@ public final class SQL92DatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQLServerDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQLServerDatabaseType.java
index 3ca979a..c1c0f56 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQLServerDatabaseType.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/SQLServerDatabaseType.java
@@ -24,7 +24,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -58,7 +57,12 @@ public final class SQLServerDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
index e8b1992..b17e629 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
@@ -58,18 +58,19 @@ public final class ShardingSphereMetaData {
      * @param schemas schemas
      * @param schemaConfig schema configuration
      * @param rules rules
+     * @param defaultDatabaseType default database type
      * @return ShardingSphere meta data
      * @throws SQLException SQL exception
      */
-    public static ShardingSphereMetaData create(final String databaseName, final Map<String, ShardingSphereSchema> schemas, final SchemaConfiguration schemaConfig,
-                                                final Collection<ShardingSphereRule> rules) throws SQLException {
-        ShardingSphereResource resource = createResource(schemaConfig.getDataSources());
+    public static ShardingSphereMetaData create(final String databaseName, final Map<String, ShardingSphereSchema> schemas, final SchemaConfiguration schemaConfig, 
+                                                final Collection<ShardingSphereRule> rules, final DatabaseType defaultDatabaseType) throws SQLException {
+        ShardingSphereResource resource = createResource(schemaConfig.getDataSources(), defaultDatabaseType);
         ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(schemaConfig.getRuleConfigurations(), rules);
         return new ShardingSphereMetaData(databaseName, resource, ruleMetaData, schemas);
     }
     
-    private static ShardingSphereResource createResource(final Map<String, DataSource> dataSourceMap) throws SQLException {
-        DatabaseType databaseType = DatabaseTypeRecognizer.getDatabaseType(dataSourceMap.values());
+    private static ShardingSphereResource createResource(final Map<String, DataSource> dataSourceMap, final DatabaseType defaultDatabaseType) throws SQLException {
+        DatabaseType databaseType = dataSourceMap.isEmpty() ? defaultDatabaseType : DatabaseTypeRecognizer.getDatabaseType(dataSourceMap.values());
         DataSourcesMetaData dataSourcesMetaData = new DataSourcesMetaData(databaseType, dataSourceMap);
         CachedDatabaseMetaData cachedDatabaseMetaData = createCachedDatabaseMetaData(dataSourceMap).orElse(null);
         return new ShardingSphereResource(dataSourceMap, dataSourcesMetaData, cachedDatabaseMetaData, databaseType);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/MySQLSystemSchemaBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/MySQLSystemSchemaBuilder.java
index b9d6bd1..8da7d10 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/MySQLSystemSchemaBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/MySQLSystemSchemaBuilder.java
@@ -17,27 +17,38 @@
 
 package org.apache.shardingsphere.infra.metadata.schema.builder.dialect;
 
+import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectSystemSchemaBuilder;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlSchema;
+import org.apache.shardingsphere.infra.yaml.schema.swapper.SchemaYamlSwapper;
 
-import java.util.Collections;
+import java.io.File;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * MySQL system schema builder.
  */
 public final class MySQLSystemSchemaBuilder implements DialectSystemSchemaBuilder {
     
+    @SneakyThrows
     @Override
     public Map<String, ShardingSphereSchema> build(final String schemaName) {
         Map<String, ShardingSphereSchema> result = new LinkedHashMap<>();
         DatabaseType databaseType = DatabaseTypeRegistry.getTrunkDatabaseType(getDatabaseType());
-        for (String each : databaseType.getSystemSchemas().getOrDefault(schemaName, Collections.emptyList())) {
-            // TODO build ShardingSphereSchema according to MySQL schema
-            result.put(each, new ShardingSphereSchema(Collections.emptyMap()));
+        SchemaYamlSwapper swapper = new SchemaYamlSwapper();
+        for (String each : databaseType.getSystemDatabases()) {
+            Optional<String> schemaPath = getSystemSchemaPath(each);
+            if (!schemaPath.isPresent()) {
+                continue;
+            }
+            YamlSchema yamlSchema = YamlEngine.unmarshal(new File(schemaPath.get()), YamlSchema.class);
+            result.put(each, swapper.swapToObject(yamlSchema));
         }
         return result;
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/PostgreSQLSystemSchemaBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/PostgreSQLSystemSchemaBuilder.java
index 63b616e..197730f 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/PostgreSQLSystemSchemaBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/dialect/PostgreSQLSystemSchemaBuilder.java
@@ -17,29 +17,38 @@
 
 package org.apache.shardingsphere.infra.metadata.schema.builder.dialect;
 
+import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectSystemSchemaBuilder;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlSchema;
+import org.apache.shardingsphere.infra.yaml.schema.swapper.SchemaYamlSwapper;
 
-import java.util.Collections;
+import java.io.File;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * PostgreSQL system schema builder.
  */
 public final class PostgreSQLSystemSchemaBuilder implements DialectSystemSchemaBuilder {
     
-    private static final String POSTGRES_DEFAULT_DATABASE = "postgres";
-    
+    @SneakyThrows
     @Override
     public Map<String, ShardingSphereSchema> build(final String schemaName) {
         Map<String, ShardingSphereSchema> result = new LinkedHashMap<>();
         DatabaseType databaseType = DatabaseTypeRegistry.getTrunkDatabaseType(getDatabaseType());
-        for (String each : databaseType.getSystemSchemas().getOrDefault(POSTGRES_DEFAULT_DATABASE, Collections.emptyList())) {
-            // TODO build ShardingSphereSchema according to PostgreSQL schema
-            result.put(each, new ShardingSphereSchema(Collections.emptyMap()));
+        SchemaYamlSwapper swapper = new SchemaYamlSwapper();
+        for (String each : databaseType.getSystemSchemas()) {
+            Optional<String> schemaPath = getSystemSchemaPath(each);
+            if (!schemaPath.isPresent()) {
+                continue;
+            }
+            YamlSchema yamlSchema = YamlEngine.unmarshal(new File(schemaPath.get()), YamlSchema.class);
+            result.put(each, swapper.swapToObject(yamlSchema));
         }
         return result;
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/spi/DialectSystemSchemaBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/spi/DialectSystemSchemaBuilder.java
index addbf7f..9bb47e0 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/spi/DialectSystemSchemaBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/spi/DialectSystemSchemaBuilder.java
@@ -21,7 +21,9 @@ import org.apache.shardingsphere.infra.database.type.DatabaseTypeAwareSPI;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.spi.singleton.SingletonSPI;
 
+import java.net.URL;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * Dialect system schema builder.
@@ -35,4 +37,15 @@ public interface DialectSystemSchemaBuilder extends DatabaseTypeAwareSPI, Single
      * @return ShardingSphere schema map
      */
     Map<String, ShardingSphereSchema> build(String schemaName);
+    
+    /**
+     * Get system schema content.
+     * 
+     * @param schemaName schema name
+     * @return system schema content
+     */
+    default Optional<String> getSystemSchemaPath(final String schemaName) {
+        URL url = getClass().getResource("schema/" + getDatabaseType().toLowerCase() + "/" + schemaName + ".yaml");
+        return Optional.ofNullable(url).map(URL::getFile);
+    }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/information_schema.yaml b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/information_schema.yaml
new file mode 100644
index 0000000..b1312a0
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/information_schema.yaml
@@ -0,0 +1,16 @@
+#
+# 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.
+#
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/mysql.yaml b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/mysql.yaml
new file mode 100644
index 0000000..b1312a0
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/mysql.yaml
@@ -0,0 +1,16 @@
+#
+# 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.
+#
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/performance_schema.yaml b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/performance_schema.yaml
new file mode 100644
index 0000000..b1312a0
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/performance_schema.yaml
@@ -0,0 +1,16 @@
+#
+# 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.
+#
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/sys.yaml b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/sys.yaml
new file mode 100644
index 0000000..b1312a0
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/mysql/sys.yaml
@@ -0,0 +1,16 @@
+#
+# 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.
+#
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/postgresql/information_schema.yaml b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/postgresql/information_schema.yaml
new file mode 100644
index 0000000..7213ca7
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/postgresql/information_schema.yaml
@@ -0,0 +1,423 @@
+#
+# 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.
+#
+
+tables:
+  columns:
+    name: columns
+    columns:
+      table_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_catalog
+        primaryKey: false
+      table_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_schema
+        primaryKey: false
+      table_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_name
+        primaryKey: false
+      column_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: column_name
+        primaryKey: false
+      ordinal_position:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: ordinal_position
+        primaryKey: false
+      column_default:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: column_default
+        primaryKey: false
+      is_nullable:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_nullable
+        primaryKey: false
+      data_type:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: data_type
+        primaryKey: false
+      character_maximum_length:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: character_maximum_length
+        primaryKey: false
+      character_octet_length:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: character_octet_length
+        primaryKey: false
+      numeric_precision:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: numeric_precision
+        primaryKey: false
+      numeric_precision_radix:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: numeric_precision_radix
+        primaryKey: false
+      numeric_scale:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: numeric_scale
+        primaryKey: false
+      datetime_precision:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: datetime_precision
+        primaryKey: false
+      interval_type:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: interval_type
+        primaryKey: false
+      interval_precision:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: interval_precision
+        primaryKey: false
+      character_set_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: character_set_catalog
+        primaryKey: false
+      character_set_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: character_set_schema
+        primaryKey: false
+      character_set_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: character_set_name
+        primaryKey: false
+      collation_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: collation_catalog
+        primaryKey: false
+      collation_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: collation_schema
+        primaryKey: false
+      collation_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: collation_name
+        primaryKey: false
+      domain_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: domain_catalog
+        primaryKey: false
+      domain_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: domain_schema
+        primaryKey: false
+      domain_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: domain_name
+        primaryKey: false
+      udt_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: udt_catalog
+        primaryKey: false
+      udt_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: udt_schema
+        primaryKey: false
+      udt_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: udt_name
+        primaryKey: false
+      scope_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: scope_catalog
+        primaryKey: false
+      scope_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: scope_schema
+        primaryKey: false
+      scope_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: scope_name
+        primaryKey: false
+      maximum_cardinality:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: maximum_cardinality
+        primaryKey: false
+      dtd_identifier:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: dtd_identifier
+        primaryKey: false
+      is_self_referencing:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_self_referencing
+        primaryKey: false
+      is_identity:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_identity
+        primaryKey: false
+      identity_generation:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: identity_generation
+        primaryKey: false
+      identity_start:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: identity_start
+        primaryKey: false
+      identity_increment:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: identity_increment
+        primaryKey: false
+      identity_maximum:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: identity_maximum
+        primaryKey: false
+      identity_minimum:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: identity_minimum
+        primaryKey: false
+      identity_cycle:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: identity_cycle
+        primaryKey: false
+      is_generated:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_generated
+        primaryKey: false
+      generation_expression:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: generation_expression
+        primaryKey: false
+      is_updatable:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_updatable
+        primaryKey: false
+  tables:
+    name: tables
+    columns:
+      table_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_catalog
+        primaryKey: false
+      table_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_schema
+        primaryKey: false
+      table_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_name
+        primaryKey: false
+      table_type:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_type
+        primaryKey: false
+      self_referencing_column_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: self_referencing_column_name
+        primaryKey: false
+      reference_generation:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: reference_generation
+        primaryKey: false
+      user_defined_type_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: user_defined_type_catalog
+        primaryKey: false
+      user_defined_type_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: user_defined_type_schema
+        primaryKey: false
+      user_defined_type_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: user_defined_type_name
+        primaryKey: false
+      is_insertable_into:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_insertable_into
+        primaryKey: false
+      is_typed:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_typed
+        primaryKey: false
+      commit_action:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: commit_action
+        primaryKey: false
+  views:
+    name: views
+    columns:
+      table_catalog:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_catalog
+        primaryKey: false
+      table_schema:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_schema
+        primaryKey: false
+      table_name:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: table_name
+        primaryKey: false
+      view_definition:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: view_definition
+        primaryKey: false
+      check_option:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: check_option
+        primaryKey: false
+      is_updatable:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_updatable
+        primaryKey: false
+      is_insertable_into:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_insertable_into
+        primaryKey: false
+      is_trigger_updatable:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_trigger_updatable
+        primaryKey: false
+      is_trigger_deletable:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_trigger_deletable
+        primaryKey: false
+      is_trigger_insertable_into:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: is_trigger_insertable_into
+        primaryKey: false
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/postgresql/pg_catalog.yaml b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/postgresql/pg_catalog.yaml
new file mode 100644
index 0000000..3568360
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/schema/postgresql/pg_catalog.yaml
@@ -0,0 +1,148 @@
+#
+# 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.
+#
+
+tables:
+  pg_database:
+    name: pg_database
+    columns:
+      oid:
+        caseSensitive: true
+        dataType: -5
+        generated: false
+        name: oid
+        primaryKey: false
+      datname:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: datname
+        primaryKey: false
+      datdba:
+        caseSensitive: true
+        dataType: -5
+        generated: false
+        name: datdba
+        primaryKey: false
+      encoding:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: encoding
+        primaryKey: false
+      datcollate:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: datcollate
+        primaryKey: false
+      datctype:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: datctype
+        primaryKey: false
+      datistemplate:
+        caseSensitive: true
+        dataType: -7
+        generated: false
+        name: datistemplate
+        primaryKey: false
+      datallowconn:
+        caseSensitive: true
+        dataType: -7
+        generated: false
+        name: datallowconn
+        primaryKey: false
+      datconnlimit:
+        caseSensitive: true
+        dataType: 4
+        generated: false
+        name: datconnlimit
+        primaryKey: false
+      datlastsysoid:
+        caseSensitive: true
+        dataType: -5
+        generated: false
+        name: datlastsysoid
+        primaryKey: false
+      datfrozenxid:
+        caseSensitive: true
+        dataType: 1111
+        generated: false
+        name: datfrozenxid
+        primaryKey: false
+      datminmxid:
+        caseSensitive: true
+        dataType: 1111
+        generated: false
+        name: datminmxid
+        primaryKey: false
+      dattablespace:
+        caseSensitive: true
+        dataType: -5
+        generated: false
+        name: dattablespace
+        primaryKey: false
+      datacl:
+        caseSensitive: true
+        dataType: 2003
+        generated: false
+        name: datacl
+        primaryKey: false
+    indexes:
+      pg_database_datname_index:
+        name: pg_database_datname_index
+      pg_database_oid_index:
+        name: pg_database_oid_index 
+  pg_tablespace:
+    name: pg_tablespace
+    columns:
+      oid:
+        caseSensitive: true
+        dataType: -5
+        generated: false
+        name: oid
+        primaryKey: false
+      spcname:
+        caseSensitive: true
+        dataType: 12
+        generated: false
+        name: spcname
+        primaryKey: false
+      spcowner:
+        caseSensitive: true
+        dataType: -5
+        generated: false
+        name: spcowner
+        primaryKey: false
+      spcacl:
+        caseSensitive: true
+        dataType: 2003
+        generated: false
+        name: spcacl
+        primaryKey: false
+      spcoptions:
+        caseSensitive: true
+        dataType: 2003
+        generated: false
+        name: spcoptions
+        primaryKey: false
+    indexes:
+      pg_tablespace_oid_index:
+        name: pg_tablespace_oid_index
+      pg_tablespace_spcname_index:
+        name: pg_tablespace_spcname_index
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseTypeTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseTypeTest.java
index 71fc649..1cd4b88 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseTypeTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/MySQLDatabaseTypeTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.infra.database.type.dialect;
 
+import com.google.common.collect.Sets;
 import org.apache.shardingsphere.infra.database.metadata.dialect.MySQLDataSourceMetaData;
 import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 import org.junit.Test;
@@ -27,9 +28,7 @@ import java.util.Arrays;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -70,11 +69,12 @@ public final class MySQLDatabaseTypeTest {
     }
     
     @Test
-    public void assertContainsSystemSchema() {
-        assertTrue(new MySQLDatabaseType().containsSystemSchema("information_schema"));
-        assertTrue(new MySQLDatabaseType().containsSystemSchema("performance_schema"));
-        assertTrue(new MySQLDatabaseType().containsSystemSchema("mysql"));
-        assertTrue(new MySQLDatabaseType().containsSystemSchema("sys"));
-        assertFalse(new MySQLDatabaseType().containsSystemSchema("sharding_db"));
+    public void assertGetSystemDatabases() {
+        assertThat(new MySQLDatabaseType().getSystemDatabases(), is(Sets.newHashSet("information_schema", "performance_schema", "mysql", "sys")));
+    }
+    
+    @Test
+    public void assertGetSystemSchemas() {
+        assertThat(new MySQLDatabaseType().getSystemSchemas(), is(Sets.newHashSet("information_schema", "performance_schema", "mysql", "sys")));
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseTypeTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseTypeTest.java
index 94fb3fa..b166997 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseTypeTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/dialect/PostgreSQLDatabaseTypeTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.infra.database.type.dialect;
 
+import com.google.common.collect.Sets;
 import org.apache.shardingsphere.infra.database.metadata.dialect.PostgreSQLDataSourceMetaData;
 import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 import org.junit.Test;
@@ -27,9 +28,7 @@ import java.util.Collections;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -70,10 +69,12 @@ public final class PostgreSQLDatabaseTypeTest {
     }
     
     @Test
-    public void assertContainsSystemSchema() {
-        assertTrue(new PostgreSQLDatabaseType().containsSystemSchema("information_schema"));
-        assertTrue(new PostgreSQLDatabaseType().containsSystemSchema("pg_catalog"));
-        assertFalse(new MySQLDatabaseType().containsSystemSchema("postgres"));
-        assertFalse(new MySQLDatabaseType().containsSystemSchema("sharding_db"));
+    public void assertGetSystemDatabases() {
+        assertThat(new PostgreSQLDatabaseType().getSystemDatabases(), is(Sets.newHashSet("postgres")));
+    }
+    
+    @Test
+    public void assertGetSystemSchemas() {
+        assertThat(new PostgreSQLDatabaseType().getSystemSchemas(), is(Sets.newHashSet("information_schema", "pg_catalog")));
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/FederationExecutorFactory.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/FederationExecutorFactory.java
index 33675f7..554c486 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/FederationExecutorFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/FederationExecutorFactory.java
@@ -33,14 +33,16 @@ public final class FederationExecutorFactory {
     /**
      * Create new instance of federation executor factory.
      * 
+     * @param databaseName database name
      * @param schemaName schema name
      * @param optimizerContext filterable optimizer context 
      * @param props configuration properties
      * @param jdbcExecutor jdbc executor
      * @return new instance of federation executor
      */
-    public static FederationExecutor newInstance(final String schemaName, final OptimizerContext optimizerContext, final ConfigurationProperties props, final JDBCExecutor jdbcExecutor) {
+    public static FederationExecutor newInstance(final String databaseName, final String schemaName, final OptimizerContext optimizerContext, 
+                                                 final ConfigurationProperties props, final JDBCExecutor jdbcExecutor) {
         // TODO Consider about CustomizedFilterableExecutor
-        return new OriginalFilterableExecutor(schemaName, optimizerContext, props, jdbcExecutor);
+        return new OriginalFilterableExecutor(databaseName, schemaName, optimizerContext, props, jdbcExecutor);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/OriginalFilterableExecutor.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/OriginalFilterableExecutor.java
index 57f4c47..220ca81 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/OriginalFilterableExecutor.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/OriginalFilterableExecutor.java
@@ -51,6 +51,8 @@ public final class OriginalFilterableExecutor implements FederationExecutor {
     
     public static final String DRIVER_NAME = "org.apache.calcite.jdbc.Driver";
     
+    private final String databaseName;
+    
     private final String schemaName;
     
     private final OptimizerContext optimizerContext;
@@ -82,16 +84,16 @@ public final class OriginalFilterableExecutor implements FederationExecutor {
     
     private Connection createConnection(final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine, 
                                         final JDBCExecutorCallback<? extends ExecuteResult> callback, final FederationContext federationContext) throws SQLException {
-        Connection result = DriverManager.getConnection(CONNECTION_URL, optimizerContext.getParserContexts().get(schemaName).getDialectProps());
+        Connection result = DriverManager.getConnection(CONNECTION_URL, optimizerContext.getParserContexts().get(databaseName).getDialectProps());
         addSchema(result.unwrap(CalciteConnection.class), prepareEngine, callback, federationContext);
         return result;
     }
     
     private void addSchema(final CalciteConnection connection, final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine, 
                            final JDBCExecutorCallback<? extends ExecuteResult> callback, final FederationContext federationContext) throws SQLException {
-        FilterableTableScanExecutorContext executorContext = new FilterableTableScanExecutorContext(schemaName, schemaName, props, federationContext);
+        FilterableTableScanExecutorContext executorContext = new FilterableTableScanExecutorContext(databaseName, schemaName, props, federationContext);
         FilterableTableScanExecutor executor = new FilterableTableScanExecutor(prepareEngine, jdbcExecutor, callback, optimizerContext, executorContext);
-        FilterableDatabase database = new FilterableDatabase(optimizerContext.getFederationMetaData().getDatabases().get(schemaName), executor);
+        FilterableDatabase database = new FilterableDatabase(optimizerContext.getFederationMetaData().getDatabases().get(databaseName), executor);
         // TODO support database.schema.table query when switch to CustomizedFilterableExecutor, calcite jdbc just support schema.table query now
         connection.getRootSchema().add(schemaName, database.getSubSchema(schemaName));
         connection.setSchema(schemaName);
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/table/FilterableTableScanExecutor.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/table/FilterableTableScanExecutor.java
index e1e5b59..402d95e 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/table/FilterableTableScanExecutor.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-executor/src/main/java/org/apache/shardingsphere/infra/federation/executor/original/table/FilterableTableScanExecutor.java
@@ -131,15 +131,16 @@ public final class FilterableTableScanExecutor {
      * @return query results
      */
     public Enumerable<Object[]> execute(final FederationTableMetaData tableMetaData, final FilterableTableScanContext scanContext) {
+        String databaseName = executorContext.getDatabaseName();
         String schemaName = executorContext.getSchemaName();
-        DatabaseType databaseType = DatabaseTypeRegistry.getTrunkDatabaseType(optimizerContext.getParserContexts().get(schemaName).getDatabaseType().getName());
+        DatabaseType databaseType = DatabaseTypeRegistry.getTrunkDatabaseType(optimizerContext.getParserContexts().get(databaseName).getDatabaseType().getName());
         SqlString sqlString = createSQLString(tableMetaData, scanContext, databaseType);
         // TODO replace sql parse with sql convert
         FederationContext federationContext = executorContext.getFederationContext();
         LogicSQL logicSQL = createLogicSQL(federationContext.getMetaDataMap(), sqlString, databaseType);
-        ShardingSphereMetaData metaData = federationContext.getMetaDataMap().get(schemaName);
+        ShardingSphereMetaData metaData = federationContext.getMetaDataMap().get(databaseName);
         ExecutionContext context = new KernelProcessor().generateExecutionContext(logicSQL, metaData, executorContext.getProps());
-        if (federationContext.isPreview() || databaseType.containsSystemSchema(schemaName)) {
+        if (federationContext.isPreview() || databaseType.getSystemSchemas().contains(schemaName)) {
             federationContext.getExecutionUnits().addAll(context.getExecutionUnits());
             return createEmptyEnumerable();
         }
@@ -258,7 +259,7 @@ public final class FilterableTableScanExecutor {
                 optimizerContext.getSqlParserRule().getSqlStatementCache(), optimizerContext.getSqlParserRule().getParseTreeCache(), 
                 optimizerContext.getSqlParserRule().isSqlCommentParseEnabled()).parse(sql, false);
         List<Object> parameters = getParameters(sqlString.getDynamicParameters());
-        SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataMap, parameters, sqlStatement, executorContext.getSchemaName());
+        SQLStatementContext<?> sqlStatementContext = SQLStatementContextFactory.newInstance(metaDataMap, parameters, sqlStatement, executorContext.getDatabaseName());
         return new LogicSQL(sqlStatementContext, sql, parameters);
     }
     
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
index 779c46c..c87c049 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java
@@ -47,7 +47,7 @@ public final class DriverExecutor implements AutoCloseable {
         JDBCExecutor jdbcExecutor = new JDBCExecutor(metaDataContexts.getExecutorEngine(), connection.isHoldTransaction());
         regularExecutor = new DriverJDBCExecutor(connection.getSchema(), metaDataContexts, jdbcExecutor);
         rawExecutor = new RawExecutor(metaDataContexts.getExecutorEngine(), connection.isHoldTransaction(), metaDataContexts.getProps());
-        federationExecutor = FederationExecutorFactory.newInstance(connection.getSchema(), metaDataContexts.getOptimizerContext(), metaDataContexts.getProps(), jdbcExecutor);
+        federationExecutor = FederationExecutorFactory.newInstance(connection.getSchema(), connection.getSchema(), metaDataContexts.getOptimizerContext(), metaDataContexts.getProps(), jdbcExecutor);
         trafficExecutor = new TrafficExecutor();
     }
     
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilder.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilder.java
index c91ff37..ed78303 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/metadata/MetaDataContextsBuilder.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.config.schema.SchemaConfiguration;
 import org.apache.shardingsphere.infra.config.schema.impl.DataSourceProvidedSchemaConfiguration;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
 import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContextFactory;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
@@ -42,8 +43,8 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Map.Entry;
+import java.util.Properties;
 
 /**
  * Meta data contexts builder.
@@ -93,12 +94,12 @@ public final class MetaDataContextsBuilder {
      * @param databaseType database type
      */
     public void addSystemSchemas(final DatabaseType databaseType) {
-        for (Entry<String, Collection<String>> entry : databaseType.getSystemSchemas().entrySet()) {
-            if (databaseMap.containsKey(entry.getKey())) {
+        for (String each : databaseType.getSystemDatabases()) {
+            if (databaseMap.containsKey(each)) {
                 continue;
             }
-            ShardingSphereDatabase database = DatabaseLoader.load(entry.getKey(), databaseType);
-            databaseMap.put(entry.getKey(), database);
+            ShardingSphereDatabase database = DatabaseLoader.load(each, databaseType);
+            databaseMap.put(each, database);
         }
     }
     
@@ -120,13 +121,14 @@ public final class MetaDataContextsBuilder {
     }
     
     private Map<String, ShardingSphereMetaData> getMetaDataMap() throws SQLException {
+        DatabaseType defaultDatabaseType = DatabaseTypeFactory.getDatabaseType(schemaConfigMap, props);
         Map<String, ShardingSphereMetaData> result = new HashMap<>(databaseMap.size(), 1);
         for (Entry<String, ShardingSphereDatabase> entry : databaseMap.entrySet()) {
             String databaseName = entry.getKey();
             // TODO support database and schema configuration separately
             SchemaConfiguration schemaConfig = schemaConfigMap.getOrDefault(databaseName, new DataSourceProvidedSchemaConfiguration(Collections.emptyMap(), Collections.emptyList()));
             Collection<ShardingSphereRule> rules = schemaRulesMap.getOrDefault(databaseName, Collections.emptyList());
-            result.put(databaseName, ShardingSphereMetaData.create(databaseName, entry.getValue().getSchemas(), schemaConfig, rules));
+            result.put(databaseName, ShardingSphereMetaData.create(databaseName, entry.getValue().getSchemas(), schemaConfig, rules, defaultDatabaseType));
         }
         return result;
     }
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 3b06923..78f097a 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -131,7 +131,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
         MetaDataContextsBuilder result = new MetaDataContextsBuilder(globalRuleConfigs, props);
         DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getSchemaConfigs(), new ConfigurationProperties(parameter.getProps()));
         for (String each : schemaNames) {
-            if (databaseType.containsSystemSchema(each)) {
+            if (databaseType.getSystemSchemas().contains(each)) {
                 continue;
             }
             result.addSchema(each, databaseType, createSchemaConfiguration(each, metaDataPersistService, parameter), props);
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index 0e037fa..d1fba37 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -75,7 +75,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
                 ? parameter.getSchemaConfigs().keySet() : metaDataPersistService.getSchemaMetaDataService().loadAllNames();
         DatabaseType databaseType = DatabaseTypeFactory.getDatabaseType(parameter.getSchemaConfigs(), new ConfigurationProperties(parameter.getProps()));
         for (String each : schemaNames) {
-            if (databaseType.containsSystemSchema(each)) {
+            if (databaseType.getSystemSchemas().contains(each)) {
                 continue;
             }
             builder.addSchema(each, databaseType, createSchemaConfiguration(each, metaDataPersistService, parameter), props);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
index a3e3657..f98dc10 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
@@ -22,6 +22,8 @@ import org.apache.commons.lang3.concurrent.LazyInitializer;
 import org.apache.shardingsphere.infra.binder.LogicSQL;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import org.apache.shardingsphere.infra.executor.sql.context.ExecutionContext;
 import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutorExceptionHandler;
 import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
@@ -84,8 +86,9 @@ public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunication
         proxySQLExecutor = new ProxySQLExecutor(driverType, backendConnection, this);
         this.backendConnection = backendConnection;
         MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
-        String schemaName = backendConnection.getConnectionSession().getSchemaName();
-        federationExecutor = FederationExecutorFactory.newInstance(schemaName, metaDataContexts.getOptimizerContext(),
+        String databaseName = backendConnection.getConnectionSession().getSchemaName();
+        String schemaName = logicSQL.getSqlStatementContext().getTablesContext().getSchemaNames().stream().findFirst().orElse(databaseName);
+        federationExecutor = FederationExecutorFactory.newInstance(databaseName, schemaName, metaDataContexts.getOptimizerContext(),
                 metaDataContexts.getProps(), new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), backendConnection.isSerialExecute()));
     }
     
@@ -120,7 +123,7 @@ public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunication
                 logicSQL, getMetaData(), ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps());
         // TODO move federation route logic to binder
         if (executionContext.getRouteContext().isFederated() 
-                || logicSQL.getSqlStatementContext().getDatabaseType().containsSystemSchema(backendConnection.getConnectionSession().getSchemaName())) {
+                || containsSystemSchema(logicSQL.getSqlStatementContext().getDatabaseType(), logicSQL.getSqlStatementContext().getTablesContext().getSchemaNames())) {
             MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
             ResultSet resultSet = doExecuteFederation(logicSQL, metaDataContexts);
             return processExecuteFederation(resultSet, metaDataContexts);
@@ -138,6 +141,18 @@ public final class JDBCDatabaseCommunicationEngine extends DatabaseCommunication
                 : processExecuteUpdate(executionContext, result);
     }
     
+    private boolean containsSystemSchema(final DatabaseType databaseType, final Collection<String> schemaNames) {
+        if (databaseType instanceof PostgreSQLDatabaseType || databaseType instanceof OpenGaussDatabaseType) {
+            for (String each : schemaNames) {
+                if (!databaseType.getSystemSchemas().contains(each)) {
+                    continue;
+                }
+                return true;
+            }
+        }
+        return databaseType.getSystemSchemas().contains(backendConnection.getConnectionSession().getSchemaName());
+    }
+    
     private ResultSet doExecuteFederation(final LogicSQL logicSQL, final MetaDataContexts metaDataContexts) throws SQLException {
         boolean isReturnGeneratedKeys = logicSQL.getSqlStatementContext().getSqlStatement() instanceof MySQLInsertStatement;
         DatabaseType databaseType = metaDataContexts.getMetaData(backendConnection.getConnectionSession().getSchemaName()).getResource().getDatabaseType();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
index aea7107..46cf7c8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
@@ -114,10 +114,10 @@ public final class TextProtocolBackendHandlerFactory {
         if (databaseOperateHandler.isPresent()) {
             return databaseOperateHandler.get();
         }
-        String schemaName = sqlStatementContext.getTablesContext().getDatabaseName().isPresent()
+        String databaseName = sqlStatementContext.getTablesContext().getDatabaseName().isPresent()
                 ? sqlStatementContext.getTablesContext().getDatabaseName().get() : connectionSession.getSchemaName();
         SQLCheckEngine.check(sqlStatement, Collections.emptyList(),
-                getRules(schemaName), schemaName, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), connectionSession.getGrantee());
+                getRules(databaseName), databaseName, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataMap(), connectionSession.getGrantee());
         if (sqlStatement instanceof TCLStatement) {
             return TransactionBackendHandlerFactory.newInstance((SQLStatementContext<TCLStatement>) sqlStatementContext, sql, connectionSession);
         }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java
index d037dab..7568240 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowTablesExecutor.java
@@ -67,7 +67,7 @@ public final class ShowTablesExecutor implements DatabaseAdminQueryExecutor {
     }
     
     private QueryResult getQueryResult(final String schemaName) {
-        if (!databaseType.containsSystemSchema(schemaName) && !ProxyContext.getInstance().getMetaData(schemaName).isComplete()) {
+        if (!databaseType.getSystemSchemas().contains(schemaName) && !ProxyContext.getInstance().getMetaData(schemaName).isComplete()) {
             return new RawMemoryQueryResult(queryResultMetaData, Collections.emptyList());
         }
         List<MemoryQueryResultDataRow> rows = getAllTableNames(schemaName).stream().map(each -> {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java
index 94d74fc..d82d175 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandler.java
@@ -20,6 +20,9 @@ package org.apache.shardingsphere.proxy.backend.text.data.impl;
 import io.vertx.core.Future;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
 import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
 import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
@@ -68,7 +71,7 @@ public final class SchemaAssignedDatabaseBackendHandler implements DatabaseBacke
     }
     
     private void prepareDatabaseCommunicationEngine() throws RequiredResourceMissedException {
-        boolean isSystemSchema = sqlStatementContext.getDatabaseType().containsSystemSchema(connectionSession.getSchemaName());
+        boolean isSystemSchema = containsSystemSchema(sqlStatementContext.getDatabaseType(), sqlStatementContext.getTablesContext().getSchemaNames());
         if (!isSystemSchema && !ProxyContext.getInstance().getMetaData(connectionSession.getSchemaName()).hasDataSource()) {
             throw new RequiredResourceMissedException(connectionSession.getSchemaName());
         }
@@ -78,6 +81,18 @@ public final class SchemaAssignedDatabaseBackendHandler implements DatabaseBacke
         databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, connectionSession.getBackendConnection());
     }
     
+    private boolean containsSystemSchema(final DatabaseType databaseType, final Collection<String> schemaNames) {
+        if (databaseType instanceof PostgreSQLDatabaseType || databaseType instanceof OpenGaussDatabaseType) {
+            for (String each : schemaNames) {
+                if (!databaseType.getSystemSchemas().contains(each)) {
+                    continue;
+                }
+                return true;
+            }
+        }
+        return databaseType.getSystemSchemas().contains(connectionSession.getSchemaName());
+    }
+    
     @Override
     public boolean next() throws SQLException {
         return databaseCommunicationEngine.next();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java
index 87d8c2a..e5c355c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advanced/PreviewDistSQLBackendHandler.java
@@ -130,7 +130,7 @@ public final class PreviewDistSQLBackendHandler extends QueryableRALBackendHandl
         DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(isReturnGeneratedKeys, metaDataContexts);
         FederationContext context = new FederationContext(true, logicSQL, metaDataContexts.getMetaDataMap());
         DatabaseType databaseType = metaDataContexts.getMetaData(getSchemaName()).getResource().getDatabaseType();
-        FederationExecutor executor = FederationExecutorFactory.newInstance(schemaName, metaDataContexts.getOptimizerContext(),
+        FederationExecutor executor = FederationExecutorFactory.newInstance(schemaName, schemaName, metaDataContexts.getOptimizerContext(),
                 metaDataContexts.getProps(), new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), false));
         executor.executeQuery(prepareEngine, createPreviewFederationCallback(sqlStatement, databaseType), context);
         return context.getExecutionUnits();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
index b0cfc9a..2a29cf8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
@@ -21,9 +21,9 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -67,7 +67,9 @@ public final class DatabaseCommunicationEngineFactoryTest {
     public void assertNewTextProtocolInstance() {
         JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class, RETURNS_DEEP_STUBS);
         when(backendConnection.getConnectionSession().getSchemaName()).thenReturn("schema");
-        DatabaseCommunicationEngine engine = DatabaseCommunicationEngineFactory.getInstance().newTextProtocolInstance(mock(SQLStatementContext.class), "schemaName", backendConnection);
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
+        DatabaseCommunicationEngine engine = DatabaseCommunicationEngineFactory.getInstance().newTextProtocolInstance(sqlStatementContext, "schemaName", backendConnection);
         assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
     }
     
@@ -75,8 +77,10 @@ public final class DatabaseCommunicationEngineFactoryTest {
     public void assertNewBinaryProtocolInstance() {
         JDBCBackendConnection backendConnection = mock(JDBCBackendConnection.class, RETURNS_DEEP_STUBS);
         when(backendConnection.getConnectionSession().getSchemaName()).thenReturn("schema");
-        DatabaseCommunicationEngine engine =
-                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
+        DatabaseCommunicationEngine engine 
+                = DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, "schemaName", Collections.emptyList(), backendConnection);
         assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
index 9c12f91..07ffd17 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
@@ -110,8 +110,10 @@ public final class JDBCDatabaseCommunicationEngineTest {
     
     @Test
     public void assertBinaryProtocolQueryHeader() throws SQLException, NoSuchFieldException {
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
         JDBCDatabaseCommunicationEngine engine =
-                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, "schemaName", Collections.emptyList(), backendConnection);
         assertNotNull(engine);
         assertThat(engine, instanceOf(DatabaseCommunicationEngine.class));
         Field queryHeadersField = DatabaseCommunicationEngine.class.getDeclaredField("queryHeaders");
@@ -177,8 +179,10 @@ public final class JDBCDatabaseCommunicationEngineTest {
     
     @Test
     public void assertAddStatementCorrectly() {
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
         JDBCDatabaseCommunicationEngine engine =
-                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, "schemaName", Collections.emptyList(), backendConnection);
         engine.add(statement);
         Collection<?> actual = getField(engine, "cachedStatements");
         assertThat(actual.size(), is(1));
@@ -187,8 +191,10 @@ public final class JDBCDatabaseCommunicationEngineTest {
     
     @Test
     public void assertAddResultSetCorrectly() {
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
         JDBCDatabaseCommunicationEngine engine =
-                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, "schemaName", Collections.emptyList(), backendConnection);
         engine.add(resultSet);
         Collection<?> actual = getField(engine, "cachedResultSets");
         assertThat(actual.size(), is(1));
@@ -197,8 +203,10 @@ public final class JDBCDatabaseCommunicationEngineTest {
     
     @Test
     public void assertCloseCorrectly() throws SQLException {
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
         JDBCDatabaseCommunicationEngine engine =
-                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, "schemaName", Collections.emptyList(), backendConnection);
         Collection<ResultSet> cachedResultSets = getField(engine, "cachedResultSets");
         cachedResultSets.add(resultSet);
         Collection<Statement> cachedStatements = getField(engine, "cachedStatements");
@@ -212,8 +220,10 @@ public final class JDBCDatabaseCommunicationEngineTest {
     
     @Test
     public void assertCloseResultSetsWithExceptionThrown() throws SQLException {
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
         JDBCDatabaseCommunicationEngine engine =
-                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(mock(SQLStatementContext.class), "schemaName", Collections.emptyList(), backendConnection);
+                DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext, "schemaName", Collections.emptyList(), backendConnection);
         Collection<ResultSet> cachedResultSets = getField(engine, "cachedResultSets");
         SQLException sqlExceptionByResultSet = new SQLException("ResultSet");
         doThrow(sqlExceptionByResultSet).when(resultSet).close();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
index 5a50e53..556252a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
@@ -45,6 +45,7 @@ import org.mockito.junit.MockitoJUnitRunner;
 
 import java.lang.reflect.Field;
 import java.sql.SQLException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -87,8 +88,9 @@ public final class SchemaAssignedDatabaseBackendHandlerTest {
         contextManagerField.set(ProxyContext.getInstance(), contextManager);
         when(connectionSession.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
         mockDatabaseCommunicationEngine(new UpdateResponseHeader(mock(SQLStatement.class)));
-        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class);
+        SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
         when(sqlStatementContext.getDatabaseType()).thenReturn(new MySQLDatabaseType());
+        when(sqlStatementContext.getTablesContext().getSchemaNames()).thenReturn(Collections.emptyList());
         schemaAssignedDatabaseBackendHandler = new SchemaAssignedDatabaseBackendHandler(sqlStatementContext, EXECUTE_SQL, connectionSession);
         setBackendHandlerFactory(schemaAssignedDatabaseBackendHandler);
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureDatabaseType.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureDatabaseType.java
index 4c84c1e..18ed947 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureDatabaseType.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureDatabaseType.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 import static org.mockito.Mockito.mock;
@@ -56,7 +55,12 @@ public final class FixtureDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyDatabaseType.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyDatabaseType.java
index 2a98e95..1ba141f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyDatabaseType.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/protocol/fixture/DummyDatabaseType.java
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Optional;
 
 public final class DummyDatabaseType implements DatabaseType {
@@ -54,7 +53,12 @@ public final class DummyDatabaseType implements DatabaseType {
     }
     
     @Override
-    public Map<String, Collection<String>> getSystemSchemas() {
-        return Collections.emptyMap();
+    public Collection<String> getSystemDatabases() {
+        return Collections.emptyList();
+    }
+    
+    @Override
+    public Collection<String> getSystemSchemas() {
+        return Collections.emptyList();
     }
 }