You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2021/06/23 09:02:15 UTC

[shardingsphere] branch opengauss_adapt updated (5bea94a -> 2a39e42)

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

wuweijie pushed a change to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git.


    omit 5bea94a  Implements openGauss batch bind protocol (#10850)
    omit 4a58244  Fix implements of OpenGaussParserFacade (#10849)
    omit 37ebf88  Fix : fix checkstyle violation (#10838)
    omit 22f3dc0  Fix : remove @Override annotation since getDatabaseType() has been removed from Interface (#10836)
    omit ad6a01a  add jdbc:opengauss supoort (#10601)
    omit b3f23e1  Update OpenGaussDataSourceMetaData
    omit b97bc28  Add OpenGauss Database type (#10292)
     add 514117f  optimize select group by having with calcite (#10848)
     add dbcc3a1  This is the video after the openGauss meetup of Zhangliang (#10851)
     add fc1985d  Update documents about docker (#10853)
     add 63bcb49  Define shortcode for QQ video in document (#10854)
     add bfc8d90  Modify articles' order (#10855)
     add c601b26  Correct the symbol in document (#10858)
     add d18667f  Split scaling ANTLR g4 file and visitor (#10859)
     add d4d2d7f  Add more test cases for shardingsphere-sql-parser-engine module (#10796) (#10839)
     add c029efa  For #10844 & #10138, Fix getSaneResult in ShardingJDBC (#10845)
     add d169ff2  Revise code format for #10839 (#10860)
     add 7e81aae  support subquery aggregation and partial distinct aggregation (#10856)
     add 6e5a37c  update supported sql doc (#10865)
     add 0a32e66  Modify readme (#10870)
     add e02a92a  Refactor DatabaseDiscoveryRuleSegment (#10871)
     add b7105da  Refactor EncryptColumnSegment (#10872)
     add 2bd5794  Refactor TableRuleSegment and BindingTableRuleSegment (#10873)
     add e1cdf0d  Refactor ReadwriteSplittingRuleSegment (#10874)
     add 829eecf  User resource name instead of IDENTIFIER in G4 file for Readwrite-splitting (#10875)
     add 9ef1c3f  Use table name instead of IDENTIFIER in G4 file for sharding (#10876)
     add 546e465  Refactor DistSQLBackendHandlerFactory (#10877)
     add a5e4706  Revise code format with RDL and RQL backend handler (#10878)
     add 0f6bbd7  update doc for beta release (#10881)
     add e30864b  Fix test case dependency (#10882)
     add 9481135  Create DropTableStatementFederateRefresher for issues#10697 (#10800)
     add c6f069b  Add PropertiesConverter to decouple TextProtocolBackendHandler (#10885)
     add b08767c  Ignore ci for window on GitHub action (#10886)
     add fdfa912  Update readwrite-splitting .cn.md (#10890)
     add f99d700  Create sql node engine for sql optimization (#10895)
     add f15e1f2  Add RuleQueryResultSet to decouple SchemaRequiredBackendHandler and RQL (#10897)
     add 3269d1c  Reuse DataSourcesQueryBackendHandler to decouple DataSourcesQueryBackendHandler (#10905)
     add 5c6aa11  Rename RuleQueryResultSet to RQLResultSet (#10906)
     add ae04f97  Refactor PostgreSQL Bind packet & executor (#10910)
     add 9c8adc6  move federate test to integration-test (#10913)
     add 021ce3f  Use SPI to introduce rule based RQL (#10924)
     add d0bebfe  Refactor DataSourceQueryResultSet (#10925)
     add 0761411  fix issues 10403 (#10884)
     add 23ac120  fix CSS code (#10926)
     new c467637  Add OpenGauss Database type (#10292)
     new 0c7ea9e  Update OpenGaussDataSourceMetaData
     new 71020be  add jdbc:opengauss supoort (#10601)
     new e7f00f9  Fix : remove @Override annotation since getDatabaseType() has been removed from Interface (#10836)
     new 20abdb6  Fix : fix checkstyle violation (#10838)
     new c9762a5  Fix implements of OpenGaussParserFacade (#10849)
     new 2a39e42  Implements openGauss batch bind protocol (#10850)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5bea94a)
            \
             N -- N -- N   refs/heads/opengauss_adapt (2a39e42)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/ci.yml                           |  42 ++--
 README.md                                          |   2 +-
 README_ZH.md                                       |   2 +-
 docs/blog/content/videos/Newfeature.cn.md          |   2 +-
 docs/blog/content/videos/Newfeature.en.md          |   2 +-
 docs/blog/content/videos/OpenSource.cn.md          |   2 +-
 docs/blog/content/videos/OpenSource.en.md          |   2 +-
 docs/blog/content/videos/_index.cn.md              |  14 +-
 docs/blog/content/videos/_index.en.md              |  14 +-
 docs/blog/content/videos/build.cn.md               |   2 +-
 docs/blog/content/videos/build.en.md               |   2 +-
 docs/blog/content/videos/ecosystem.cn.md           |   2 +-
 docs/blog/content/videos/ecosystem.en.md           |   2 +-
 docs/blog/content/videos/evolution.cn.md           |   2 +-
 docs/blog/content/videos/evolution.en.md           |   2 +-
 docs/blog/content/videos/new_SQL.cn.md             |   2 +-
 docs/blog/content/videos/new_SQL.en.md             |   2 +-
 docs/blog/content/videos/openGauss.cn.md           |   9 +
 docs/blog/content/videos/openGauss.en.md           |   9 +
 docs/blog/layouts/shortcodes/bilibili.html         |  19 +-
 docs/blog/layouts/shortcodes/qq.html               |  18 ++
 .../content/contribute/release-elasticjob-ui.cn.md |   1 +
 .../content/contribute/release-elasticjob-ui.en.md |   1 +
 .../content/contribute/release-elasticjob.cn.md    |   1 +
 .../content/contribute/release-elasticjob.en.md    |   1 +
 docs/community/content/contribute/release.cn.md    |   1 +
 docs/community/content/contribute/release.en.md    |   1 +
 docs/community/content/contribute/release_ui.cn.md |   1 +
 docs/community/content/contribute/release_ui.en.md |   1 +
 docs/document/content/downloads/_index.cn.md       |  12 +-
 docs/document/content/downloads/_index.en.md       |  12 +-
 .../content/features/sharding/use-norms/sql.cn.md  |  10 +-
 .../content/features/sharding/use-norms/sql.en.md  |  10 +-
 .../configuration/yaml/readwrite-splitting .cn.md  |   2 +-
 .../user-manual/shardingsphere-proxy/docker.cn.md  |  10 +-
 .../user-manual/shardingsphere-proxy/docker.en.md  |  16 +-
 .../shardingsphere-proxy/usage/startup.en.md       |   2 +-
 .../shardingsphere-agent-core/pom.xml              |   2 +-
 .../base/advice/SchemaMetaDataLoaderAdvice.java    |   2 +-
 ...olumnFormat.java => PostgreSQLValueFormat.java} |   8 +-
 .../query/binary/bind/PostgreSQLComBindPacket.java |  24 +--
 .../binary/bind/PostgreSQLComBindPacketTest.java   |   7 +-
 .../shardingsphere-distsql-parser-engine/pom.xml   |  18 +-
 .../src/main/antlr4/imports/Keyword.g4             |  32 ---
 .../distsql/parser/autogen/ResourceStatement.g4    |   9 +-
 .../resource/ResourceDistSQLStatementVisitor.java  |  49 -----
 .../DatabaseDiscoveryRuleQueryResultSet.java       |  74 +++++++
 .../DatabaseDiscoveryRuleQueryResultSetTest.java   |  65 ++++++
 ...atabaseDiscoveryRuleStatementConverterTest.java |  18 +-
 ...pache.shardingsphere.infra.distsql.RQLResultSet |  18 ++
 .../DatabaseDiscoveryRuleSQLStatementVisitor.java  |  12 +-
 .../segment/DatabaseDiscoveryRuleSegment.java      |  12 +-
 .../encrypt/distsql/EncryptRuleQueryResultSet.java |  94 ++++++++
 ...pache.shardingsphere.infra.distsql.RQLResultSet |  18 ++
 .../distsql/EncryptRuleQueryResultSetTest.java     |  68 ++++++
 .../EncryptRuleStatementConverterTest.java         |  18 +-
 .../core/EncryptRuleSQLStatementVisitor.java       |  10 +-
 .../parser/segment/EncryptColumnSegment.java       |  12 +-
 .../ReadwriteSplittingRuleQueryResultSet.java      |  76 +++++++
 ...pache.shardingsphere.infra.distsql.RQLResultSet |  18 ++
 .../ReadwriteSplittingRuleQueryResultSetTest.java  |  70 ++++++
 .../imports/readwrite-splitting/RDLStatement.g4    |  16 +-
 .../ReadwriteSplittingRuleSQLStatementVisitor.java |  36 +---
 .../segment/ReadwriteSplittingRuleSegment.java     |  25 ++-
 .../ShardingBindingTableRuleQueryResultSet.java    |  64 ++++++
 .../ShardingBroadcastTableRuleQueryResultSet.java  |  64 ++++++
 .../distsql/ShardingTableRuleQueryResultSet.java   | 206 ++++++++++++++++++
 .../merge/dal/show/LogicTablesMergedResult.java    |   3 +-
 .../merge/dal/show/ShowIndexMergedResult.java      |   3 +-
 .../merge/dql/ShardingDQLResultMerger.java         |  15 --
 .../dql/groupby/GroupByMemoryMergedResult.java     |  19 +-
 .../having/HavingDecoratorMergedResult.java        |  84 --------
 .../engine/type/ShardingRouteEngineFactory.java    |  17 +-
 .../dml/impl/ShardingSelectStatementValidator.java |   2 +-
 ...pache.shardingsphere.infra.distsql.RQLResultSet |  20 ++
 .../ShardingRuleStatementConverterTest.java        |   6 +-
 ...ShardingBindingTableRuleQueryResultSetTest.java |  59 +++++
 ...ardingBroadcastTableRuleQueryResultSetTest.java |  54 +++++
 .../ShardingTableRuleQueryResultSetTest.java       |  78 +++++++
 .../engine/type/standard/AbstractSQLRouteTest.java |   8 +-
 .../engine/type/standard/SubqueryRouteTest.java    |  34 +--
 .../yaml/distsql/sharding-rule-config.yaml         |   0
 .../main/antlr4/imports/sharding/RDLStatement.g4   |   4 +-
 .../core/ShardingRuleSQLStatementVisitor.java      |  29 ++-
 .../parser/segment/BindingTableRuleSegment.java    |   6 +-
 .../distsql/parser/segment/TableRuleSegment.java   |  16 +-
 .../binder/segment/select/having/HavingColumn.java |  36 ----
 .../select/having/engine/HavingContextEngine.java  |  93 --------
 .../statement/dml/SelectStatementContext.java      |  50 +++--
 .../statement/impl/SelectStatementContextTest.java |   2 +
 .../shardingsphere/infra/distsql/RQLResultSet.java |  59 +++++
 .../infra/properties/PropertiesConverter.java}     |  23 +-
 .../infra/properties/PropertiesConverterTest.java  |  34 +--
 .../refresher/MetadataRefresherFactory.java        |   2 +
 .../refresher/MetadataRefresherFactoryTest.java    |   2 +-
 .../federate/schema/row/FederateRowEnumerator.java |   6 +-
 .../federate/schema/row/FederateRowExecutor.java   |   8 +-
 .../schema/table/FederateFilterableTable.java      |   3 +-
 .../generator/FederateExecutionSQLGenerator.java   |  11 +-
 .../engine/jdbc/JDBCExecutorCallbackTest.java      |   2 +-
 .../result/impl/memory/MemoryMergedResult.java     |  13 +-
 .../result/impl/memory/MemoryQueryResultRow.java   |  13 --
 .../memory/fixture/TestMemoryMergedResult.java     |   5 +-
 ...odeConverter.java => SqlNodeConvertEngine.java} |  21 +-
 .../convert/{ => converter}/SqlNodeConverter.java  |  15 +-
 .../impl/DistinctSqlNodeConverter.java}            |  27 +--
 .../impl/SelectStatementSqlNodeConverter.java      |  41 ++++
 .../core/metadata/FederateTableMetadata.java       |  16 +-
 .../type/DropTableStatementFederateRefresher.java  |  38 ++++
 .../DropTableStatementFederateRefresherTest.java   | 117 ++++++++++
 .../generator/generic/RemoveTokenGenerator.java    |  11 +-
 .../batch/BatchPreparedStatementExecutor.java      |   2 +-
 .../statement/ShardingSpherePreparedStatement.java |   5 +-
 .../core/statement/ShardingSphereStatement.java    |   5 +-
 .../driver/executor/AbstractBaseExecutorTest.java  |   2 +-
 .../batch/BatchPreparedStatementExecutorTest.java  |   8 +-
 .../statement/FederatePrepareStatementTest.java    | 104 ++++++---
 .../jdbc/core/statement/FederateStatementTest.java |  98 ++++++---
 .../ShardingSpherePreparedStatementTest.java       |  10 +
 .../statement/ShardingSphereStatementTest.java     |   8 +
 .../shardingsphere-proxy-backend/pom.xml           |  10 +
 .../backend/text/SchemaRequiredBackendHandler.java |   2 +
 .../text/distsql/DistSQLBackendHandlerFactory.java |  14 +-
 .../text/distsql/ral/RALBackendHandlerFactory.java |  14 +-
 .../ral/impl/CheckScalingJobBackendHandler.java    |   2 +-
 .../ral/impl/DropScalingJobBackendHandler.java     |   2 +-
 .../ral/impl/ResetScalingJobBackendHandler.java    |   2 +-
 .../impl/ShowScalingJobStatusBackendHandler.java   |   2 +-
 .../ral/impl/StartScalingJobBackendHandler.java    |   2 +-
 .../ral/impl/StopScalingJobBackendHandler.java     |   2 +-
 .../text/distsql/rdl/RDLBackendHandlerFactory.java |   2 +-
 .../AlterReadwriteSplittingRuleBackendHandler.java |  15 +-
 ...terShardingBindingTableRulesBackendHandler.java |   9 +-
 ...rShardingBroadcastTableRulesBackendHandler.java |   2 +-
 ...ateShardingBindingTableRulesBackendHandler.java |   4 +-
 .../text/distsql/rdl/impl/RDLBackendHandler.java   |  12 +-
 .../text/distsql/rql/DataSourceQueryResultSet.java |  92 ++++++++
 .../text/distsql/rql/RQLBackendHandler.java        |  63 ++++++
 .../text/distsql/rql/RQLBackendHandlerFactory.java |  51 ++---
 .../rql/impl/DataSourcesQueryBackendHandler.java   | 104 ---------
 .../DatabaseDiscoveryRulesQueryBackendHandler.java |  96 ---------
 .../rql/impl/EncryptRulesQueryBackendHandler.java  | 118 ----------
 ...ReadwriteSplittingRulesQueryBackendHandler.java |  99 ---------
 ...ardingBindingTableRulesQueryBackendHandler.java |  83 -------
 ...dingBroadcastTableRulesQueryBackendHandler.java |  80 -------
 .../ShardingTableRulesQueryBackendHandler.java     | 238 ---------------------
 ...pache.shardingsphere.infra.distsql.RQLResultSet |  18 ++
 .../DatabaseCommunicationEngineTest.java           |   3 +-
 ....java => DistSQLBackendHandlerFactoryTest.java} |   6 +-
 ...terDatabaseDiscoveryRuleBackendHandlerTest.java |  58 ++---
 .../impl/AlterEncryptRuleBackendHandlerTest.java   |  15 +-
 ...erReadwriteSplittingRuleBackendHandlerTest.java |  58 ++---
 ...hardingBindingTableRulesBackendHandlerTest.java |  12 +-
 .../AlterShardingTableRuleBackendHandlerTest.java  |  19 +-
 ...ateDatabaseDiscoveryRuleBackendHandlerTest.java |  38 ++--
 .../impl/CreateEncryptRuleBackendHandlerTest.java  |  15 +-
 ...teReadwriteSplittingRuleBackendHandlerTest.java |  61 ++----
 ...hardingBindingTableRulesBackendHandlerTest.java |  38 ++--
 .../CreateShardingTableRuleBackendHandlerTest.java |  18 +-
 ...opReadwriteSplittingRuleBackendHandlerTest.java |   2 +-
 ...hardingBindingTableRulesBackendHandlerTest.java |   5 +-
 ...rdingBroadcastTableRulesBackendHandlerTest.java |   4 +-
 .../DropShardingTableRuleBackendHandlerTest.java   |   4 +-
 .../text/distsql/rql/RQLBackendHandlerTest.java    |  96 +++++++++
 ...abaseDiscoveryRulesQueryBackendHandlerTest.java | 107 ---------
 .../impl/EncryptRulesQueryBackendHandlerTest.java  | 111 ----------
 ...writeSplittingRulesQueryBackendHandlerTest.java | 115 ----------
 ...ngBindingTableRulesQueryBackendHandlerTest.java | 100 ---------
 ...BroadcastTableRulesQueryBackendHandlerTest.java |  97 ---------
 .../ShardingTableRulesQueryBackendHandlerTest.java | 121 -----------
 .../binary/bind/PostgreSQLComBindExecutor.java     |  11 +-
 .../binary/bind/PostgreSQLComBindExecutorTest.java |   4 +-
 shardingsphere-scaling/pom.xml                     |   1 +
 .../{ => shardingsphere-scaling-distsql}/pom.xml   |  14 +-
 .../shardingsphere-scaling-distsql-parser}/pom.xml |  23 +-
 .../src/main/antlr4/imports/scaling}/Alphabet.g4   |   0
 .../src/main/antlr4/imports/scaling}/Keyword.g4    |  40 ----
 .../src/main/antlr4/imports/scaling}/Literals.g4   |   0
 .../main/antlr4/imports/scaling}/RALStatement.g4   |   0
 .../src/main/antlr4/imports/scaling}/Symbol.g4     |   0
 .../distsql/parser/autogen/ScalingStatement.g4     |   9 +-
 .../scaling/distsql/parser/core/ScalingLexer.java  |  23 +-
 .../scaling/distsql/parser/core/ScalingParser.java |  28 +--
 .../parser/core/ScalingSQLStatementVisitor.java    |  77 +++++++
 .../facade/ScalingSQLStatementParserFacade.java    |  52 +++++
 ...distsql.parser.spi.RuleSQLStatementParserFacade |  18 ++
 .../core/ScalingStatementParserEngineTest.java     |  41 ++++
 .../pom.xml                                        |  22 +-
 .../statement}/CheckScalingJobStatement.java       |   2 +-
 .../statement}/DropScalingJobStatement.java        |   2 +-
 .../statement}/ResetScalingJobStatement.java       |   2 +-
 .../statement}/ShowScalingJobListStatement.java    |   2 +-
 .../statement}/ShowScalingJobStatusStatement.java  |   2 +-
 .../statement}/StartScalingJobStatement.java       |   2 +-
 .../statement}/StopScalingJobStatement.java        |   2 +-
 .../DatabaseTypedSQLParserFacadeRegistryTest.java  |  41 ++++
 .../sql/parser/core/SQLParserEngineTest.java       |  57 +++++
 .../DatabaseTypedSQLParserFacadeFixture.java       |  33 +--
 .../sql/parser/fixture/LexerFixture.java           |   9 +-
 .../sql/parser/fixture/ParserFixture.java          |  17 +-
 ...ere.sql.parser.spi.DatabaseTypedSQLParserFacade |  18 ++
 .../segment/dml/predicate/HavingSegment.java       |   4 +-
 .../src/main/resources/case/tcl/end.xml            |  17 +-
 .../main/resources/case/tcl/start-transaction.xml  |  18 +-
 .../src/main/resources/sql/supported/tcl/end.xml   |  17 +-
 .../sql/supported/tcl/start-transcation.xml        |  18 +-
 .../test/integration/env/EnvironmentPath.java      |  30 ++-
 .../junit/container/storage/impl/H2Container.java  |  17 +-
 .../select_across_single_tables_with_federate.xml} |  23 +-
 .../select_across_single_tables_with_federate.xml} |  23 +-
 .../select_across_single_tables_with_federate.xml} |  23 +-
 .../cases/dql/dql-integration-test-cases.xml       |   4 +
 .../src/test/resources/env/db/dataset.xml          |  17 ++
 .../resources/env/db/init-sql/h2/init-db_0.sql     |  20 ++
 .../resources/env/db/init-sql/h2/init-db_1.sql     |  20 ++
 .../test/resources/env/db/init-sql/mysql/init.sql  |   2 +
 .../test/resources/env/db/init-sql/oracle/init.sql |   2 +
 .../resources/env/db/init-sql/sqlserver/init.sql   |   2 +
 .../env/dbtbl_with_readwrite_splitting/dataset.xml |  23 ++
 .../init-sql/h2/init-read_ds_0.sql                 |  20 ++
 .../init-sql/h2/init-read_ds_1.sql                 |  20 ++
 .../init-sql/h2/init-write_ds_0.sql                |  20 ++
 .../init-sql/h2/init-write_ds_1.sql                |  20 ++
 .../init-sql/mysql/init.sql                        |   4 +
 .../init-sql/oracle/init.sql                       |   4 +
 .../init-sql/sqlserver/init.sql                    |   4 +
 .../dataset.xml                                    |  23 ++
 .../init-sql/h2/init-encrypt_read_ds_0.sql         |  20 ++
 .../init-sql/h2/init-encrypt_read_ds_1.sql         |  20 ++
 .../init-sql/h2/init-encrypt_write_ds_0.sql        |  20 ++
 .../init-sql/h2/init-encrypt_write_ds_1.sql        |  20 ++
 .../init-sql/mysql/init.sql                        |   4 +
 .../init-sql/oracle/init.sql                       |   4 +
 .../init-sql/sqlserver/init.sql                    |   4 +
 .../src/test/resources/logback-test.xml            |   4 +
 .../resources/scenario/sharding/case/select.xml    |  11 +-
 236 files changed, 3188 insertions(+), 2834 deletions(-)
 create mode 100644 docs/blog/content/videos/openGauss.cn.md
 create mode 100644 docs/blog/content/videos/openGauss.en.md
 create mode 100644 docs/blog/layouts/shortcodes/qq.html
 rename shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/{PostgreSQLColumnFormat.java => PostgreSQLValueFormat.java} (88%)
 create mode 100644 shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/DatabaseDiscoveryRuleQueryResultSet.java
 create mode 100644 shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/distsql/DatabaseDiscoveryRuleQueryResultSetTest.java
 create mode 100644 shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.RQLResultSet
 create mode 100644 shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/distsql/EncryptRuleQueryResultSet.java
 create mode 100644 shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.RQLResultSet
 create mode 100644 shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/distsql/EncryptRuleQueryResultSetTest.java
 create mode 100644 shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/ReadwriteSplittingRuleQueryResultSet.java
 create mode 100644 shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.RQLResultSet
 create mode 100644 shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/ReadwriteSplittingRuleQueryResultSetTest.java
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/distsql/ShardingBindingTableRuleQueryResultSet.java
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/distsql/ShardingBroadcastTableRuleQueryResultSet.java
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/distsql/ShardingTableRuleQueryResultSet.java
 delete mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/having/HavingDecoratorMergedResult.java
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.RQLResultSet
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/distsql/ShardingBindingTableRuleQueryResultSetTest.java
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/distsql/ShardingBroadcastTableRuleQueryResultSetTest.java
 create mode 100644 shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/distsql/ShardingTableRuleQueryResultSetTest.java
 rename shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/yaml/config-sharding.yaml => shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/resources/yaml/distsql/sharding-rule-config.yaml (100%)
 delete mode 100644 shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/having/HavingColumn.java
 delete mode 100644 shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/having/engine/HavingContextEngine.java
 create mode 100644 shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/RQLResultSet.java
 copy shardingsphere-infra/{shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/SqlNodeConverter.java => shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/properties/PropertiesConverter.java} (62%)
 copy shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-statement/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/segment/DatabaseDiscoveryRuleSegment.java => shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/properties/PropertiesConverterTest.java (57%)
 copy shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/{SqlNodeConverter.java => SqlNodeConvertEngine.java} (59%)
 copy shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/{ => converter}/SqlNodeConverter.java (67%)
 rename shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/{SqlNodeConverter.java => converter/impl/DistinctSqlNodeConverter.java} (51%)
 create mode 100644 shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/convert/converter/impl/SelectStatementSqlNodeConverter.java
 create mode 100644 shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/core/metadata/refresher/type/DropTableStatementFederateRefresher.java
 create mode 100644 shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/metadata/refresher/DropTableStatementFederateRefresherTest.java
 create mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/DataSourceQueryResultSet.java
 create mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/DataSourcesQueryBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/DatabaseDiscoveryRulesQueryBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/EncryptRulesQueryBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ReadwriteSplittingRulesQueryBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ShardingBindingTableRulesQueryBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ShardingBroadcastTableRulesQueryBackendHandler.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ShardingTableRulesQueryBackendHandler.java
 create mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.RQLResultSet
 rename shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/{RDLBackendHandlerFactoryTest.java => DistSQLBackendHandlerFactoryTest.java} (98%)
 create mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/DatabaseDiscoveryRulesQueryBackendHandlerTest.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/EncryptRulesQueryBackendHandlerTest.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ReadwriteSplittingRulesQueryBackendHandlerTest.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ShardingBindingTableRulesQueryBackendHandlerTest.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ShardingBroadcastTableRulesQueryBackendHandlerTest.java
 delete mode 100644 shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/ShardingTableRulesQueryBackendHandlerTest.java
 copy shardingsphere-scaling/{ => shardingsphere-scaling-distsql}/pom.xml (70%)
 mode change 100755 => 100644
 copy {shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser}/pom.xml (81%)
 copy {shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling}/Alphabet.g4 (100%)
 copy {shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling}/Keyword.g4 (80%)
 copy {shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling}/Literals.g4 (100%)
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling}/RALStatement.g4 (100%)
 copy {shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/imports/scaling}/Symbol.g4 (100%)
 copy shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4 => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ScalingStatement.g4 (85%)
 rename shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/select/having/HavingContext.java => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingLexer.java (65%)
 copy shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/segment/EncryptColumnSegment.java => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingParser.java (59%)
 create mode 100644 shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingSQLStatementVisitor.java
 create mode 100644 shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/java/org/apache/shardingsphere/scaling/distsql/parser/facade/ScalingSQLStatementParserFacade.java
 create mode 100644 shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.parser.spi.RuleSQLStatementParserFacade
 create mode 100644 shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-parser/src/test/java/org/apache/shardingsphere/scaling/distsql/parser/core/ScalingStatementParserEngineTest.java
 copy shardingsphere-scaling/{ => shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement}/pom.xml (63%)
 mode change 100755 => 100644
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/CheckScalingJobStatement.java (94%)
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/DropScalingJobStatement.java (94%)
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/ResetScalingJobStatement.java (94%)
 copy {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/ShowScalingJobListStatement.java (93%)
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/ShowScalingJobStatusStatement.java (94%)
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/StartScalingJobStatement.java (94%)
 rename {shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl => shardingsphere-scaling/shardingsphere-scaling-distsql/shardingsphere-scaling-distsql-statement/src/main/java/org/apache/shardingsphere/scaling/distsql/statement}/StopScalingJobStatement.java (94%)
 create mode 100644 shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/DatabaseTypedSQLParserFacadeRegistryTest.java
 create mode 100644 shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/SQLParserEngineTest.java
 copy shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-statement/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/segment/EncryptColumnSegment.java => shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/fixture/DatabaseTypedSQLParserFacadeFixture.java (55%)
 rename shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/impl/ShowScalingJobListStatement.java => shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/fixture/LexerFixture.java (75%)
 copy shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/BindingTableRuleSegment.java => shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/fixture/ParserFixture.java (77%)
 create mode 100644 shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.DatabaseTypedSQLParserFacade
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml => shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/tcl/end.xml (66%)
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml => shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/tcl/start-transaction.xml (66%)
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml => shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/tcl/end.xml (66%)
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/logback-test.xml => shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/tcl/start-transcation.xml (62%)
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/{logback-test.xml => cases/dql/dataset/db/select_across_single_tables_with_federate.xml} (66%)
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/{logback-test.xml => cases/dql/dataset/dbtbl_with_readwrite_splitting/select_across_single_tables_with_federate.xml} (66%)
 copy shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/{logback-test.xml => cases/dql/dataset/dbtbl_with_readwrite_splitting_and_encrypt/select_across_single_tables_with_federate.xml} (66%)
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/db/init-sql/h2/init-db_0.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/db/init-sql/h2/init-db_1.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting/init-sql/h2/init-read_ds_0.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting/init-sql/h2/init-read_ds_1.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting/init-sql/h2/init-write_ds_0.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting/init-sql/h2/init-write_ds_1.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting_and_encrypt/init-sql/h2/init-encrypt_read_ds_0.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting_and_encrypt/init-sql/h2/init-encrypt_read_ds_1.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting_and_encrypt/init-sql/h2/init-encrypt_write_ds_0.sql
 create mode 100644 shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/dbtbl_with_readwrite_splitting_and_encrypt/init-sql/h2/init-encrypt_write_ds_1.sql

[shardingsphere] 03/07: add jdbc:opengauss supoort (#10601)

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit 71020be22244999163ad4e6f4d86a43cec756b8a
Author: justbk2015 <24...@qq.com>
AuthorDate: Tue Jun 1 20:38:33 2021 +0800

    add jdbc:opengauss supoort (#10601)
---
 .../dialect/OpenGaussDataSourceMetaData.java       |   2 +-
 .../dialect/OpenGaussTableMetaDataLoader.java      | 144 +++++++++++++++++++++
 ...a.schema.builder.spi.DialectTableMetaDataLoader |   1 +
 .../optimize/context/OptimizeContextFactory.java   |   4 +-
 .../jdbc/recognizer/impl/OpenGaussRecognizer.java  |  44 +++++++
 ...aussStatementMemoryStrictlyFetchSizeSetter.java |  39 ++++++
 ...ion.jdbc.recognizer.spi.JDBCDriverURLRecognizer |   1 +
 ...tatement.StatementMemoryStrictlyFetchSizeSetter |   1 +
 .../src/main/resources/conf/config-sharding.yaml   |   4 +-
 .../postgresql/OpenGaussFrontendEngine.java        |  56 ++++++++
 ...oxy.frontend.spi.DatabaseProtocolFrontendEngine |   1 +
 .../postgresql/parser/OpenGaussParserFacade.java   |  43 ++++++
 .../facade/OpenGaussFormatSQLVisitorFacade.java    |  72 +++++++++++
 .../facade/OpenGaussStatementSQLVisitorFacade.java |  77 +++++++++++
 ...ere.sql.parser.spi.DatabaseTypedSQLParserFacade |   1 +
 ....shardingsphere.sql.parser.spi.SQLVisitorFacade |   2 +
 .../xa/jta/connection/XAConnectionFactory.java     |   1 +
 .../dialect/OpenGaussXADataSourceDefinition.java   |  39 ++++++
 ...ta.datasource.properties.XADataSourceDefinition |   1 +
 19 files changed, 529 insertions(+), 4 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java
index 84974b3..b9837e6 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java
@@ -42,7 +42,7 @@ public final class OpenGaussDataSourceMetaData implements DataSourceMetaData {
     private final String schema;
     
     // TODO fix OpenGauss's url pattern
-    private final Pattern pattern = Pattern.compile("jdbc:openguass://([\\w\\-\\.]+):?([0-9]*),?.*?/([\\w\\-]+)?\\S*", Pattern.CASE_INSENSITIVE);
+    private final Pattern pattern = Pattern.compile("jdbc:opengauss://([\\w\\-\\.]+):?([0-9]*),?.*?/([\\w\\-]+)?\\S*", Pattern.CASE_INSENSITIVE);
     
     public OpenGaussDataSourceMetaData(final String url) {
         Matcher matcher = pattern.matcher(url);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/loader/dialect/OpenGaussTableMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/loader/dialect/OpenGaussTableMetaDataLoader.java
new file mode 100644
index 0000000..9346b5a
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/builder/loader/dialect/OpenGaussTableMetaDataLoader.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect;
+
+import org.apache.shardingsphere.infra.metadata.schema.builder.loader.DataTypeLoader;
+import org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectTableMetaDataLoader;
+import org.apache.shardingsphere.infra.metadata.schema.model.ColumnMetaData;
+import org.apache.shardingsphere.infra.metadata.schema.model.IndexMetaData;
+import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Table meta data loader for OpenGauss.
+ */
+public final class OpenGaussTableMetaDataLoader implements DialectTableMetaDataLoader {
+    
+    private static final String BASIC_TABLE_META_DATA_SQL = "SELECT table_name, column_name, data_type, udt_name, column_default FROM information_schema.columns WHERE table_schema = ?";
+    
+    private static final String TABLE_META_DATA_SQL_WITH_EXISTED_TABLES = BASIC_TABLE_META_DATA_SQL + " AND table_name NOT IN (%s)";
+    
+    private static final String PRIMARY_KEY_META_DATA_SQL = "SELECT tc.table_name, kc.column_name FROM information_schema.table_constraints tc"
+            + " JOIN information_schema.key_column_usage kc"
+            + " ON kc.table_schema = tc.table_schema AND kc.table_name = tc.table_name AND kc.constraint_name = tc.constraint_name"
+            + " WHERE tc.constraint_type = 'PRIMARY KEY' AND kc.ordinal_position IS NOT NULL AND kc.table_schema = ?";
+    
+    private static final String BASIC_INDEX_META_DATA_SQL = "SELECT tablename, indexname FROM pg_indexes WHERE schemaname = ?";
+    
+    @Override
+    public Map<String, TableMetaData> load(final DataSource dataSource, final Collection<String> existedTables) throws SQLException {
+        Map<String, TableMetaData> result = new LinkedHashMap<>();
+        Map<String, Collection<IndexMetaData>> indexMetaDataMap = loadIndexMetaDataMap(dataSource);
+        for (Entry<String, Collection<ColumnMetaData>> entry : loadColumnMetaDataMap(dataSource, existedTables).entrySet()) {
+            Collection<IndexMetaData> indexMetaDataList = indexMetaDataMap.get(entry.getKey());
+            if (null == indexMetaDataList) {
+                indexMetaDataList = Collections.emptyList();
+            }
+            result.put(entry.getKey(), new TableMetaData(entry.getValue(), indexMetaDataList));
+        }
+        return result;
+    }
+    
+    private Map<String, Collection<ColumnMetaData>> loadColumnMetaDataMap(final DataSource dataSource, final Collection<String> existedTables) throws SQLException {
+        Map<String, Collection<ColumnMetaData>> result = new HashMap<>();
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = connection.prepareStatement(getTableMetaDataSQL(existedTables))) {
+            Map<String, Integer> dataTypes = DataTypeLoader.load(connection.getMetaData());
+            Set<String> primaryKeys = loadPrimaryKeys(connection);
+            preparedStatement.setString(1, connection.getSchema());
+            try (ResultSet resultSet = preparedStatement.executeQuery()) {
+                while (resultSet.next()) {
+                    String tableName = resultSet.getString("table_name");
+                    Collection<ColumnMetaData> columns = result.computeIfAbsent(tableName, key -> new LinkedList<>());
+                    ColumnMetaData columnMetaData = loadColumnMetaData(dataTypes, primaryKeys, resultSet);
+                    columns.add(columnMetaData);
+                }
+            }
+        }
+        return result;
+    }
+    
+    private Set<String> loadPrimaryKeys(final Connection connection) throws SQLException {
+        Set<String> result = new HashSet<>();
+        try (PreparedStatement preparedStatement = connection.prepareStatement(PRIMARY_KEY_META_DATA_SQL)) {
+            preparedStatement.setString(1, connection.getSchema());
+            try (ResultSet resultSet = preparedStatement.executeQuery()) {
+                while (resultSet.next()) {
+                    String tableName = resultSet.getString("table_name");
+                    String columnName = resultSet.getString("column_name");
+                    result.add(tableName + "," + columnName);
+                }
+            }
+        }
+        return result;
+    }
+    
+    private ColumnMetaData loadColumnMetaData(final Map<String, Integer> dataTypeMap, final Set<String> primaryKeys, final ResultSet resultSet) throws SQLException {
+        String tableName = resultSet.getString("table_name");
+        String columnName = resultSet.getString("column_name");
+        String dataType = resultSet.getString("udt_name");
+        boolean isPrimaryKey = primaryKeys.contains(tableName + "," + columnName);
+        String columnDefault = resultSet.getString("column_default");
+        boolean generated = null != columnDefault && columnDefault.startsWith("nextval(");
+        //TODO user defined collation which deterministic is false
+        boolean caseSensitive = true;
+        return new ColumnMetaData(columnName, dataTypeMap.get(dataType), isPrimaryKey, generated, caseSensitive);
+    }
+    
+    private String getTableMetaDataSQL(final Collection<String> existedTables) {
+        return existedTables.isEmpty() ? BASIC_TABLE_META_DATA_SQL
+                : String.format(TABLE_META_DATA_SQL_WITH_EXISTED_TABLES, existedTables.stream().map(each -> String.format("'%s'", each)).collect(Collectors.joining(",")));
+    }
+    
+    private Map<String, Collection<IndexMetaData>> loadIndexMetaDataMap(final DataSource dataSource) throws SQLException {
+        Map<String, Collection<IndexMetaData>> result = new HashMap<>();
+        try (Connection connection = dataSource.getConnection();
+             PreparedStatement preparedStatement = connection.prepareStatement(BASIC_INDEX_META_DATA_SQL)) {
+            preparedStatement.setString(1, connection.getSchema());
+            try (ResultSet resultSet = preparedStatement.executeQuery()) {
+                while (resultSet.next()) {
+                    String tableName = resultSet.getString("tablename");
+                    Collection<IndexMetaData> indexes = result.computeIfAbsent(tableName, k -> new LinkedList<>());
+                    String indexName = resultSet.getString("indexname");
+                    indexes.add(new IndexMetaData(indexName));
+                }
+            }
+        }
+        return result;
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectTableMetaDataLoader b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectTableMetaDataLoader
index 9e92eb6..4dbc8ef 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectTableMetaDataLoader
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.metadata.schema.builder.spi.DialectTableMetaDataLoader
@@ -18,5 +18,6 @@
 org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect.MySQLTableMetaDataLoader
 org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect.OracleTableMetaDataLoader
 org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect.PostgreSQLTableMetaDataLoader
+org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect.OpenGaussTableMetaDataLoader
 org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect.SQLServerTableMetaDataLoader
 org.apache.shardingsphere.infra.metadata.schema.builder.loader.dialect.H2TableMetaDataLoader
diff --git a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizeContextFactory.java b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizeContextFactory.java
index c3485a9..1d9aaff 100644
--- a/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizeContextFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-optimize/src/main/java/org/apache/shardingsphere/infra/optimize/context/OptimizeContextFactory.java
@@ -45,6 +45,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.MariaDBDatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.OracleDatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.SQL92DatabaseType;
@@ -118,7 +119,8 @@ public final class OptimizeContextFactory {
             properties.setProperty(CONFORMANCE_CAMEL_NAME, SqlConformanceEnum.ORACLE_12.name());
             return;
         }
-        if (databaseType instanceof PostgreSQLDatabaseType) {
+        if (databaseType instanceof PostgreSQLDatabaseType
+            || databaseType instanceof OpenGaussDatabaseType) {
             // TODO No suitable type of Lex and conformance
             properties.setProperty(LEX_CAMEL_NAME, Lex.JAVA.name());
             properties.setProperty(CONFORMANCE_CAMEL_NAME, SqlConformanceEnum.BABEL.name());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/recognizer/impl/OpenGaussRecognizer.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/recognizer/impl/OpenGaussRecognizer.java
new file mode 100644
index 0000000..4a545c0
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/recognizer/impl/OpenGaussRecognizer.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl;
+
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.spi.JDBCDriverURLRecognizer;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * JDBC URL recognizer for OpenGauss.
+ */
+public final class OpenGaussRecognizer implements JDBCDriverURLRecognizer {
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+    
+    @Override
+    public Collection<String> getURLPrefixes() {
+        return Collections.singletonList("jdbc:opengauss:");
+    }
+    
+    @Override
+    public String getDriverClassName() {
+        return "org.postgresql.OpenGaussDriver";
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetter.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetter.java
new file mode 100644
index 0000000..0e9fbf1
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.impl;
+
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Statement memory strictly fetch size setter for OpenGauss.
+ */
+public final class OpenGaussStatementMemoryStrictlyFetchSizeSetter implements StatementMemoryStrictlyFetchSizeSetter {
+    
+    @Override
+    public void setFetchSize(final Statement statement) throws SQLException {
+        statement.setFetchSize(1);
+    }
+    
+    @Override
+    public String getType() {
+        return "OpenGauss";
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.spi.JDBCDriverURLRecognizer b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.spi.JDBCDriverURLRecognizer
index ef113f7..3a86eb7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.spi.JDBCDriverURLRecognizer
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.spi.JDBCDriverURLRecognizer
@@ -17,6 +17,7 @@
 
 org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl.MySQLRecognizer
 org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl.PostgreSQLRecognizer
+org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl.OpenGaussRecognizer
 org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl.OracleRecognizer
 org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl.SQLServerRecognizer
 org.apache.shardingsphere.proxy.backend.communication.jdbc.recognizer.impl.H2Recognizer
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter
index 1992b53..077e29e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter
@@ -17,3 +17,4 @@
 
 org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.impl.MySQLStatementMemoryStrictlyFetchSizeSetter
 org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.impl.PostgreSQLStatementMemoryStrictlyFetchSizeSetter
+org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.impl.OpenGaussStatementMemoryStrictlyFetchSizeSetter
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
index 621efaa..f0de349 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/config-sharding.yaml
@@ -75,7 +75,7 @@
 #      shardingAlgorithmName: database_inline
 #  defaultTableStrategy:
 #    none:
-#  
+#
 #  shardingAlgorithms:
 #    database_inline:
 #      type: INLINE
@@ -89,7 +89,7 @@
 #      type: INLINE
 #      props:
 #        algorithm-expression: t_order_item_${order_id % 2}
-#  
+#
 #  keyGenerators:
 #    snowflake:
 #      type: SNOWFLAKE
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/OpenGaussFrontendEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/OpenGaussFrontendEngine.java
new file mode 100644
index 0000000..41090e1
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/OpenGaussFrontendEngine.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.postgresql;
+
+import lombok.Getter;
+import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
+import org.apache.shardingsphere.db.protocol.postgresql.codec.PostgreSQLPacketCodecEngine;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
+import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
+import org.apache.shardingsphere.proxy.frontend.context.FrontendContext;
+import org.apache.shardingsphere.proxy.frontend.postgresql.authentication.PostgreSQLAuthenticationEngine;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine;
+import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
+
+/**
+ * Frontend engine for OpenGauss.
+ */
+@Getter
+public final class OpenGaussFrontendEngine implements DatabaseProtocolFrontendEngine {
+    
+    private final FrontendContext frontendContext = new FrontendContext(true, false);
+    
+    private final AuthenticationEngine authenticationEngine = new PostgreSQLAuthenticationEngine();
+    
+    private final CommandExecuteEngine commandExecuteEngine = new PostgreSQLCommandExecuteEngine();
+    
+    private final DatabasePacketCodecEngine<PostgreSQLPacket> codecEngine = new PostgreSQLPacketCodecEngine();
+    
+    @Override
+    public void release(final BackendConnection backendConnection) {
+        PostgreSQLBinaryStatementRegistry.getInstance().unregister(backendConnection.getConnectionId());
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine
index 05657ad..4f9324e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine
@@ -16,3 +16,4 @@
 #
 
 org.apache.shardingsphere.proxy.frontend.postgresql.PostgreSQLFrontendEngine
+org.apache.shardingsphere.proxy.frontend.postgresql.OpenGaussFrontendEngine
\ No newline at end of file
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
new file mode 100644
index 0000000..cce6487
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.postgresql.parser;
+
+import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
+import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.spi.SQLParserFacade;
+
+/**
+ * SQL parser facade for OpenGauss.
+ */
+public final class OpenGaussParserFacade implements SQLParserFacade {
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+    
+    @Override
+    public Class<? extends SQLLexer> getLexerClass() {
+        return PostgreSQLLexer.class;
+    }
+    
+    @Override
+    public Class<? extends SQLParser> getParserClass() {
+        return PostgreSQLParser.class;
+    }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java
new file mode 100644
index 0000000..c28e787
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.postgresql.visitor.format.facade;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DMLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.RLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
+
+/**
+ * Format SQL Visitor facade for OpenGauss.
+ */
+public final class OpenGaussFormatSQLVisitorFacade implements SQLVisitorFacade {
+    
+    @Override
+    public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public Class<? extends DALSQLVisitor> getDALVisitorClass() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public Class<? extends RLSQLVisitor> getRLVisitorClass() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+    
+    @Override
+    public String getVisitorType() {
+        return "FORMAT";
+    }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/facade/OpenGaussStatementSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/facade/OpenGaussStatementSQLVisitorFacade.java
new file mode 100644
index 0000000..a60356a
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/facade/OpenGaussStatementSQLVisitorFacade.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.facade;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.DMLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.RLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLDALStatementSQLVisitor;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLDCLStatementSQLVisitor;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLDDLStatementSQLVisitor;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLDMLStatementSQLVisitor;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLTCLStatementSQLVisitor;
+import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
+
+/**
+ * Statement SQL Visitor facade for OpenGauss.
+ */
+public final class OpenGaussStatementSQLVisitorFacade implements SQLVisitorFacade {
+    
+    @Override
+    public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
+        return PostgreSQLDMLStatementSQLVisitor.class;
+    }
+    
+    @Override
+    public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
+        return PostgreSQLDDLStatementSQLVisitor.class;
+    }
+    
+    @Override
+    public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
+        return PostgreSQLTCLStatementSQLVisitor.class;
+    }
+    
+    @Override
+    public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
+        return PostgreSQLDCLStatementSQLVisitor.class;
+    }
+    
+    @Override
+    public Class<? extends DALSQLVisitor> getDALVisitorClass() {
+        return PostgreSQLDALStatementSQLVisitor.class;
+    }
+    
+    @Override
+    public Class<? extends RLSQLVisitor> getRLVisitorClass() {
+        return null;
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+    
+    @Override
+    public String getVisitorType() {
+        return "STATEMENT";
+    }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.DatabaseTypedSQLParserFacade b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.DatabaseTypedSQLParserFacade
index b5461a9..54ae70b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.DatabaseTypedSQLParserFacade
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.DatabaseTypedSQLParserFacade
@@ -16,3 +16,4 @@
 #
 
 org.apache.shardingsphere.sql.parser.postgresql.parser.PostgreSQLParserFacade
+org.apache.shardingsphere.sql.parser.postgresql.parser.OpenGaussParserFacade
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade
index b1fc497..611c2ec 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade
@@ -16,4 +16,6 @@
 #
 
 org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.facade.PostgreSQLStatementSQLVisitorFacade
+org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.facade.OpenGaussStatementSQLVisitorFacade
 org.apache.shardingsphere.sql.parser.postgresql.visitor.format.facade.PostgreSQLFormatSQLVisitorFacade
+org.apache.shardingsphere.sql.parser.postgresql.visitor.format.facade.OpenGaussFormatSQLVisitorFacade
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java
index afad978..171a58e 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionFactory.java
@@ -51,6 +51,7 @@ public final class XAConnectionFactory {
             case "MariaDB":
                 return new MariaDBXAConnectionWrapper().wrap(xaDataSource, connection);
             case "PostgreSQL":
+            case "OpenGauss":
                 return new PostgreSQLXAConnectionWrapper().wrap(xaDataSource, connection);
             case "H2":
                 return new H2XAConnectionWrapper().wrap(xaDataSource, connection);
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinition.java b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSo [...]
new file mode 100644
index 0000000..9905384
--- /dev/null
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinition.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
+
+import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * XA data source definition for PostgreSQL.
+ */
+public final class OpenGaussXADataSourceDefinition implements XADataSourceDefinition {
+    
+    @Override
+    public String getDatabaseType() {
+        return "OpenGauss";
+    }
+    
+    @Override
+    public Collection<String> getXADriverClassName() {
+        return Collections.singletonList("org.postgresql.xa.PGXADataSource");
+    }
+}
diff --git a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.X [...]
index fc31195..6e707a8 100644
--- a/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition
+++ b/shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition
@@ -18,6 +18,7 @@
 org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.MySQLXADataSourceDefinition
 org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.MariaDBXADataSourceDefinition
 org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.PostgreSQLXADataSourceDefinition
+org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.OpenGaussXADataSourceDefinition
 org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.OracleXADataSourceDefinition
 org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.SQLServerXADataSourceDefinition
 org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.H2XADataSourceDefinition

[shardingsphere] 06/07: Fix implements of OpenGaussParserFacade (#10849)

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit c9762a5916b23e0e9921ddc07a7f78cd302a6d4d
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Thu Jun 17 20:34:44 2021 +0800

    Fix implements of OpenGaussParserFacade (#10849)
---
 .../sql/parser/postgresql/parser/OpenGaussParserFacade.java        | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
index 1f23cb1..94ce786 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
@@ -19,18 +19,19 @@ package org.apache.shardingsphere.sql.parser.postgresql.parser;
 
 import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
 import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.spi.SQLParserFacade;
+import org.apache.shardingsphere.sql.parser.spi.DatabaseTypedSQLParserFacade;
 
 /**
  * SQL parser facade for OpenGauss.
  */
-public final class OpenGaussParserFacade implements SQLParserFacade {
-
+public final class OpenGaussParserFacade implements DatabaseTypedSQLParserFacade {
+    
     /**
      * Get Database Type.
      *
      * @return Database Type
      */
+    @Override
     public String getDatabaseType() {
         return "OpenGauss";
     }

[shardingsphere] 05/07: Fix : fix checkstyle violation (#10838)

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit 20abdb6c70703771666d327a4c42ea1679116ccc
Author: 孙念君 Sun Nianjun <ka...@outlook.com>
AuthorDate: Thu Jun 17 11:45:14 2021 +0800

    Fix : fix checkstyle violation (#10838)
---
 .../sql/parser/postgresql/parser/OpenGaussParserFacade.java        | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
index 2962261..1f23cb1 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
@@ -25,7 +25,12 @@ import org.apache.shardingsphere.sql.parser.spi.SQLParserFacade;
  * SQL parser facade for OpenGauss.
  */
 public final class OpenGaussParserFacade implements SQLParserFacade {
-    
+
+    /**
+     * Get Database Type.
+     *
+     * @return Database Type
+     */
     public String getDatabaseType() {
         return "OpenGauss";
     }

[shardingsphere] 07/07: Implements openGauss batch bind protocol (#10850)

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit 2a39e42ba1e08ca2c7e7440069146a5c4249e21b
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Thu Jun 17 23:53:46 2021 +0800

    Implements openGauss batch bind protocol (#10850)
    
    * Implements openGauss BatchBind
    
    * Add javadoc
---
 .../command/PostgreSQLCommandPacketFactory.java    |   3 +
 .../command/PostgreSQLCommandPacketType.java       |   2 +
 .../binary/bind/OpenGaussComBatchBindPacket.java   | 179 +++++++++++++++++++++
 .../command/PostgreSQLCommandExecutorFactory.java  |   4 +
 .../binary/bind/OpenGaussComBatchBindExecutor.java | 171 ++++++++++++++++++++
 5 files changed, 359 insertions(+)

diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactory.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactory.java
index 070bc37..9832864 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactory.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactory.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.admin.PostgreSQLUnsupportedCommandPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.OpenGaussComBatchBindPacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.PostgreSQLComBindPacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.close.PostgreSQLComClosePacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.describe.PostgreSQLComDescribePacket;
@@ -52,6 +53,8 @@ public final class PostgreSQLCommandPacketFactory {
                 return new PostgreSQLComParsePacket(payload);
             case BIND_COMMAND:
                 return new PostgreSQLComBindPacket(payload, connectionId);
+            case BATCH_BIND_COMMAND:
+                return new OpenGaussComBatchBindPacket(payload, connectionId);
             case DESCRIBE_COMMAND:
                 return new PostgreSQLComDescribePacket(payload);
             case EXECUTE_COMMAND:
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
index 014ad2d..f59f684 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
@@ -37,6 +37,8 @@ public enum PostgreSQLCommandPacketType implements CommandPacketType, PostgreSQL
     
     BIND_COMMAND('B'),
     
+    BATCH_BIND_COMMAND('U'),
+    
     DESCRIBE_COMMAND('D'),
     
     EXECUTE_COMMAND('E'),
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/OpenGaussComBatchBindPacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/OpenGaussComBatchBindPacket.java
new file mode 100644
index 0000000..8c290e9
--- /dev/null
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/OpenGaussComBatchBindPacket.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind;
+
+import com.google.common.collect.Lists;
+import lombok.Getter;
+import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
+import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnFormat;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatement;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol.PostgreSQLBinaryProtocolValue;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol.PostgreSQLBinaryProtocolValueFactory;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
+import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Batch bind packet for openGauss.
+ */
+@Getter
+public final class OpenGaussComBatchBindPacket extends PostgreSQLCommandPacket {
+    
+    private final String statementId;
+    
+    private final String sql;
+    
+    private final List<Integer> resultFormatCodes;
+    
+    private final List<List<Object>> parameters;
+    
+    public OpenGaussComBatchBindPacket(final PostgreSQLPacketPayload payload, final int connectionId) {
+        payload.readInt4();
+        payload.readInt4();
+        payload.readStringNul();
+        statementId = payload.readStringNul();
+        int parameterFormatCount = payload.readInt2();
+        List<Integer> parameterFormats = new ArrayList<>(parameterFormatCount);
+        for (int i = 0; i < parameterFormatCount; i++) {
+            parameterFormats.add(payload.readInt2());
+        }
+        int resultFormatsLength = payload.readInt2();
+        resultFormatCodes = new ArrayList<>(resultFormatsLength);
+        for (int i = 0; i < resultFormatsLength; i++) {
+            resultFormatCodes.add(payload.readInt2());
+        }
+        PostgreSQLBinaryStatement binaryStatement = PostgreSQLBinaryStatementRegistry.getInstance().get(connectionId).getBinaryStatement(statementId);
+        sql = null == binaryStatement ? null : binaryStatement.getSql();
+        List<Object> allParameters = null == sql ? Collections.emptyList() : getParameters(payload, parameterFormats, binaryStatement.getColumnTypes());
+        parameters = Lists.partition(allParameters, parameterFormatCount);
+        payload.readInt1();
+        payload.readStringNul();
+        payload.readInt4();
+    }
+    
+    private List<Object> getParameters(final PostgreSQLPacketPayload payload, final List<Integer> parameterFormats, final List<PostgreSQLBinaryColumnType> columnTypes) {
+        int parameterCount = payload.readInt2();
+        List<Object> result = new ArrayList<>(parameterCount);
+        for (int parameterIndex = 0; hasNextParameter(payload); parameterIndex++) {
+            int parameterValueLength = payload.readInt4();
+            if (-1 == parameterValueLength) {
+                result.add(null);
+                continue;
+            }
+            int modedParameterIndex = parameterIndex % parameterCount;
+            Object parameterValue = isTextParameterValue(parameterFormats, modedParameterIndex)
+                    ? getTextParameters(payload, parameterValueLength, columnTypes.get(modedParameterIndex)) : getBinaryParameters(payload, parameterValueLength, columnTypes.get(modedParameterIndex));
+            result.add(parameterValue);
+        }
+        return result;
+    }
+    
+    private boolean hasNextParameter(final PostgreSQLPacketPayload payload) {
+        payload.getByteBuf().markReaderIndex();
+        int c = payload.readInt1();
+        payload.getByteBuf().resetReaderIndex();
+        return 'E' != c;
+    }
+    
+    private boolean isTextParameterValue(final List<Integer> parameterFormats, final int parameterIndex) {
+        return parameterFormats.isEmpty() || 0 == parameterFormats.get(parameterIndex % parameterFormats.size());
+    }
+    
+    private Object getTextParameters(final PostgreSQLPacketPayload payload, final int parameterValueLength, final PostgreSQLBinaryColumnType columnType) {
+        byte[] bytes = new byte[parameterValueLength];
+        payload.getByteBuf().readBytes(bytes);
+        return getTextParameters(new String(bytes), columnType);
+    }
+    
+    private Object getTextParameters(final String textValue, final PostgreSQLBinaryColumnType columnType) {
+        switch (columnType) {
+            case POSTGRESQL_TYPE_UNSPECIFIED:
+                return new PostgreSQLTypeUnspecifiedSQLParameter(textValue);
+            case POSTGRESQL_TYPE_BOOL:
+                return Boolean.valueOf(textValue);
+            case POSTGRESQL_TYPE_INT2:
+            case POSTGRESQL_TYPE_INT4:
+                return Integer.parseInt(textValue);
+            case POSTGRESQL_TYPE_INT8:
+                return Long.parseLong(textValue);
+            case POSTGRESQL_TYPE_FLOAT4:
+                return Float.parseFloat(textValue);
+            case POSTGRESQL_TYPE_FLOAT8:
+                return Double.parseDouble(textValue);
+            case POSTGRESQL_TYPE_NUMERIC:
+                try {
+                    return Integer.parseInt(textValue);
+                } catch (final NumberFormatException ignored) {
+                }
+                try {
+                    return Long.parseLong(textValue);
+                } catch (final NumberFormatException ignored) {
+                }
+                return new BigDecimal(textValue);
+            case POSTGRESQL_TYPE_DATE:
+                return Date.valueOf(textValue);
+            case POSTGRESQL_TYPE_TIME:
+                return Time.valueOf(textValue);
+            case POSTGRESQL_TYPE_TIMESTAMP:
+            case POSTGRESQL_TYPE_TIMESTAMPTZ:
+                return Timestamp.valueOf(textValue);
+            default:
+                return textValue;
+        }
+    }
+    
+    private Object getBinaryParameters(final PostgreSQLPacketPayload payload, final int parameterValueLength, final PostgreSQLBinaryColumnType columnType) {
+        PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(columnType);
+        return binaryProtocolValue.read(payload, parameterValueLength);
+    }
+    
+    /**
+     * Get result format by column index.
+     *
+     * @param columnIndex column index
+     * @return result format
+     */
+    public PostgreSQLColumnFormat getResultFormatByColumnIndex(final int columnIndex) {
+        if (resultFormatCodes.isEmpty()) {
+            return PostgreSQLColumnFormat.TEXT;
+        }
+        if (1 == resultFormatCodes.size()) {
+            return PostgreSQLColumnFormat.valueOf(resultFormatCodes.get(0));
+        }
+        return PostgreSQLColumnFormat.valueOf(resultFormatCodes.get(columnIndex));
+    }
+    
+    @Override
+    public void write(final PostgreSQLPacketPayload payload) {
+    }
+    
+    @Override
+    public PostgreSQLIdentifierTag getIdentifier() {
+        return PostgreSQLCommandPacketType.BATCH_BIND_COMMAND;
+    }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
index a3a3abc..6da37e2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
@@ -22,6 +22,7 @@ import lombok.NoArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.OpenGaussComBatchBindPacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.PostgreSQLComBindPacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.close.PostgreSQLComClosePacket;
 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLComParsePacket;
@@ -30,6 +31,7 @@ import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.Bac
 import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
 import org.apache.shardingsphere.proxy.frontend.postgresql.command.generic.PostgreSQLComTerminationExecutor;
 import org.apache.shardingsphere.proxy.frontend.postgresql.command.generic.PostgreSQLUnsupportedCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.bind.OpenGaussComBatchBindExecutor;
 import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.bind.PostgreSQLComBindExecutor;
 import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.close.PostgreSQLComCloseExecutor;
 import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.describe.PostgreSQLComDescribeExecutor;
@@ -69,6 +71,8 @@ public final class PostgreSQLCommandExecutorFactory {
             case BIND_COMMAND:
                 connectionContext.getPendingExecutors().add(new PostgreSQLComBindExecutor(connectionContext, (PostgreSQLComBindPacket) commandPacket, backendConnection));
                 break;
+            case BATCH_BIND_COMMAND:
+                return new OpenGaussComBatchBindExecutor(connectionContext, (OpenGaussComBatchBindPacket) commandPacket, backendConnection);
             case DESCRIBE_COMMAND:
                 connectionContext.getPendingExecutors().add(new PostgreSQLComDescribeExecutor(connectionContext));
                 break;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/OpenGaussComBatchBindExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/OpenGaussComBatchBindExecutor.java
new file mode 100644
index 0000000..b85a712
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/OpenGaussComBatchBindExecutor.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.bind;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.db.protocol.binary.BinaryCell;
+import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
+import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnFormat;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.OpenGaussComBatchBindPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.PostgreSQLBindCompletePacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.text.PostgreSQLDataRowPacket;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
+import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
+import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import org.apache.shardingsphere.proxy.backend.response.data.impl.BinaryQueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
+import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
+import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.PostgreSQLCommand;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Command batch bind executor for openGauss.
+ */
+@RequiredArgsConstructor
+public final class OpenGaussComBatchBindExecutor implements QueryCommandExecutor {
+    
+    private final PostgreSQLConnectionContext connectionContext;
+    
+    private final OpenGaussComBatchBindPacket packet;
+    
+    private final BackendConnection backendConnection;
+    
+    private final List<DatabaseCommunicationEngine> databaseCommunicationEngines = new LinkedList<>();
+    
+    @Getter
+    private volatile ResponseType responseType;
+    
+    private boolean batchBindComplete;
+    
+    @Override
+    public Collection<DatabasePacket<?>> execute() throws SQLException {
+        List<List<Object>> parameters = packet.getParameters();
+        for (int i = 0; i < parameters.size(); i++) {
+            List<Object> parameter = parameters.get(i);
+            init(parameter);
+            ResponseHeader responseHeader = databaseCommunicationEngines.get(i).execute();
+            if (responseHeader instanceof QueryResponseHeader && connectionContext.getDescribeExecutor().isPresent()) {
+                connectionContext.getDescribeExecutor().get().setRowDescriptionPacket(getRowDescriptionPacket((QueryResponseHeader) responseHeader));
+            }
+            if (responseHeader instanceof UpdateResponseHeader) {
+                responseType = ResponseType.UPDATE;
+                connectionContext.setUpdateCount(connectionContext.getUpdateCount() + ((UpdateResponseHeader) responseHeader).getUpdateCount());
+            }
+        }
+        return Collections.singletonList(new PostgreSQLBindCompletePacket());
+    }
+    
+    private void init(final List<Object> parameter) {
+        databaseCommunicationEngines.add(DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(getSqlStatement(), packet.getSql(), parameter, backendConnection));
+    }
+    
+    private SQLStatement getSqlStatement() {
+        return connectionContext.getSqlStatement().orElseGet(() -> {
+            SQLStatement result = parseSql(packet.getSql(), backendConnection.getSchemaName());
+            connectionContext.setSqlStatement(result);
+            return result;
+        });
+    }
+    
+    private SQLStatement parseSql(final String sql, final String schemaName) {
+        if (sql.isEmpty()) {
+            return new EmptyStatement();
+        }
+        ShardingSphereSQLParserEngine sqlStatementParserEngine = new ShardingSphereSQLParserEngine(
+                DatabaseTypeRegistry.getTrunkDatabaseTypeName(ProxyContext.getInstance().getMetaDataContexts().getMetaData(schemaName).getResource().getDatabaseType()));
+        return sqlStatementParserEngine.parse(sql, true);
+    }
+    
+    private PostgreSQLRowDescriptionPacket getRowDescriptionPacket(final QueryResponseHeader queryResponseHeader) {
+        responseType = ResponseType.QUERY;
+        Collection<PostgreSQLColumnDescription> columnDescriptions = createColumnDescriptions(queryResponseHeader);
+        return new PostgreSQLRowDescriptionPacket(columnDescriptions.size(), columnDescriptions);
+    }
+    
+    private Collection<PostgreSQLColumnDescription> createColumnDescriptions(final QueryResponseHeader queryResponseHeader) {
+        Collection<PostgreSQLColumnDescription> result = new LinkedList<>();
+        int columnIndex = 0;
+        for (QueryHeader each : queryResponseHeader.getQueryHeaders()) {
+            result.add(new PostgreSQLColumnDescription(each.getColumnName(), ++columnIndex, each.getColumnType(), each.getColumnLength(), each.getColumnTypeName()));
+        }
+        return result;
+    }
+    
+    @Override
+    public boolean next() throws SQLException {
+        Iterator<DatabaseCommunicationEngine> iterator = databaseCommunicationEngines.iterator();
+        while (iterator.hasNext()) {
+            if (iterator.next().next()) {
+                return true;
+            } else {
+                iterator.remove();
+            }
+        }
+        return !batchBindComplete && (batchBindComplete = true);
+    }
+    
+    @Override
+    public PostgreSQLPacket getQueryRowPacket() throws SQLException {
+        if (batchBindComplete) {
+            String sqlCommand = connectionContext.getSqlStatement().map(SQLStatement::getClass).map(PostgreSQLCommand::valueOf).map(command -> command.map(Enum::name).orElse("")).orElse("");
+            return new PostgreSQLCommandCompletePacket(sqlCommand, connectionContext.getUpdateCount());
+        }
+        QueryResponseRow queryResponseRow = databaseCommunicationEngines.get(0).getQueryResponseRow();
+        return new PostgreSQLDataRowPacket(getData(queryResponseRow));
+    }
+    
+    private List<Object> getData(final QueryResponseRow queryResponseRow) {
+        Collection<QueryResponseCell> cells = queryResponseRow.getCells();
+        List<Object> result = new ArrayList<>(cells.size());
+        List<QueryResponseCell> columns = new ArrayList<>(cells);
+        for (int i = 0; i < columns.size(); i++) {
+            PostgreSQLColumnFormat format = packet.getResultFormatByColumnIndex(i);
+            result.add(PostgreSQLColumnFormat.BINARY == format ? createBinaryCell(columns.get(i)) : columns.get(i).getData());
+        }
+        return result;
+    }
+    
+    private BinaryCell createBinaryCell(final QueryResponseCell cell) {
+        return new BinaryCell(PostgreSQLBinaryColumnType.valueOfJDBCType(((BinaryQueryResponseCell) cell).getJdbcType()), cell.getData());
+    }
+}

[shardingsphere] 02/07: Update OpenGaussDataSourceMetaData

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit 0c7ea9ed257741931879a06143d529e0c1884a43
Author: zhangliang <zh...@apache.org>
AuthorDate: Mon May 10 13:24:34 2021 +0800

    Update OpenGaussDataSourceMetaData
---
 .../infra/database/type/dialect/OpenGaussDatabaseType.java          | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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 9b3d2e0..d41e53e 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
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.infra.database.type.dialect;
 
-import org.apache.shardingsphere.infra.database.metadata.dialect.MariaDBDataSourceMetaData;
+import org.apache.shardingsphere.infra.database.metadata.dialect.OpenGaussDataSourceMetaData;
 import org.apache.shardingsphere.infra.database.type.BranchDatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
@@ -48,8 +48,8 @@ public final class OpenGaussDatabaseType implements BranchDatabaseType {
     }
     
     @Override
-    public MariaDBDataSourceMetaData getDataSourceMetaData(final String url, final String username) {
-        return new MariaDBDataSourceMetaData(url);
+    public OpenGaussDataSourceMetaData getDataSourceMetaData(final String url, final String username) {
+        return new OpenGaussDataSourceMetaData(url);
     }
     
     @Override

[shardingsphere] 01/07: Add OpenGauss Database type (#10292)

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit c467637f94b21869c1a7a91c7c3b9b0222e019b5
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon May 10 12:53:24 2021 +0800

    Add OpenGauss Database type (#10292)
---
 .../dialect/OpenGaussDataSourceMetaData.java       | 57 +++++++++++++++++++++
 .../type/dialect/OpenGaussDatabaseType.java        | 59 ++++++++++++++++++++++
 ...shardingsphere.infra.database.type.DatabaseType |  1 +
 3 files changed, 117 insertions(+)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java
new file mode 100644
index 0000000..84974b3
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/dialect/OpenGaussDataSourceMetaData.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.database.metadata.dialect;
+
+import com.google.common.base.Strings;
+import lombok.Getter;
+import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
+import org.apache.shardingsphere.infra.database.metadata.UnrecognizedDatabaseURLException;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Data source meta data for OpenGauss.
+ */
+@Getter
+public final class OpenGaussDataSourceMetaData implements DataSourceMetaData {
+    
+    private static final int DEFAULT_PORT = 5432;
+    
+    private final String hostName;
+    
+    private final int port;
+    
+    private final String catalog;
+    
+    private final String schema;
+    
+    // TODO fix OpenGauss's url pattern
+    private final Pattern pattern = Pattern.compile("jdbc:openguass://([\\w\\-\\.]+):?([0-9]*),?.*?/([\\w\\-]+)?\\S*", Pattern.CASE_INSENSITIVE);
+    
+    public OpenGaussDataSourceMetaData(final String url) {
+        Matcher matcher = pattern.matcher(url);
+        if (!matcher.find()) {
+            throw new UnrecognizedDatabaseURLException(url, pattern.pattern());
+        }
+        hostName = matcher.group(1);
+        port = Strings.isNullOrEmpty(matcher.group(2)) ? DEFAULT_PORT : Integer.parseInt(matcher.group(2));
+        catalog = matcher.group(3);
+        schema = null;
+    }
+}
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
new file mode 100644
index 0000000..9b3d2e0
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/type/dialect/OpenGaussDatabaseType.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.database.type.dialect;
+
+import org.apache.shardingsphere.infra.database.metadata.dialect.MariaDBDataSourceMetaData;
+import org.apache.shardingsphere.infra.database.type.BranchDatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Database type of OpenGauss.
+ */
+public final class OpenGaussDatabaseType implements BranchDatabaseType {
+    
+    @Override
+    public String getName() {
+        return "OpenGauss";
+    }
+    
+    @Override
+    public QuoteCharacter getQuoteCharacter() {
+        return QuoteCharacter.QUOTE;
+    }
+    
+    @Override
+    public Collection<String> getJdbcUrlPrefixes() {
+        // TODO fix OpenGauss's url pattern
+        return Collections.singleton(String.format("jdbc:%s:", getName().toLowerCase()));
+    }
+    
+    @Override
+    public MariaDBDataSourceMetaData getDataSourceMetaData(final String url, final String username) {
+        return new MariaDBDataSourceMetaData(url);
+    }
+    
+    @Override
+    public DatabaseType getTrunkDatabaseType() {
+        return DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL");
+    }
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType
index 3c34e38..8a86232 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType
@@ -19,6 +19,7 @@ org.apache.shardingsphere.infra.database.type.dialect.SQL92DatabaseType
 org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType
 org.apache.shardingsphere.infra.database.type.dialect.MariaDBDatabaseType
 org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType
+org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType
 org.apache.shardingsphere.infra.database.type.dialect.OracleDatabaseType
 org.apache.shardingsphere.infra.database.type.dialect.SQLServerDatabaseType
 org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType

[shardingsphere] 04/07: Fix : remove @Override annotation since getDatabaseType() has been removed from Interface (#10836)

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wuweijie pushed a commit to branch opengauss_adapt
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git

commit e7f00f972f61e17e0c5effb698ab690154af692e
Author: 孙念君 Sun Nianjun <ka...@outlook.com>
AuthorDate: Thu Jun 17 10:36:15 2021 +0800

    Fix : remove @Override annotation since getDatabaseType() has been removed from Interface (#10836)
---
 .../sql/parser/postgresql/parser/OpenGaussParserFacade.java              | 1 -
 1 file changed, 1 deletion(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
index cce6487..2962261 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/parser/OpenGaussParserFacade.java
@@ -26,7 +26,6 @@ import org.apache.shardingsphere.sql.parser.spi.SQLParserFacade;
  */
 public final class OpenGaussParserFacade implements SQLParserFacade {
     
-    @Override
     public String getDatabaseType() {
         return "OpenGauss";
     }