azexcy commented on code in PR #24598:
URL: https://github.com/apache/shardingsphere/pull/24598#discussion_r1136460986


##########
db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLFractionalSeconds.java:
##########
@@ -26,41 +27,29 @@
  */
 public final class MySQLFractionalSeconds {
     
-    private final int fraction;
+    @Getter
+    private final int nanos;
     
     private final int fractionalSecondsPrecision;
     
     public MySQLFractionalSeconds(final int columnMeta, final 
MySQLPacketPayload payload) {
         fractionalSecondsPrecision = columnMeta;
-        fraction = readFraction(payload);
+        nanos = readFraction(payload);
     }
     
     private int readFraction(final MySQLPacketPayload payload) {
         switch (fractionalSecondsPrecision) {
             case 1:
             case 2:
-                return payload.readInt1() * 10000;
+                return payload.readInt1() * 10000 * 1000;
             case 3:
             case 4:
-                return payload.getByteBuf().readUnsignedShort() * 100;
+                return payload.getByteBuf().readUnsignedShort() * 100 * 1000;
             case 5:
             case 6:
-                return payload.getByteBuf().readUnsignedMedium();
+                return payload.getByteBuf().readUnsignedMedium() * 1000;
             default:
                 return 0;
         }
     }
-    
-    @Override
-    public String toString() {
-        if (0 == fractionalSecondsPrecision) {
-            return "";
-        }
-        StringBuilder result = new StringBuilder(Integer.toString(fraction));
-        for (int i = result.length(); i < fractionalSecondsPrecision; i++) {
-            result.append("0");
-        }
-        result.setLength(fractionalSecondsPrecision);
-        return "." + result;
-    }

Review Comment:
   There have problem when the fractional seconds just like `025000`
   
   1. `payload.getByteBuf().readUnsignedMedium();` return `25000`
   2. toString will append 0 at end, value = `250000`
   
   so the result is wrong



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