sandynz commented on a change in pull request #12814:
URL: https://github.com/apache/shardingsphere/pull/12814#discussion_r718430925



##########
File path: 
shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-opengauss/src/main/java/org/apache/shardingsphere/scaling/opengauss/wal/decode/MppdbDecodingPlugin.java
##########
@@ -158,28 +160,77 @@ private Object readColumnData(final String data, final 
String columnType) {
             case "boolean":
                 return Boolean.parseBoolean(data);
             case "time without time zone":
+            case "time with time zone":
                 try {
-                    return timestampUtils.toTime(null, data);
+                    return timestampUtils.toTime(null, decodeString(data));
                 } catch (final SQLException ex) {
                     throw new DecodingException(ex);
                 }
             case "date":
-                return Date.valueOf(data);
+                return Date.valueOf(decodeString(data));
             case "timestamp without time zone":
+            case "timestamp with time zone":
+            case "smalldatetime":
                 try {
-                    return timestampUtils.toTimestamp(null, data);
+                    return timestampUtils.toTimestamp(null, 
decodeString(data));
                 } catch (final SQLException ex) {
                     throw new DecodingException(ex);
                 }
             case "bytea":
-                return decodeHex(data.substring(2));
+                return decodeBytea(data);
+            case "raw":
+            case "reltime":
+                return decodePgObject(data, columnType);
+            case "money":
+                return decodeMoney(data);
+            case "interval":
+                return decodeInterval(data);
             case "character varying":
-                return decodeString(data);
+            case "text":
+            case "character":
+            case "nvarchar2":
             default:
-                return data;
+                return decodeString(data);
         }
     }
     
+    private static PGobject decodeInterval(final String data) {
+        try {
+            return new PGInterval(decodeString(data));
+        } catch (SQLException ex) {
+            return null;
+        }
+    }
+    
+    private static PGobject decodePgObject(final String data, final String 
type) {
+        try {
+            PGobject pgObject = new PGobject();
+            pgObject.setType(type);
+            pgObject.setValue(decodeString(data));
+            return pgObject;
+        } catch (SQLException ex) {
+            return null;
+        }
+    }
+    
+    private static PGobject decodeBytea(final String data) {
+        try {
+            PGobject pgObject = new PGobject();
+            pgObject.setType("bytea");
+            byte[] decodeByte = decodeHex(decodeString(data).substring(2));
+            pgObject.setValue(new String(decodeByte));
+            return pgObject;
+        } catch (SQLException ex) {

Review comment:
       Could be `final SQLException ignored`, and also other places.

##########
File path: 
shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-opengauss/src/test/java/org/apache/shardingsphere/scaling/opengauss/wal/decode/MppdbDecodingPluginTest.java
##########
@@ -50,14 +55,18 @@ public void assertDecodeWriteRowEvent() {
         MppTableData tableData = new MppTableData();
         tableData.setTableName("public.test");
         tableData.setOpType("INSERT");
-        tableData.setColumnsName(new String[]{"data"});
-        tableData.setColumnsType(new String[]{"character varyint"});
-        tableData.setColumnsVal(new String[]{"1 2 3"});
+        String[] insertTypes = new String[]{"character varying", "text", 
"char", "character", "nchar", "varchar2", "nvarchar2", "clob"};
+    

Review comment:
       Blank line could be removed, and also other places




-- 
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