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

[shardingsphere] branch master updated: Refactor PostgreSQLCommandPacketType (#10058)

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 043408d  Refactor PostgreSQLCommandPacketType (#10058)
043408d is described below

commit 043408d36d9608a543308b7c49c0c35474afe763
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Apr 12 23:39:54 2021 +0800

    Refactor PostgreSQLCommandPacketType (#10058)
---
 .../command/PostgreSQLCommandPacketFactory.java    | 12 ++--
 .../command/PostgreSQLCommandPacketType.java       | 68 ++++++++--------------
 .../query/binary/bind/PostgreSQLComBindPacket.java |  2 +-
 .../describe/PostgreSQLComDescribePacket.java      |  2 +-
 .../binary/execute/PostgreSQLComExecutePacket.java |  2 +-
 .../binary/parse/PostgreSQLComParsePacket.java     |  2 +-
 .../query/binary/sync/PostgreSQLComSyncPacket.java |  2 +-
 .../query/text/PostgreSQLComQueryPacket.java       |  2 +-
 .../PostgreSQLAuthenticationMD5PasswordPacket.java |  2 +-
 .../PostgreSQLAuthenticationOKPacket.java          |  2 +-
 .../codec/PostgreSQLPacketCodecEngineTest.java     |  4 +-
 .../PostgreSQLCommandPacketFactoryTest.java        | 12 ++--
 .../PostgreSQLCommandPacketTypeLoaderTest.java     |  4 +-
 .../command/PostgreSQLCommandPacketTypeTest.java   |  2 +-
 .../PostgreSQLUnsupportedCommandPacketTest.java    |  6 +-
 .../binary/bind/PostgreSQLComBindPacketTest.java   |  9 ++-
 ...tgreSQLAuthenticationMD5PasswordPacketTest.java |  2 +-
 .../PostgreSQLAuthenticationOKPacketTest.java      |  2 +-
 .../command/PostgreSQLCommandExecutorFactory.java  | 12 ++--
 .../PostgreSQLCommandExecutorFactoryTest.java      | 26 +++++----
 20 files changed, 79 insertions(+), 96 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 8c43c00..d8d9ced 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
@@ -45,17 +45,17 @@ public final class PostgreSQLCommandPacketFactory {
      */
     public static PostgreSQLCommandPacket newInstance(final PostgreSQLCommandPacketType commandPacketType, final PostgreSQLPacketPayload payload, final int connectionId) {
         switch (commandPacketType) {
-            case QUERY:
+            case SIMPLE_QUERY:
                 return new PostgreSQLComQueryPacket(payload);
-            case PARSE:
+            case PARSE_COMMAND:
                 return new PostgreSQLComParsePacket(payload);
-            case BIND:
+            case BIND_COMMAND:
                 return new PostgreSQLComBindPacket(payload, connectionId);
-            case DESCRIBE:
+            case DESCRIBE_COMMAND:
                 return new PostgreSQLComDescribePacket(payload);
-            case EXECUTE:
+            case EXECUTE_COMMAND:
                 return new PostgreSQLComExecutePacket(payload);
-            case SYNC:
+            case SYNC_COMMAND:
                 return new PostgreSQLComSyncPacket(payload);
             case TERMINATE:
                 return new PostgreSQLComTerminationPacket(payload);
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
index df94004..ea72555 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketType.java
@@ -23,68 +23,50 @@ import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
 
 /**
  * Command packet type for PostgreSQL.
+ * 
+ * @see <a href="https://www.postgresql.org/docs/13/protocol-message-formats.html">Message Formats</a>
  */
 @RequiredArgsConstructor
 @Getter
 public enum PostgreSQLCommandPacketType implements CommandPacketType {
     
-    AUTHENTICATION_OK('R'),
+    AUTHENTICATION_REQUEST('R'),
     
-    AUTHENTICATION_KERBEROS_V5('R'),
+    SIMPLE_QUERY('Q'),
     
-    AUTHENTICATION_CLEARTEXT_PASSWORD('R'),
+    PARSE_COMMAND('P'),
     
-    AUTHENTICATION_MD5_PASSWORD('R'),
+    BIND_COMMAND('B'),
     
-    AUTHENTICATION_SCM_CREDENTIAL('R'),
+    DESCRIBE_COMMAND('D'),
     
-    AUTHENTICATION_GSS('R'),
+    EXECUTE_COMMAND('E'),
     
-    AUTHENTICATION_SSPI('R'),
+    SYNC_COMMAND('S'),
     
-    AUTHENTICATION_GSS_CONTINUE('R'),
+    CLOSE_COMMAND('C'),
     
-    AUTHENTICATION_SASL('R'),
-    
-    AUTHENTICATION_SASL_CONTINUE('R'),
-    
-    AUTHENTICATION_SASL_FINAL('R'),
-    
-    QUERY('Q'),
-    
-    PARSE('P'),
-    
-    BIND('B'),
-    
-    DESCRIBE('D'),
-    
-    EXECUTE('E'),
-    
-    SYNC('S'),
+    FLUSH_COMMAND('H'),
     
     PARSE_COMPLETE('1'),
     
     BIND_COMPLETE('2'),
     
+    COMMAND_COMPLETE('C'),
+    
     ROW_DESCRIPTION('T'),
     
     DATA_ROW('D'),
     
-    COMMAND_COMPLETE('C'),
-    
     READY_FOR_QUERY('Z'),
     
-    CLOSE('C'),
-    
     CLOSE_COMPLETE('3'),
     
-    BACKEND_KEY_DATA('K'),
-    
     COPY_DATA('d'),
     
-    COPY_DONE('c'),
+    COPY_COMPLETE('c'),
     
-    COPY_FAIL('f'),
+    COPY_FAILURE('f'),
     
     COPY_IN_RESPONSE('G'),
     
@@ -96,22 +78,26 @@ public enum PostgreSQLCommandPacketType implements CommandPacketType {
     
     ERROR_RESPONSE('E'),
     
-    FLUSH('H'),
-    
     FUNCTION_CALL('F'),
     
     FUNCTION_CALL_RESPONSE('V'),
     
     GSS_RESPONSE('p'),
     
-    NEGOTIATE_PROTOCOL_VERSION('v'),
-    
-    NO_DATA('n'),
-    
     NOTICE_RESPONSE('N'),
     
     NOTIFICATION_RESPONSE('A'),
     
+    SASL_INITIAL_RESPONSE('p'),
+    
+    SASL_RESPONSE('p'),
+    
+    BACKEND_KEY_DATA('K'),
+    
+    NEGOTIATE_PROTOCOL_VERSION('v'),
+    
+    NO_DATA('n'),
+    
     PARAMETER_DESCRIPTION('t'),
     
     PARAMETER_STATUS('S'),
@@ -120,10 +106,6 @@ public enum PostgreSQLCommandPacketType implements CommandPacketType {
     
     PORTAL_SUSPENDED('s'),
     
-    SASL_INITIAL_RESPONSE('p'),
-    
-    SASL_RESPONSE('p'),
-    
     TERMINATE('X');
     
     private final char value;
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 8bac816..03f8afc 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
@@ -84,6 +84,6 @@ public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.BIND.getValue();
+        return PostgreSQLCommandPacketType.BIND_COMMAND.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/describe/PostgreSQLComDescribePacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/describe/PostgreSQLComDescribePacket.java
index d4d7b70..caa2e8e 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/describe/PostgreSQLComDescribePacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/describe/PostgreSQLComDescribePacket.java
@@ -38,6 +38,6 @@ public final class PostgreSQLComDescribePacket extends PostgreSQLCommandPacket {
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.DESCRIBE.getValue();
+        return PostgreSQLCommandPacketType.DESCRIBE_COMMAND.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/execute/PostgreSQLComExecutePacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/execute/PostgreSQLComExecutePacket.java
index 69492f2..c721a5b 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/execute/PostgreSQLComExecutePacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/execute/PostgreSQLComExecutePacket.java
@@ -38,6 +38,6 @@ public final class PostgreSQLComExecutePacket extends PostgreSQLCommandPacket {
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.EXECUTE.getValue();
+        return PostgreSQLCommandPacketType.EXECUTE_COMMAND.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
index 2f0c5fe..4c55da6 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
@@ -66,6 +66,6 @@ public final class PostgreSQLComParsePacket extends PostgreSQLCommandPacket {
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.PARSE.getValue();
+        return PostgreSQLCommandPacketType.PARSE_COMMAND.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/sync/PostgreSQLComSyncPacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/sync/PostgreSQLComSyncPacket.java
index 1fb6333..71d9158 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/sync/PostgreSQLComSyncPacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/sync/PostgreSQLComSyncPacket.java
@@ -36,6 +36,6 @@ public final class PostgreSQLComSyncPacket extends PostgreSQLCommandPacket {
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.SYNC.getValue();
+        return PostgreSQLCommandPacketType.SYNC_COMMAND.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/text/PostgreSQLComQueryPacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/text/PostgreSQLComQueryPacket.java
index ef45f2f..0f899b4 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/text/PostgreSQLComQueryPacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/text/PostgreSQLComQueryPacket.java
@@ -41,6 +41,6 @@ public final class PostgreSQLComQueryPacket extends PostgreSQLCommandPacket {
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.QUERY.getValue();
+        return PostgreSQLCommandPacketType.SIMPLE_QUERY.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationMD5PasswordPacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationMD5PasswordPacket.java
index 530be88..5e18c0c 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationMD5PasswordPacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationMD5PasswordPacket.java
@@ -40,6 +40,6 @@ public final class PostgreSQLAuthenticationMD5PasswordPacket implements PostgreS
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.AUTHENTICATION_MD5_PASSWORD.getValue();
+        return PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationOKPacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationOKPacket.java
index 2029372..8a0c957 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationOKPacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/handshake/PostgreSQLAuthenticationOKPacket.java
@@ -37,6 +37,6 @@ public final class PostgreSQLAuthenticationOKPacket implements PostgreSQLPacket
     
     @Override
     public char getMessageType() {
-        return PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue();
+        return PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue();
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngineTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngineTest.java
index 43ca37b..5dc7b97 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngineTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngineTest.java
@@ -84,10 +84,10 @@ public final class PostgreSQLPacketCodecEngineTest {
         when(byteBufAllocator.buffer()).thenReturn(payloadByteBuf);
         when(payloadByteBuf.readableBytes()).thenReturn(50);
         PostgreSQLPacket actualMessage = mock(PostgreSQLPacket.class);
-        when(actualMessage.getMessageType()).thenReturn(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue());
+        when(actualMessage.getMessageType()).thenReturn(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue());
         new PostgreSQLPacketCodecEngine().encode(context, actualMessage, byteBuf);
         verify(actualMessage).write(ArgumentMatchers.any());
-        verify(byteBuf).writeByte(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue());
+        verify(byteBuf).writeByte(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue());
         verify(byteBuf).writeInt(50 + PostgreSQLPacket.PAYLOAD_LENGTH);
         verify(byteBuf).writeBytes(payloadByteBuf);
     }
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 2bfcfc5..b2bfa77 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
@@ -44,7 +44,7 @@ public final class PostgreSQLCommandPacketFactoryTest {
     
     @Test
     public void assertNewInstanceWithQueryComPacket() {
-        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.QUERY, payload, 1), instanceOf(PostgreSQLComQueryPacket.class));
+        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SIMPLE_QUERY, payload, 1), instanceOf(PostgreSQLComQueryPacket.class));
     }
     
     @Test
@@ -53,7 +53,7 @@ public final class PostgreSQLCommandPacketFactoryTest {
         when(payload.readStringNul()).thenReturn("stat-id");
         when(payload.readStringNul()).thenReturn("SELECT * FROM t_order");
         when(payload.readInt2()).thenReturn(0);
-        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.PARSE, payload, 1), instanceOf(PostgreSQLComParsePacket.class));
+        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.PARSE_COMMAND, payload, 1), instanceOf(PostgreSQLComParsePacket.class));
     }
     
     @Test
@@ -63,22 +63,22 @@ public final class PostgreSQLCommandPacketFactoryTest {
         when(payload.readStringNul()).thenReturn("SELECT * FROM t_order");
         when(payload.readInt2()).thenReturn(0);
         BinaryStatementRegistry.getInstance().register(1);
-        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.BIND, payload, 1), instanceOf(PostgreSQLComBindPacket.class));
+        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.BIND_COMMAND, payload, 1), instanceOf(PostgreSQLComBindPacket.class));
     }
     
     @Test
     public void assertNewInstanceWithDescribeComPacket() {
-        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.DESCRIBE, payload, 1), instanceOf(PostgreSQLComDescribePacket.class));
+        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.DESCRIBE_COMMAND, payload, 1), instanceOf(PostgreSQLComDescribePacket.class));
     }
     
     @Test
     public void assertNewInstanceWithExecuteComPacket() {
-        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.EXECUTE, payload, 1), instanceOf(PostgreSQLComExecutePacket.class));
+        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.EXECUTE_COMMAND, payload, 1), instanceOf(PostgreSQLComExecutePacket.class));
     }
     
     @Test
     public void assertNewInstanceWithSyncComPacket() {
-        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SYNC, payload, 1), instanceOf(PostgreSQLComSyncPacket.class));
+        assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SYNC_COMMAND, payload, 1), instanceOf(PostgreSQLComSyncPacket.class));
     }
     
     @Test
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeLoaderTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeLoaderTest.java
index 1caf6c2..f335ceb 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeLoaderTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeLoaderTest.java
@@ -30,8 +30,8 @@ public final class PostgreSQLCommandPacketTypeLoaderTest {
     @Test
     public void assertGetCommandPacketType() {
         PostgreSQLPacketPayload payload = mock(PostgreSQLPacketPayload.class);
-        when(payload.readInt1()).thenReturn((int) PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue());
-        assertThat(PostgreSQLCommandPacketTypeLoader.getCommandPacketType(payload), is(PostgreSQLCommandPacketType.AUTHENTICATION_OK));
+        when(payload.readInt1()).thenReturn((int) PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue());
+        assertThat(PostgreSQLCommandPacketTypeLoader.getCommandPacketType(payload), is(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST));
     }
     
     @Test(expected = IllegalArgumentException.class)
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeTest.java
index 75a096e..37067e6 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/PostgreSQLCommandPacketTypeTest.java
@@ -26,7 +26,7 @@ public final class PostgreSQLCommandPacketTypeTest {
     
     @Test
     public void assertValueOf() {
-        assertThat(PostgreSQLCommandPacketType.valueOf(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue()), is(PostgreSQLCommandPacketType.AUTHENTICATION_OK));
+        assertThat(PostgreSQLCommandPacketType.valueOf(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue()), is(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST));
     }
     
     @Test(expected = IllegalArgumentException.class)
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacketTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacketTest.java
index 05ba90e..6f97548 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacketTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/admin/PostgreSQLUnsupportedCommandPacketTest.java
@@ -36,14 +36,14 @@ public final class PostgreSQLUnsupportedCommandPacketTest {
     
     @Test
     public void assertWrite() {
-        PostgreSQLUnsupportedCommandPacket rowPacket = new PostgreSQLUnsupportedCommandPacket(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue());
+        PostgreSQLUnsupportedCommandPacket rowPacket = new PostgreSQLUnsupportedCommandPacket(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue());
         rowPacket.write(new PostgreSQLPacketPayload(byteBuf));
         assertThat(byteBuf.writerIndex(), is(0));
     }
     
     @Test
     public void assertGetMessageType() {
-        PostgreSQLUnsupportedCommandPacket rowPacket = new PostgreSQLUnsupportedCommandPacket(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue());
-        assertThat(rowPacket.getMessageType(), is(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue()));
+        PostgreSQLUnsupportedCommandPacket rowPacket = new PostgreSQLUnsupportedCommandPacket(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue());
+        assertThat(rowPacket.getMessageType(), is(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue()));
     }
 }
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 54d7759..dbe0288 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
@@ -28,7 +28,6 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
-import java.sql.SQLException;
 import java.util.Collections;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -52,7 +51,7 @@ public final class PostgreSQLComBindPacketTest {
     }
     
     @Test
-    public void assertWrite() throws SQLException {
+    public void assertWrite() {
         when(payload.readInt2()).thenReturn(1);
         when(payload.readInt4()).thenReturn(1);
         when(payload.readInt8()).thenReturn(11L);
@@ -66,7 +65,7 @@ public final class PostgreSQLComBindPacketTest {
     }
     
     @Test
-    public void assertWriteWithEmptySql() throws SQLException {
+    public void assertWriteWithEmptySql() {
         PostgreSQLComBindPacket bindPacket = new PostgreSQLComBindPacket(payload, 1);
         bindPacket.write(payload);
         assertNull(bindPacket.getSql());
@@ -75,8 +74,8 @@ public final class PostgreSQLComBindPacketTest {
     }
     
     @Test
-    public void getMessageType() throws SQLException {
+    public void getMessageType() {
         PostgreSQLComBindPacket bindPacket = new PostgreSQLComBindPacket(payload, 1);
-        assertThat(bindPacket.getMessageType(), is(PostgreSQLCommandPacketType.BIND.getValue()));
+        assertThat(bindPacket.getMessageType(), is(PostgreSQLCommandPacketType.BIND_COMMAND.getValue()));
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationMD5PasswordPacketTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationMD5PasswordPacketTest.java
index 24541cd..37a31c0 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationMD5PasswordPacketTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationMD5PasswordPacketTest.java
@@ -36,7 +36,7 @@ public final class PostgreSQLAuthenticationMD5PasswordPacketTest {
         ByteBuf byteBuf = ByteBufTestUtils.createByteBuf(expectedLength);
         PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
         PostgreSQLAuthenticationMD5PasswordPacket packet = new PostgreSQLAuthenticationMD5PasswordPacket(md5Salt);
-        assertThat(packet.getMessageType(), is(PostgreSQLCommandPacketType.AUTHENTICATION_MD5_PASSWORD.getValue()));
+        assertThat(packet.getMessageType(), is(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue()));
         packet.write(payload);
         assertThat(byteBuf.writerIndex(), is(expectedLength));
         assertThat(byteBuf.readInt(), is(5));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationOKPacketTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationOKPacketTest.java
index 19c1cd2..648d6a5 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationOKPacketTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLAuthenticationOKPacketTest.java
@@ -43,7 +43,7 @@ public final class PostgreSQLAuthenticationOKPacketTest {
         ByteBuf byteBuf = ByteBufTestUtils.createByteBuf(4);
         PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
         PostgreSQLAuthenticationOKPacket packet = new PostgreSQLAuthenticationOKPacket(isSuccess);
-        assertThat(packet.getMessageType(), is(PostgreSQLCommandPacketType.AUTHENTICATION_OK.getValue()));
+        assertThat(packet.getMessageType(), is(PostgreSQLCommandPacketType.AUTHENTICATION_REQUEST.getValue()));
         packet.write(payload);
         assertThat(byteBuf.writerIndex(), is(4));
         assertThat(byteBuf.readInt(), is(isSuccess ? 0 : 1));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
index 6cb4e52..59eb8e6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactory.java
@@ -58,17 +58,17 @@ public final class PostgreSQLCommandExecutorFactory {
                                               final PostgreSQLCommandPacket commandPacket, final BackendConnection backendConnection) throws SQLException {
         log.debug("Execute packet type: {}, value: {}", commandPacketType, commandPacket);
         switch (commandPacketType) {
-            case QUERY:
+            case SIMPLE_QUERY:
                 return new PostgreSQLComQueryExecutor((PostgreSQLComQueryPacket) commandPacket, backendConnection);
-            case PARSE:
+            case PARSE_COMMAND:
                 return new PostgreSQLComParseExecutor((PostgreSQLComParsePacket) commandPacket, backendConnection);
-            case BIND:
+            case BIND_COMMAND:
                 return new PostgreSQLComBindExecutor((PostgreSQLComBindPacket) commandPacket, backendConnection);
-            case DESCRIBE:
+            case DESCRIBE_COMMAND:
                 return new PostgreSQLComDescribeExecutor();
-            case EXECUTE:
+            case EXECUTE_COMMAND:
                 return new PostgreSQLComExecuteExecutor();
-            case SYNC:
+            case SYNC_COMMAND:
                 return new PostgreSQLComSyncExecutor();
             case TERMINATE:
                 return new PostgreSQLComTerminationExecutor();
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 1909c14..d80d3a5 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
@@ -17,7 +17,8 @@
 
 package org.apache.shardingsphere.proxy.frontend.postgresql.command;
 
-import lombok.AllArgsConstructor;
+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.bind.PostgreSQLComBindPacket;
@@ -51,26 +52,27 @@ public final class PostgreSQLCommandExecutorFactoryTest {
         BackendConnection backendConnection = mock(BackendConnection.class);
         when(backendConnection.getSchemaName()).thenReturn("schema");
         Collection<InputOutput> inputOutputs = Arrays.asList(
-            new InputOutput(PostgreSQLCommandPacketType.QUERY, PostgreSQLComQueryPacket.class, PostgreSQLComQueryExecutor.class),
-            new InputOutput(PostgreSQLCommandPacketType.PARSE, PostgreSQLComParsePacket.class, PostgreSQLComParseExecutor.class),
-            new InputOutput(PostgreSQLCommandPacketType.BIND, PostgreSQLComBindPacket.class, PostgreSQLComBindExecutor.class),
-            new InputOutput(PostgreSQLCommandPacketType.DESCRIBE, null, PostgreSQLComDescribeExecutor.class),
-            new InputOutput(PostgreSQLCommandPacketType.EXECUTE, null, PostgreSQLComExecuteExecutor.class),
-            new InputOutput(PostgreSQLCommandPacketType.SYNC, null, PostgreSQLComSyncExecutor.class),
+            new InputOutput(PostgreSQLCommandPacketType.SIMPLE_QUERY, PostgreSQLComQueryPacket.class, PostgreSQLComQueryExecutor.class),
+            new InputOutput(PostgreSQLCommandPacketType.PARSE_COMMAND, PostgreSQLComParsePacket.class, PostgreSQLComParseExecutor.class),
+            new InputOutput(PostgreSQLCommandPacketType.BIND_COMMAND, PostgreSQLComBindPacket.class, PostgreSQLComBindExecutor.class),
+            new InputOutput(PostgreSQLCommandPacketType.DESCRIBE_COMMAND, null, PostgreSQLComDescribeExecutor.class),
+            new InputOutput(PostgreSQLCommandPacketType.EXECUTE_COMMAND, null, PostgreSQLComExecuteExecutor.class),
+            new InputOutput(PostgreSQLCommandPacketType.SYNC_COMMAND, null, PostgreSQLComSyncExecutor.class),
             new InputOutput(PostgreSQLCommandPacketType.TERMINATE, null, PostgreSQLComTerminationExecutor.class),
-            new InputOutput(PostgreSQLCommandPacketType.CLOSE, null, PostgreSQLUnsupportedCommandExecutor.class)
+            new InputOutput(PostgreSQLCommandPacketType.CLOSE_COMMAND, null, PostgreSQLUnsupportedCommandExecutor.class)
         );
         for (InputOutput inputOutput : inputOutputs) {
-            Class<? extends PostgreSQLCommandPacket> commandPacketClass = inputOutput.commandPacketClass;
+            Class<? extends PostgreSQLCommandPacket> commandPacketClass = inputOutput.getCommandPacketClass();
             if (null == commandPacketClass) {
                 commandPacketClass = PostgreSQLCommandPacket.class;
             }
-            CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(inputOutput.commandPacketType, mock(commandPacketClass), mock(BackendConnection.class));
-            assertThat(actual, instanceOf(inputOutput.resultClass));
+            CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(inputOutput.getCommandPacketType(), mock(commandPacketClass), mock(BackendConnection.class));
+            assertThat(actual, instanceOf(inputOutput.getResultClass()));
         }
     }
     
-    @AllArgsConstructor
+    @RequiredArgsConstructor
+    @Getter
     private static final class InputOutput {
         
         private final PostgreSQLCommandPacketType commandPacketType;