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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6dd0369  Avoid duplicated SQL parsing in Proxy (#14109)
6dd0369 is described below

commit 6dd0369c80f3631146c8e8a0aada40013360487c
Author: 吴伟杰 <[email protected]>
AuthorDate: Thu Dec 16 15:55:30 2021 +0800

    Avoid duplicated SQL parsing in Proxy (#14109)
    
    * Avoid duplicated SQL parsing in Proxy
    
    * Fix checkstyle
    
    * Fix checkstyle
---
 .../text/TextProtocolBackendHandlerFactory.java    | 11 ++++--
 .../TextProtocolBackendHandlerFactoryTest.java     | 44 +++++++++++-----------
 .../execute/MySQLComStmtExecuteExecutor.java       |  2 +-
 .../text/query/MySQLComQueryPacketExecutor.java    |  3 +-
 .../command/query/extended/PostgreSQLPortal.java   |  7 ++--
 .../query/simple/PostgreSQLComQueryExecutor.java   |  6 ++-
 6 files changed, 41 insertions(+), 32 deletions(-)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
index 3d46306..b2e3b80 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactory.java
@@ -56,6 +56,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.Optional;
+import java.util.function.Supplier;
 
 /**
  * Text protocol backend handler factory.
@@ -72,18 +73,22 @@ public final class TextProtocolBackendHandlerFactory {
      *
      * @param databaseType database type
      * @param sql SQL to be executed
+     * @param sqlStatementSupplier optional SQL statement supplier
      * @param connectionSession connection session
      * @return text protocol backend handler
      * @throws SQLException SQL exception
      */
     @SuppressWarnings("unchecked")
-    public static TextProtocolBackendHandler newInstance(final DatabaseType 
databaseType, final String sql, final ConnectionSession connectionSession) 
throws SQLException {
+    public static TextProtocolBackendHandler newInstance(final DatabaseType 
databaseType, final String sql, final Supplier<Optional<SQLStatement>> 
sqlStatementSupplier,
+                                                         final 
ConnectionSession connectionSession) throws SQLException {
         String trimSQL = SQLUtil.trimComment(sql);
         if (Strings.isNullOrEmpty(trimSQL)) {
             return new SkipBackendHandler(new EmptyStatement());
         }
-        Optional<SQLParserRule> sqlParserRule = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
-        SQLStatement sqlStatement = new 
ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, 
connectionSession).getName(), sqlParserRule.orElse(null)).parse(sql, false);
+        SQLStatement sqlStatement = sqlStatementSupplier.get().orElseGet(() -> 
{
+            Optional<SQLParserRule> sqlParserRule = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class);
+            return new 
ShardingSphereSQLParserEngine(getBackendDatabaseType(databaseType, 
connectionSession).getName(), sqlParserRule.orElse(null)).parse(sql, false);
+        });
         checkUnsupportedSQLStatement(sqlStatement);
         if (sqlStatement instanceof DistSQLStatement) {
             return DistSQLBackendHandlerFactory.newInstance(databaseType, 
(DistSQLStatement) sqlStatement, connectionSession);
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
index cc962e8..4eac91b 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
@@ -117,126 +117,126 @@ public final class 
TextProtocolBackendHandlerFactoryTest {
     @Test
     public void assertNewInstanceWithCommonDistSQL() throws SQLException {
         String sql = "set variable transaction_type=LOCAL";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(SetDistSQLBackendHandler.class));
         sql = "show variable transaction_type";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(ShowDistSQLBackendHandler.class));
         sql = "show all variables";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(ShowDistSQLBackendHandler.class));
         sql = "set sharding hint database_value=1";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(HintDistSQLBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithBegin() throws SQLException {
         String sql = "BEGIN";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(TransactionBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithStartTransaction() throws SQLException {
         String sql = "START TRANSACTION";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(TransactionBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithSetAutoCommitToOff() throws SQLException {
         String sql = "SET AUTOCOMMIT=0";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithScopeSetAutoCommitToOff() throws 
SQLException {
         String sql = "SET @@SESSION.AUTOCOMMIT = OFF";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithSetAutoCommitToOn() throws SQLException {
         String sql = "SET AUTOCOMMIT=1";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithScopeSetAutoCommitToOnForInTransaction() 
throws SQLException {
         String sql = "SET @@SESSION.AUTOCOMMIT = ON";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(TransactionAutoCommitHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithUse() throws SQLException {
         String sql = "use sharding_db";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, 
instanceOf(DatabaseAdminUpdateBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithShowDatabase() throws SQLException {
         String sql = "show databases";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(DatabaseAdminQueryBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithSet() throws SQLException {
         String sql = "set @num=1";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(BroadcastDatabaseBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithShow() throws SQLException {
         String sql = "SHOW VARIABLES LIKE '%x%'";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
         sql = "SHOW VARIABLES WHERE Variable_name ='language'";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
         sql = "SHOW CHARACTER SET";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
         sql = "SHOW COLLATION";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithQuery() throws SQLException {
         String sql = "select * from t_order limit 1";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, 
instanceOf(SchemaAssignedDatabaseBackendHandler.class));
         sql = "select * from information_schema.schemata limit 1";
-        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, connectionSession);
+        actual = TextProtocolBackendHandlerFactory.newInstance(databaseType, 
sql, Optional::empty, connectionSession);
         assertThat(actual, instanceOf(DatabaseAdminQueryBackendHandler.class));
     }
     
     @Test
     public void assertNewInstanceWithEmptyString() throws SQLException {
         String sql = "";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(SkipBackendHandler.class));
     }
     
     @Test(expected = SQLParsingException.class)
     public void assertNewInstanceWithErrorSQL() throws SQLException {
         String sql = "SELECT";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(SkipBackendHandler.class));
     }
     
     @Test(expected = SQLParsingException.class)
     public void assertNewInstanceWithErrorRDL() throws SQLException {
         String sql = "CREATE SHARDING";
-        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
connectionSession);
+        TextProtocolBackendHandler actual = 
TextProtocolBackendHandlerFactory.newInstance(databaseType, sql, 
Optional::empty, connectionSession);
         assertThat(actual, instanceOf(SkipBackendHandler.class));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
index 284ad40..9160b9e 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
@@ -98,7 +98,7 @@ public final class MySQLComStmtExecuteExecutor implements 
QueryCommandExecutor {
         if (sqlStatement instanceof TCLStatement) {
             databaseCommunicationEngine = null;
             textProtocolBackendHandler =
-                    
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"),
 packet.getSql(), connectionSession);
+                    
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"),
 packet.getSql(), () -> Optional.of(sqlStatement), connectionSession);
             return;
         }
         textProtocolBackendHandler = null;
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
index 8626370..4a9dd30 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
@@ -36,6 +36,7 @@ import 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.Resp
 
 import java.sql.SQLException;
 import java.util.Collection;
+import java.util.Optional;
 
 /**
  * COM_QUERY command packet executor for MySQL.
@@ -52,7 +53,7 @@ public final class MySQLComQueryPacketExecutor implements 
QueryCommandExecutor {
     private int currentSequenceId;
     
     public MySQLComQueryPacketExecutor(final MySQLComQueryPacket packet, final 
ConnectionSession connectionSession) throws SQLException {
-        textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"),
 packet.getSql(), connectionSession);
+        textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("MySQL"),
 packet.getSql(), Optional::empty, connectionSession);
         characterSet = 
connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
index 6de8d56..318ace7 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLPortal.java
@@ -22,11 +22,11 @@ import 
org.apache.shardingsphere.db.protocol.binary.BinaryCell;
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
 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.PostgreSQLDataRowPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLPreparedStatement;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
 import org.apache.shardingsphere.distsql.parser.statement.DistSQLStatement;
 import org.apache.shardingsphere.infra.binder.SQLStatementContextFactory;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
@@ -53,6 +53,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Optional;
 
 /**
  * PostgreSQL portal.
@@ -79,8 +80,8 @@ public final class PostgreSQLPortal {
         this.backendConnection = backendConnection;
         if (sqlStatement instanceof TCLStatement || sqlStatement instanceof 
EmptyStatement || sqlStatement instanceof DistSQLStatement) {
             databaseCommunicationEngine = null;
-            textProtocolBackendHandler =
-                    
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"),
 preparedStatement.getSql(), backendConnection.getConnectionSession());
+            textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"),
+                    preparedStatement.getSql(), () -> 
Optional.of(sqlStatement), backendConnection.getConnectionSession());
             return;
         }
         SQLStatementContext<?> sqlStatementContext = 
SQLStatementContextFactory.newInstance(
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
index db95bc7..6352683 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutor.java
@@ -21,10 +21,10 @@ import lombok.Getter;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 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.PostgreSQLDataRowPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLEmptyQueryResponsePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.simple.PostgreSQLComQueryPacket;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLDataRowPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
@@ -47,6 +47,7 @@ import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
+import java.util.Optional;
 
 /**
  * Command query executor for PostgreSQL.
@@ -63,7 +64,8 @@ public final class PostgreSQLComQueryExecutor implements 
QueryCommandExecutor {
     public PostgreSQLComQueryExecutor(final PostgreSQLConnectionContext 
connectionContext, final PostgreSQLComQueryPacket comQueryPacket,
                                       final ConnectionSession 
connectionSession) throws SQLException {
         this.connectionContext = connectionContext;
-        textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"),
 comQueryPacket.getSql(), connectionSession);
+        textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"),
+                comQueryPacket.getSql(), Optional::empty, connectionSession);
     }
     
     @Override

Reply via email to