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

zhangyonglun 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 78dd99a  Fixes #9127 (#9183)
78dd99a is described below

commit 78dd99a935b4a513f5907d963c91ec326f07f4a9
Author: Jieker <[email protected]>
AuthorDate: Wed Jan 27 21:35:03 2021 +0800

    Fixes #9127 (#9183)
---
 .../query/binary/execute/MySQLBinaryResultSetRowPacket.java       | 5 +++--
 .../binary/execute/protocol/MySQLInt4BinaryProtocolValue.java     | 4 +++-
 .../binary/execute/protocol/MySQLInt8BinaryProtocolValue.java     | 8 +++++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacket.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacket.java
index 89ef9ce..f6871c3 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacket.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacket.java
@@ -69,8 +69,9 @@ public final class MySQLBinaryResultSetRowPacket implements 
MySQLPacket {
     
     private void writeValues(final MySQLPacketPayload payload) {
         for (BinaryCell each : row.getCells()) {
-            if (null != each.getData()) {
-                
MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(each.getColumnType()).write(payload,
 each.getData());
+            Object data = each.getData();
+            if (null != data) {
+                
MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(each.getColumnType()).write(payload,
 data);
             }
         }
     }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt4BinaryProtocolValue.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt4BinaryProtocolValue.java
index aaffc33..d7d6dc4 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt4BinaryProtocolValue.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt4BinaryProtocolValue.java
@@ -19,6 +19,8 @@ package 
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.
 
 import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
 
+import java.math.BigDecimal;
+
 /**
  * Binary protocol value for int4 for MySQL.
  */
@@ -31,6 +33,6 @@ public final class MySQLInt4BinaryProtocolValue implements 
MySQLBinaryProtocolVa
     
     @Override
     public void write(final MySQLPacketPayload payload, final Object value) {
-        payload.writeInt4((Integer) value);
+        payload.writeInt4(value instanceof BigDecimal ? ((BigDecimal) 
value).intValue() : (Integer) value);
     }
 }
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt8BinaryProtocolValue.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt8BinaryProtocolValue.java
index c705fd0..9061c27 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt8BinaryProtocolValue.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLInt8BinaryProtocolValue.java
@@ -33,6 +33,12 @@ public final class MySQLInt8BinaryProtocolValue implements 
MySQLBinaryProtocolVa
     
     @Override
     public void write(final MySQLPacketPayload payload, final Object value) {
-        payload.writeInt8(value instanceof BigDecimal ? ((BigDecimal) 
value).longValue() : (Long) value);
+        if (value instanceof BigDecimal) {
+            payload.writeInt8(((BigDecimal) value).longValue());
+        } else if (value instanceof Integer) {
+            payload.writeInt8(((Integer) value).longValue());
+        } else {
+            payload.writeInt8((Long) value);
+        }
     }
 }

Reply via email to