RaigorJiang commented on code in PR #36372:
URL: https://github.com/apache/shardingsphere/pull/36372#discussion_r2553969984


##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringBinaryProtocolValue.java:
##########
@@ -26,25 +26,26 @@ public final class PostgreSQLStringBinaryProtocolValue 
implements PostgreSQLBina
     
     @Override
     public int getColumnLength(final PostgreSQLPacketPayload payload, final 
Object value) {
-        if (value instanceof byte[]) {
-            return ((byte[]) value).length;
-        }
-        return value.toString().getBytes(payload.getCharset()).length;
+        return -1;

Review Comment:
   Why is ColumnLength a fixed value of -1? This is incorrect.



##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/util/codec/decoder/ArrayDecoder.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.database.protocol.postgresql.packet.command.query.extended.bind.protocol.util.codec.decoder;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+/**
+ * postgresql array decoder.

Review Comment:
   Specialized terms and sentences should all be capitalized.



##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/util/codec/decoder/BooleanArrayDecoder.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.database.protocol.postgresql.packet.command.query.extended.bind.protocol.util.codec.decoder;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+/**
+ * BooleanArrayDecoder.

Review Comment:
   Words in the comments should be separated, not camelCase.



##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTimeStampBinaryProtocolValue.java:
##########
@@ -17,30 +17,34 @@
 
 package 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol;
 
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLBinaryTimestampUtils;
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.util.codec.decoder.PgBinaryObj;
 import 
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
-import 
org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
+
+import java.sql.Timestamp;
 
 /**
- * Binary protocol value for boolean array for PostgreSQL.
+ * Binary protocol value for time for PostgreSQL.
  */
-public final class PostgreSQLBoolArrayBinaryProtocolValue implements 
PostgreSQLBinaryProtocolValue {
-    
-    private static final PostgreSQLArrayParameterDecoder 
ARRAY_PARAMETER_DECODER = new PostgreSQLArrayParameterDecoder();
+public final class PostgreSQLTimeStampBinaryProtocolValue implements 
PostgreSQLBinaryProtocolValue {
     
     @Override
     public int getColumnLength(final PostgreSQLPacketPayload payload, final 
Object value) {
-        throw new 
UnsupportedSQLOperationException("PostgreSQLBoolArrayBinaryProtocolValue.getColumnLength()");
+        return 8;
     }
     
     @Override
     public Object read(final PostgreSQLPacketPayload payload, final int 
parameterValueLength) {
-        byte[] bytes = new byte[parameterValueLength];
+        // 获取pg 时间戳

Review Comment:
   Chinese comments are not accepted.



##########
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringBinaryProtocolValue.java:
##########
@@ -26,25 +26,26 @@ public final class PostgreSQLStringBinaryProtocolValue 
implements PostgreSQLBina
     
     @Override
     public int getColumnLength(final PostgreSQLPacketPayload payload, final 
Object value) {
-        if (value instanceof byte[]) {
-            return ((byte[]) value).length;
-        }
-        return value.toString().getBytes(payload.getCharset()).length;
+        return -1;
     }
     
     @Override
     public Object read(final PostgreSQLPacketPayload payload, final int 
parameterValueLength) {
         byte[] result = new byte[parameterValueLength];
         payload.getByteBuf().readBytes(result);
-        return new String(result);
+        return new String(result, payload.getCharset());
     }
     
     @Override
     public void write(final PostgreSQLPacketPayload payload, final Object 
value) {
         if (value instanceof byte[]) {
+            payload.writeInt4(((byte[]) value).length);
+            // we may convert charset?
             payload.writeBytes((byte[]) value);
         } else {
-            payload.writeStringEOF(value.toString());
+            byte[] bytes = value.toString().getBytes(payload.getCharset());
+            payload.writeInt4(bytes.length);

Review Comment:
   PostgreSQL DataRowPacket has a unified write length operation (based on 
getColumnLength()), so individual value implementations do not need to call 
writeInt4.
   
   This is clearly incorrect logic.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to