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

wuweijie 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 e967a99  Remove PostgreSQLBinaryStatementRegistry (#11215)
e967a99 is described below

commit e967a998d98f343491cc25ad81306f6f7f86fd2c
Author: Juan Pan(Trista) <[email protected]>
AuthorDate: Thu Jul 8 18:31:57 2021 +0800

    Remove PostgreSQLBinaryStatementRegistry (#11215)
    
    * Remove PostgreSQLBinaryStatementRegistry
    
    * fix test
    
    * fix tests
    
    * fix tests
    
    * fix tests
    
    * fix tests
---
 .../command/PostgreSQLCommandPacketFactory.java    |  2 +-
 .../ConnectionScopeBinaryStatementRegistry.java    | 64 -------------------
 .../binary/PostgreSQLBinaryStatementRegistry.java  | 72 ----------------------
 .../query/binary/bind/PostgreSQLComBindPacket.java | 27 +++++---
 .../PostgreSQLCommandPacketFactoryTest.java        |  3 -
 ...ConnectionScopeBinaryStatementRegistryTest.java | 58 -----------------
 .../PostgreSQLBinaryStatementRegistryTest.java     | 63 -------------------
 .../binary/bind/PostgreSQLComBindPacketTest.java   | 15 ++---
 .../postgresql/PostgreSQLFrontendEngine.java       |  2 -
 .../PostgreSQLAuthenticationEngine.java            |  5 +-
 .../command}/PostgreSQLBinaryStatement.java        |  5 +-
 .../command/PostgreSQLConnectionContext.java       | 36 ++++++-----
 .../command/query/binary/PostgreSQLPortal.java     | 11 ++--
 .../binary/bind/PostgreSQLComBindExecutor.java     |  5 +-
 .../binary/close/PostgreSQLComCloseExecutor.java   | 11 +---
 .../binary/parse/PostgreSQLComParseExecutor.java   |  6 +-
 .../postgresql/PostgreSQLFrontendEngineTest.java   |  7 ---
 .../PostgreSQLAuthenticationEngineTest.java        |  8 ---
 .../PostgreSQLCommandExecutorFactoryTest.java      | 12 ++--
 .../binary/bind/PostgreSQLComBindExecutorTest.java | 12 +++-
 .../close/PostgreSQLComCloseExecutorTest.java      |  8 +--
 .../parse/PostgreSQLComParseExecutorTest.java      |  8 +--
 22 files changed, 79 insertions(+), 361 deletions(-)

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..ee670af 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
@@ -51,7 +51,7 @@ public final class PostgreSQLCommandPacketFactory {
             case PARSE_COMMAND:
                 return new PostgreSQLComParsePacket(payload);
             case BIND_COMMAND:
-                return new PostgreSQLComBindPacket(payload, connectionId);
+                return new PostgreSQLComBindPacket(payload);
             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/query/binary/ConnectionScopeBinaryStatementRegistry.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/ConnectionScopeBinaryStatementRegistry.java
deleted file mode 100644
index e455c4f..0000000
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/ConnectionScopeBinaryStatementRegistry.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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;
-
-import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
-
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Connection scope binary statement registry.
- */
-public final class ConnectionScopeBinaryStatementRegistry {
-    
-    private final ConcurrentMap<String, PostgreSQLBinaryStatement> 
binaryStatements = new ConcurrentHashMap<>(65535, 1);
-    
-    /**
-     * Register SQL.
-     *
-     * @param statementId statement ID
-     * @param sql SQL
-     * @param parameterCount parameter count
-     * @param binaryColumnTypes binary statement column types
-     */
-    public void register(final String statementId, final String sql, final int 
parameterCount, final List<PostgreSQLBinaryColumnType> binaryColumnTypes) {
-        binaryStatements.put(statementId, new PostgreSQLBinaryStatement(sql, 
parameterCount, binaryColumnTypes));
-    }
-    
-    /**
-     * Get binary prepared statement.
-     *
-     * @param statementId statement ID
-     * @return binary prepared statement
-     */
-    public PostgreSQLBinaryStatement getBinaryStatement(final String 
statementId) {
-        return binaryStatements.get(statementId);
-    }
-    
-    /**
-     * Close prepared statement.
-     *
-     * @param statementId statement ID
-     * @return closed binary prepared statement
-     */
-    public PostgreSQLBinaryStatement closeStatement(final String statementId) {
-        return binaryStatements.remove(statementId);
-    }
-}
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementRegistry.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementRegistry.java
deleted file mode 100644
index cd05f16..0000000
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementRegistry.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * PostgreSQL binary prepared statement registry.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class PostgreSQLBinaryStatementRegistry {
-    
-    private static final PostgreSQLBinaryStatementRegistry INSTANCE = new 
PostgreSQLBinaryStatementRegistry();
-    
-    private final ConcurrentMap<Integer, 
ConnectionScopeBinaryStatementRegistry> registries = new ConcurrentHashMap<>();
-    
-    /**
-     * Get instance of binary statement registry.
-     *
-     * @return instance of binary statement registry.
-     */
-    public static PostgreSQLBinaryStatementRegistry getInstance() {
-        return INSTANCE;
-    }
-    
-    /**
-     * Register.
-     *
-     * @param connectionId connection id
-     */
-    public void register(final int connectionId) {
-        registries.put(connectionId, new 
ConnectionScopeBinaryStatementRegistry());
-    }
-    
-    /**
-     * Unregister.
-     *
-     * @param connectionId connection id
-     */
-    public void unregister(final int connectionId) {
-        registries.remove(connectionId);
-    }
-    
-    /**
-     * Get connection scope binary statement registry.
-     *
-     * @param connectionId connection id
-     * @return connection scope binary statement registry
-     */
-    public ConnectionScopeBinaryStatementRegistry get(final int connectionId) {
-        return registries.get(connectionId);
-    }
-}
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacket.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacket.java
index 7955d3b..30ac867 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacket.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacket.java
@@ -22,8 +22,6 @@ import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinar
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
 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;
@@ -34,7 +32,7 @@ import java.sql.Date;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.LinkedList;
 import java.util.List;
 
 /**
@@ -43,30 +41,39 @@ import java.util.List;
 @Getter
 public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
     
+    private final PostgreSQLPacketPayload payload;
+    
     private final String portal;
     
     private final String statementId;
     
-    private final String sql;
-    
     private final List<Object> parameters;
     
     private final List<PostgreSQLValueFormat> resultFormats;
     
-    public PostgreSQLComBindPacket(final PostgreSQLPacketPayload payload, 
final int connectionId) {
+    public PostgreSQLComBindPacket(final PostgreSQLPacketPayload payload) {
+        this.payload = payload;
         payload.readInt4();
         portal = payload.readStringNul();
         statementId = payload.readStringNul();
+        parameters = new LinkedList<>();
+        resultFormats = new LinkedList<>();
+    }
+    
+    /**
+     * Init.
+     * @param columnTypes column types
+     */
+    public void init(final List<PostgreSQLBinaryColumnType> columnTypes) {
         int parameterFormatCount = payload.readInt2();
         List<Integer> parameterFormats = new ArrayList<>(parameterFormatCount);
         for (int i = 0; i < parameterFormatCount; i++) {
             parameterFormats.add(payload.readInt2());
         }
-        PostgreSQLBinaryStatement binaryStatement = 
PostgreSQLBinaryStatementRegistry.getInstance().get(connectionId).getBinaryStatement(statementId);
-        sql = null == binaryStatement ? null : binaryStatement.getSql();
-        parameters = null == sql ? Collections.emptyList() : 
getParameters(payload, parameterFormats, binaryStatement.getColumnTypes());
+        if (!columnTypes.isEmpty()) {
+            parameters.addAll(getParameters(payload, parameterFormats, 
columnTypes));
+        }
         int resultFormatsLength = payload.readInt2();
-        resultFormats = new ArrayList<>(resultFormatsLength);
         for (int i = 0; i < resultFormatsLength; i++) {
             
resultFormats.add(PostgreSQLValueFormat.valueOf(payload.readInt2()));
         }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
index 830675e..2cfb57e 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.db.protocol.postgresql.packet.command;
 
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 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;
@@ -61,8 +60,6 @@ public final class PostgreSQLCommandPacketFactoryTest {
         when(payload.readInt4()).thenReturn(1);
         when(payload.readStringNul()).thenReturn("stat-id");
         when(payload.readStringNul()).thenReturn("SELECT * FROM t_order");
-        when(payload.readInt2()).thenReturn(0);
-        PostgreSQLBinaryStatementRegistry.getInstance().register(1);
         
assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.BIND_COMMAND,
 payload, 1), instanceOf(PostgreSQLComBindPacket.class));
     }
     
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/ConnectionScopeBinaryStatementRegistryTest.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/ConnectionScopeBinaryStatementRegistryTest.java
deleted file mode 100644
index 3212c19..0000000
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/ConnectionScopeBinaryStatementRegistryTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-public final class ConnectionScopeBinaryStatementRegistryTest {
-    
-    @Test
-    public void assertRegister() {
-        ConnectionScopeBinaryStatementRegistry statementRegistry = new 
ConnectionScopeBinaryStatementRegistry();
-        String statementId = "stat-id";
-        String sql = "select * from t_order";
-        statementRegistry.register(statementId, sql, 1, null);
-        PostgreSQLBinaryStatement binaryStatement = 
statementRegistry.getBinaryStatement(statementId);
-        assertThat(binaryStatement.getSql(), is(sql));
-        assertThat(binaryStatement.getParameterCount(), is(1));
-    }
-    
-    @Test
-    public void assertGetBinaryStatementNotExists() {
-        ConnectionScopeBinaryStatementRegistry statementRegistry = new 
ConnectionScopeBinaryStatementRegistry();
-        PostgreSQLBinaryStatement binaryStatement = 
statementRegistry.getBinaryStatement("stat-no-exists");
-        assertNull(binaryStatement);
-    }
-    
-    @Test
-    public void assertGetAndCloseBinaryStatement() {
-        ConnectionScopeBinaryStatementRegistry statementRegistry = new 
ConnectionScopeBinaryStatementRegistry();
-        String statementId = "stat-id";
-        statementRegistry.register(statementId, "", 1, null);
-        PostgreSQLBinaryStatement actual = 
statementRegistry.getBinaryStatement(statementId);
-        assertNotNull(actual);
-        PostgreSQLBinaryStatement actualClosed = 
statementRegistry.closeStatement(statementId);
-        assertThat(actualClosed, is(actual));
-        assertNull(statementRegistry.getBinaryStatement(statementId));
-    }
-}
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementRegistryTest.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementRegistryTest.java
deleted file mode 100644
index 72d6785..0000000
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementRegistryTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-public final class PostgreSQLBinaryStatementRegistryTest {
-    
-    private final String sql = "SELECT * FROM tbl WHERE id=?";
-    
-    private final String statementId = "stat-id";
-    
-    @Before
-    public void init() {
-        PostgreSQLBinaryStatementRegistry.getInstance().register(1);
-        ConnectionScopeBinaryStatementRegistry statementRegistry = 
PostgreSQLBinaryStatementRegistry.getInstance().get(1);
-        statementRegistry.register(statementId, sql, 1, null);
-    }
-    
-    @Test
-    public void assertRegisterIfAbsent() {
-        PostgreSQLBinaryStatementRegistry.getInstance().register(2);
-        ConnectionScopeBinaryStatementRegistry actual = 
PostgreSQLBinaryStatementRegistry.getInstance().get(2);
-        assertNull(actual.getBinaryStatement("stat-no-exist"));
-    }
-    
-    @Test
-    public void assertRegisterIfPresent() {
-        ConnectionScopeBinaryStatementRegistry statementRegistry = 
PostgreSQLBinaryStatementRegistry.getInstance().get(1);
-        PostgreSQLBinaryStatement statement = 
statementRegistry.getBinaryStatement(statementId);
-        assertThat(statement.getSql(), is(sql));
-        assertThat(statement.getParameterCount(), is(1));
-        PostgreSQLBinaryStatementRegistry.getInstance().register(1);
-        
assertNull(PostgreSQLBinaryStatementRegistry.getInstance().get(1).getBinaryStatement(statementId));
-    }
-    
-    @Test
-    public void assertUnregister() {
-        PostgreSQLBinaryStatementRegistry.getInstance().unregister(1);
-        ConnectionScopeBinaryStatementRegistry actual = 
PostgreSQLBinaryStatementRegistry.getInstance().get(1);
-        assertNull(actual);
-    }
-}
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacketTest.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacketTest.java
index 92f35f7..91b32e3 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacketTest.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLComBindPacketTest.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bi
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
 import org.junit.Before;
 import org.junit.Test;
@@ -31,7 +30,6 @@ import org.mockito.junit.MockitoJUnitRunner;
 import java.util.Collections;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.when;
 
@@ -47,19 +45,15 @@ public final class PostgreSQLComBindPacketTest {
         when(payload.readStringNul()).thenReturn("");
         when(payload.readStringNul()).thenReturn("sts-id");
         when(payload.readInt2()).thenReturn(1);
-        PostgreSQLBinaryStatementRegistry.getInstance().register(1);
     }
     
     @Test
     public void assertWrite() {
         when(payload.readInt2()).thenReturn(1);
         when(payload.readInt4()).thenReturn(1);
-        String sql = "select * from order where id = ? ";
-        PostgreSQLBinaryStatementRegistry.getInstance().get(1).register(
-                "sts-id", sql, 1, 
Collections.singletonList(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8));
-        PostgreSQLComBindPacket bindPacket = new 
PostgreSQLComBindPacket(payload, 1);
+        PostgreSQLComBindPacket bindPacket = new 
PostgreSQLComBindPacket(payload);
         bindPacket.write(payload);
-        assertThat(bindPacket.getSql(), is(sql));
+        
bindPacket.init(Collections.singletonList(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8));
         assertThat(bindPacket.getParameters().size(), is(1));
         assertThat(bindPacket.getResultFormats().size(), is(1));
         assertThat(bindPacket.getResultFormats().get(0), 
is(PostgreSQLValueFormat.BINARY));
@@ -67,15 +61,14 @@ public final class PostgreSQLComBindPacketTest {
     
     @Test
     public void assertWriteWithEmptySql() {
-        PostgreSQLComBindPacket bindPacket = new 
PostgreSQLComBindPacket(payload, 1);
+        PostgreSQLComBindPacket bindPacket = new 
PostgreSQLComBindPacket(payload);
         bindPacket.write(payload);
-        assertNull(bindPacket.getSql());
         assertThat(bindPacket.getParameters().size(), is(0));
     }
     
     @Test
     public void getMessageType() {
-        PostgreSQLComBindPacket bindPacket = new 
PostgreSQLComBindPacket(payload, 1);
+        PostgreSQLComBindPacket bindPacket = new 
PostgreSQLComBindPacket(payload);
         assertThat(bindPacket.getIdentifier(), 
is(PostgreSQLCommandPacketType.BIND_COMMAND));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
index 0e15258..447497f 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java
@@ -21,7 +21,6 @@ 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;
@@ -47,7 +46,6 @@ public final class PostgreSQLFrontendEngine implements 
DatabaseProtocolFrontendE
     
     @Override
     public void release(final BackendConnection backendConnection) {
-        
PostgreSQLBinaryStatementRegistry.getInstance().unregister(backendConnection.getConnectionId());
         
PostgreSQLConnectionContextRegistry.getInstance().remove(backendConnection.getConnectionId());
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
index e931d09..4be2c1f 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
@@ -22,7 +22,6 @@ import io.netty.channel.ChannelHandlerContext;
 import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLErrorCode;
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLServerInfo;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationMD5PasswordPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationOKPacket;
@@ -58,9 +57,7 @@ public final class PostgreSQLAuthenticationEngine implements 
AuthenticationEngin
     
     @Override
     public int handshake(final ChannelHandlerContext context) {
-        int result = ConnectionIdGenerator.getInstance().nextId();
-        PostgreSQLBinaryStatementRegistry.getInstance().register(result);
-        return result;
+        return ConnectionIdGenerator.getInstance().nextId();
     }
     
     @Override
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatement.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLBinaryStatement.java
similarity index 86%
rename from 
shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatement.java
rename to 
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLBinaryStatement.java
index 754ac96..637bc3f 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatement.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLBinaryStatement.java
@@ -15,11 +15,12 @@
  * limitations under the License.
  */
 
-package 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary;
+package org.apache.shardingsphere.proxy.frontend.postgresql.command;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
 import java.util.List;
 
@@ -32,7 +33,7 @@ public final class PostgreSQLBinaryStatement {
     
     private final String sql;
     
-    private final int parameterCount;
+    private final SQLStatement sqlStatement;
     
     private final List<PostgreSQLBinaryColumnType> columnTypes;
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
index 54920d5..f92b54e 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLConnectionContext.java
@@ -20,23 +20,22 @@ package 
org.apache.shardingsphere.proxy.frontend.postgresql.command;
 import lombok.Getter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.PostgreSQLPortal;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.describe.PostgreSQLComDescribeExecutor;
-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.Collection;
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  * PostgreSQL connection context.
@@ -44,6 +43,9 @@ import java.util.Optional;
 @Setter
 public final class PostgreSQLConnectionContext {
     
+    @Getter
+    private final ConcurrentMap<String, PostgreSQLBinaryStatement> 
binaryStatements = new ConcurrentHashMap<>(65535, 1);
+    
     private final Map<String, PostgreSQLPortal> portals = new 
LinkedHashMap<>();
     
     @Getter
@@ -56,30 +58,20 @@ public final class PostgreSQLConnectionContext {
      * Create a portal.
      *
      * @param portal portal name
-     * @param sql sql
+     * @param binaryStatement binary statement
      * @param parameters bind parameters
      * @param resultFormats result formats
      * @param backendConnection backend connection
      * @return a new portal
      * @throws SQLException SQL exception
      */
-    public PostgreSQLPortal createPortal(final String portal, final String 
sql, final List<Object> parameters, final List<PostgreSQLValueFormat> 
resultFormats,
+    public PostgreSQLPortal createPortal(final String portal, final 
PostgreSQLBinaryStatement binaryStatement, final List<Object> parameters, final 
List<PostgreSQLValueFormat> resultFormats,
                                          final BackendConnection 
backendConnection) throws SQLException {
-        SQLStatement sqlStatement = parseSql(sql, 
backendConnection.getSchemaName());
-        PostgreSQLPortal result = new PostgreSQLPortal(sqlStatement, sql, 
parameters, resultFormats, backendConnection);
+        PostgreSQLPortal result = new PostgreSQLPortal(binaryStatement, 
parameters, resultFormats, backendConnection);
         portals.put(portal, 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);
-    }
-    
     /**
      * Get portal.
      *
@@ -139,4 +131,14 @@ public final class PostgreSQLConnectionContext {
         pendingExecutors.clear();
         updateCount = 0;
     }
+    
+    /**
+     * Get postgreSQL binary statement.
+     * 
+     * @param statementId statement Id
+     * @return postgreSQL binary statement
+     */
+    public PostgreSQLBinaryStatement getPostgreSQLBinaryStatement(final String 
statementId) {
+        return binaryStatements.getOrDefault(statementId, new 
PostgreSQLBinaryStatement("", new EmptyStatement(), Collections.emptyList()));
+    }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/PostgreSQLPortal.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/PostgreSQLPortal.java
index dad0129..11e23ac 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/PostgreSQLPortal.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/PostgreSQLPortal.java
@@ -36,6 +36,7 @@ import 
org.apache.shardingsphere.proxy.backend.response.data.impl.BinaryQueryRes
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory;
+import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLBinaryStatement;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
@@ -61,19 +62,21 @@ public final class PostgreSQLPortal {
     
     private final BackendConnection backendConnection;
     
-    public PostgreSQLPortal(final SQLStatement sqlStatement, final String sql, 
final List<Object> parameters, final List<PostgreSQLValueFormat> resultFormats,
+    public PostgreSQLPortal(final PostgreSQLBinaryStatement binaryStatement, 
final List<Object> parameters, final List<PostgreSQLValueFormat> resultFormats,
                             final BackendConnection backendConnection) throws 
SQLException {
-        this.sqlStatement = sqlStatement;
+        this.sqlStatement = binaryStatement.getSqlStatement();
         this.resultFormats = resultFormats;
         this.backendConnection = backendConnection;
         if (sqlStatement instanceof TCLStatement || sqlStatement instanceof 
EmptyStatement) {
             databaseCommunicationEngine = null;
-            textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"),
 sql, backendConnection);
+            textProtocolBackendHandler = 
+                    
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"),
 binaryStatement.getSql(), backendConnection);
             return;
         }
         SQLStatementContext<?> sqlStatementContext = 
SQLStatementContextFactory.newInstance(
                 
ProxyContext.getInstance().getMetaDataContexts().getMetaDataMap(), parameters, 
sqlStatement, backendConnection.getDefaultSchemaName());
-        databaseCommunicationEngine = 
DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext,
 sql, parameters, backendConnection);
+        databaseCommunicationEngine = 
DatabaseCommunicationEngineFactory.getInstance().newBinaryProtocolInstance(sqlStatementContext,
 
+                binaryStatement.getSql(), parameters, backendConnection);
         textProtocolBackendHandler = null;
     }
     
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/PostgreSQLComBindExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
index 200e621..7d16d40 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
@@ -29,6 +29,7 @@ import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryRespon
 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.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLBinaryStatement;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.PostgreSQLPortal;
 
@@ -51,7 +52,9 @@ public final class PostgreSQLComBindExecutor implements 
CommandExecutor {
     
     @Override
     public Collection<DatabasePacket<?>> execute() throws SQLException {
-        PostgreSQLPortal portal = 
connectionContext.createPortal(packet.getPortal(), packet.getSql(), 
packet.getParameters(), packet.getResultFormats(), backendConnection);
+        PostgreSQLBinaryStatement binaryStatement = 
connectionContext.getPostgreSQLBinaryStatement(packet.getStatementId());
+        packet.init(binaryStatement.getColumnTypes());
+        PostgreSQLPortal portal = 
connectionContext.createPortal(packet.getPortal(), binaryStatement, 
packet.getParameters(), packet.getResultFormats(), backendConnection);
         List<DatabasePacket<?>> result = new LinkedList<>();
         result.add(new PostgreSQLBindCompletePacket());
         ResponseHeader responseHeader = portal.execute();
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutor.java
index e0b8532..e47f1ff 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutor.java
@@ -19,8 +19,6 @@ package 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.ConnectionScopeBinaryStatementRegistry;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.close.PostgreSQLCloseCompletePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.close.PostgreSQLComClosePacket;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -47,7 +45,7 @@ public final class PostgreSQLComCloseExecutor implements 
CommandExecutor {
     public Collection<DatabasePacket<?>> execute() throws SQLException {
         switch (packet.getType()) {
             case PREPARED_STATEMENT:
-                closePreparedStatement();
+                
connectionContext.getBinaryStatements().remove(packet.getName());
                 break;
             case PORTAL:
                 closePortal();
@@ -58,13 +56,6 @@ public final class PostgreSQLComCloseExecutor implements 
CommandExecutor {
         return Collections.singletonList(new PostgreSQLCloseCompletePacket());
     }
     
-    private void closePreparedStatement() {
-        ConnectionScopeBinaryStatementRegistry binaryStatementRegistry = 
PostgreSQLBinaryStatementRegistry.getInstance().get(backendConnection.getConnectionId());
-        if (null != binaryStatementRegistry) {
-            binaryStatementRegistry.closeStatement(packet.getName());
-        }
-    }
-    
     private void closePortal() throws SQLException {
         connectionContext.closePortal(packet.getName());
     }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java
index fdbb96d..9f95c55 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutor.java
@@ -18,8 +18,6 @@
 package 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.parse;
 
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.ConnectionScopeBinaryStatementRegistry;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLComParsePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLParseCompletePacket;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
@@ -27,6 +25,7 @@ import 
org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLBinaryStatement;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.EmptyStatement;
@@ -41,9 +40,8 @@ public final class PostgreSQLComParseExecutor implements 
CommandExecutor {
     
     public PostgreSQLComParseExecutor(final PostgreSQLConnectionContext 
connectionContext, final PostgreSQLComParsePacket packet, final 
BackendConnection backendConnection) {
         String schemaName = backendConnection.getSchemaName();
-        ConnectionScopeBinaryStatementRegistry binaryStatementRegistry = 
PostgreSQLBinaryStatementRegistry.getInstance().get(backendConnection.getConnectionId());
         SQLStatement sqlStatement = parseSql(packet.getSql(), schemaName);
-        binaryStatementRegistry.register(packet.getStatementId(), 
packet.getSql(), sqlStatement.getParameterCount(), 
packet.getBinaryStatementColumnTypes());
+        connectionContext.getBinaryStatements().put(packet.getStatementId(), 
new PostgreSQLBinaryStatement(packet.getSql(), sqlStatement, 
packet.getBinaryStatementColumnTypes()));
     }
     
     private SQLStatement parseSql(final String sql, final String schemaName) {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
index ef995bc..ccbbb4f 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngineTest.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.proxy.frontend.postgresql;
 
 import lombok.SneakyThrows;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import 
org.apache.shardingsphere.proxy.frontend.executor.ConnectionThreadExecutorGroup;
@@ -30,8 +29,6 @@ import java.lang.reflect.Field;
 import java.util.concurrent.ConcurrentMap;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -51,15 +48,11 @@ public final class PostgreSQLFrontendEngineTest {
         BackendConnection backendConnection = mock(BackendConnection.class, 
RETURNS_DEEP_STUBS);
         int connectionId = 1;
         when(backendConnection.getConnectionId()).thenReturn(connectionId);
-        PostgreSQLBinaryStatementRegistry registry = 
PostgreSQLBinaryStatementRegistry.getInstance();
-        registry.register(connectionId);
         PostgreSQLConnectionContextRegistry.getInstance().get(connectionId);
-        assertNotNull(registry.get(connectionId));
         PostgreSQLFrontendEngine frontendEngine = new 
PostgreSQLFrontendEngine();
         ConnectionThreadExecutorGroup.getInstance().register(connectionId);
         
ConnectionThreadExecutorGroup.getInstance().unregisterAndAwaitTermination(connectionId);
         frontendEngine.release(backendConnection);
-        assertNull(registry.get(connectionId));
         assertTrue(getConnectionContexts().isEmpty());
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
index bb46703..009b23c 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
@@ -26,7 +26,6 @@ import 
org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration
 import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import org.apache.shardingsphere.authority.rule.builder.AuthorityRuleBuilder;
 import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationMD5PasswordPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
 import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
@@ -52,7 +51,6 @@ import java.util.LinkedHashMap;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -63,12 +61,6 @@ public final class PostgreSQLAuthenticationEngineTest {
     
     private final String password = "sharding";
     
-    @Test
-    public void assertHandshake() {
-        int connectionId = new 
PostgreSQLAuthenticationEngine().handshake(mock(ChannelHandlerContext.class));
-        
assertNotNull(PostgreSQLBinaryStatementRegistry.getInstance().get(connectionId));
-    }
-    
     private ByteBuf createByteBuf(final int initialCapacity, final int 
maxCapacity) {
         return new UnpooledHeapByteBuf(UnpooledByteBufAllocator.DEFAULT, 
initialCapacity, maxCapacity);
     }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
index 4808c5f..1a984d5 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
@@ -21,7 +21,6 @@ import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 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.PostgreSQLBinaryStatementRegistry;
 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.execute.PostgreSQLComExecutePacket;
@@ -37,7 +36,6 @@ import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.parse.PostgreSQLComParseExecutor;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.sync.PostgreSQLComSyncExecutor;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.text.PostgreSQLComQueryExecutor;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -46,6 +44,7 @@ import org.mockito.junit.MockitoJUnitRunner;
 import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
@@ -60,10 +59,8 @@ public final class PostgreSQLCommandExecutorFactoryTest {
     @Mock
     private BackendConnection backendConnection;
     
-    @BeforeClass
-    public static void setup() {
-        PostgreSQLBinaryStatementRegistry.getInstance().register(0);
-    }
+    @Mock
+    private PostgreSQLConnectionContext connectionContext;
     
     @Test
     public void assertPendingCommandExecutors() throws SQLException {
@@ -81,6 +78,7 @@ public final class PostgreSQLCommandExecutorFactoryTest {
     @Test
     public void assertNewInstance() throws SQLException {
         when(backendConnection.getSchemaName()).thenReturn("schema");
+        when(connectionContext.getBinaryStatements()).thenReturn(new 
ConcurrentHashMap<>(1, 1));
         Collection<InputOutput> inputOutputs = Arrays.asList(
             new InputOutput(PostgreSQLCommandPacketType.SIMPLE_QUERY, 
PostgreSQLComQueryPacket.class, PostgreSQLComQueryExecutor.class),
             new InputOutput(PostgreSQLCommandPacketType.PARSE_COMMAND, 
PostgreSQLComParsePacket.class, PostgreSQLComParseExecutor.class),
@@ -94,7 +92,7 @@ public final class PostgreSQLCommandExecutorFactoryTest {
                 commandPacketClass = PostgreSQLCommandPacket.class;
             }
             PostgreSQLCommandPacket packet = preparePacket(commandPacketClass);
-            CommandExecutor actual = 
PostgreSQLCommandExecutorFactory.newInstance(inputOutput.getCommandPacketType(),
 packet, backendConnection, mock(PostgreSQLConnectionContext.class));
+            CommandExecutor actual = 
PostgreSQLCommandExecutorFactory.newInstance(inputOutput.getCommandPacketType(),
 packet, backendConnection, connectionContext);
             assertThat(actual, instanceOf(inputOutput.getResultClass()));
         }
     }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutorTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutorTest.java
index 740f1b7..ea2ac36 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutorTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutorTest.java
@@ -21,6 +21,7 @@ import 
org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.PostgreSQLBindCompletePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.PostgreSQLComBindPacket;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLBinaryStatement;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
 import 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.PostgreSQLPortal;
 import org.junit.Before;
@@ -41,6 +42,7 @@ import static org.junit.Assert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -51,6 +53,9 @@ public final class PostgreSQLComBindExecutorTest {
     private PostgreSQLConnectionContext connectionContext;
     
     @Mock
+    private PostgreSQLBinaryStatement binaryStatement;
+    
+    @Mock
     private PostgreSQLPortal portal;
     
     @Mock
@@ -61,11 +66,14 @@ public final class PostgreSQLComBindExecutorTest {
     
     @Before
     public void setup() throws SQLException {
+        when(bindPacket.getStatementId()).thenReturn("1");
         when(bindPacket.getPortal()).thenReturn("C_1");
-        when(bindPacket.getSql()).thenReturn("");
         when(bindPacket.getParameters()).thenReturn(Collections.emptyList());
         
when(bindPacket.getResultFormats()).thenReturn(Collections.emptyList());
-        when(connectionContext.createPortal(anyString(), anyString(), 
any(List.class), any(List.class), eq(backendConnection))).thenReturn(portal);
+        doNothing().when(bindPacket).init(any(List.class));
+        
when(binaryStatement.getColumnTypes()).thenReturn(Collections.emptyList());
+        
when(connectionContext.getPostgreSQLBinaryStatement(anyString())).thenReturn(binaryStatement);
+        when(connectionContext.createPortal(anyString(), 
any(PostgreSQLBinaryStatement.class), any(List.class), any(List.class), 
eq(backendConnection))).thenReturn(portal);
     }
     
     @Test
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutorTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutorTest.java
index 4e8453e..f6a202c 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutorTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/close/PostgreSQLComCloseExecutorTest.java
@@ -18,7 +18,6 @@
 package 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.close;
 
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.close.PostgreSQLCloseCompletePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.close.PostgreSQLComClosePacket;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
@@ -31,7 +30,7 @@ import org.mockito.junit.MockitoJUnitRunner;
 
 import java.sql.SQLException;
 import java.util.Collection;
-import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
@@ -42,8 +41,6 @@ import static org.mockito.Mockito.when;
 @RunWith(MockitoJUnitRunner.class)
 public final class PostgreSQLComCloseExecutorTest {
     
-    private static final int CONNECTION_ID = new Random().nextInt() & 
Integer.MAX_VALUE;
-    
     @Mock
     private PostgreSQLConnectionContext connectionContext;
     
@@ -55,8 +52,7 @@ public final class PostgreSQLComCloseExecutorTest {
     
     @Before
     public void setUp() {
-        when(backendConnection.getConnectionId()).thenReturn(CONNECTION_ID);
-        
PostgreSQLBinaryStatementRegistry.getInstance().register(CONNECTION_ID);
+        when(connectionContext.getBinaryStatements()).thenReturn(new 
ConcurrentHashMap<>(1, 1));
     }
     
     @Test
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
index ea1fc15..29498a9 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
@@ -17,7 +17,6 @@
 
 package 
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary.parse;
 
-import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLComParsePacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLParseCompletePacket;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
@@ -39,6 +38,7 @@ import java.lang.reflect.Field;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
@@ -62,13 +62,12 @@ public final class PostgreSQLComParseExecutorTest {
     public void assertNewInstance() throws NoSuchFieldException, 
IllegalAccessException {
         when(parsePacket.getSql()).thenReturn("SELECT 1");
         when(parsePacket.getStatementId()).thenReturn("2");
-        when(backendConnection.getConnectionId()).thenReturn(1);
         when(backendConnection.getSchemaName()).thenReturn("schema");
+        when(connectionContext.getBinaryStatements()).thenReturn(new 
ConcurrentHashMap<>(1, 1));
         Field metaDataContexts = 
ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
         metaDataContexts.setAccessible(true);
         metaDataContexts.set(ProxyContext.getInstance(), new 
StandardMetaDataContexts(getMetaDataMap(),
                 mock(ShardingSphereRuleMetaData.class), 
mock(ExecutorEngine.class), new ConfigurationProperties(new Properties()), 
mock(OptimizeContextFactory.class)));
-        PostgreSQLBinaryStatementRegistry.getInstance().register(1);
         PostgreSQLComParseExecutor actual = new 
PostgreSQLComParseExecutor(connectionContext, parsePacket, backendConnection);
         assertThat(actual.execute().iterator().next(), 
instanceOf(PostgreSQLParseCompletePacket.class));
     }
@@ -83,8 +82,7 @@ public final class PostgreSQLComParseExecutorTest {
     public void assertGetSqlWithNull() {
         when(parsePacket.getStatementId()).thenReturn("");
         when(parsePacket.getSql()).thenReturn("");
-        when(backendConnection.getConnectionId()).thenReturn(1);
-        PostgreSQLBinaryStatementRegistry.getInstance().register(1);
+        when(connectionContext.getBinaryStatements()).thenReturn(new 
ConcurrentHashMap<>(1, 1));
         PostgreSQLComParseExecutor actual = new 
PostgreSQLComParseExecutor(connectionContext, parsePacket, backendConnection);
         assertThat(actual.execute().iterator().next(), 
instanceOf(PostgreSQLParseCompletePacket.class));
     }

Reply via email to