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/05/02 05:07:40 UTC
[shardingsphere] branch master updated: Add parameterValueLength
for PostgreSQLBinaryProtocolValue (#10238)
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 222776c Add parameterValueLength for PostgreSQLBinaryProtocolValue (#10238)
222776c is described below
commit 222776c6c2d5325f699a80b1fa1f2be65ebe43f4
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun May 2 13:06:46 2021 +0800
Add parameterValueLength for PostgreSQLBinaryProtocolValue (#10238)
* Add parameterValueLength for PostgreSQLBinaryProtocolValue
* Add parameterValueLength for PostgreSQLBinaryProtocolValue
---
.../query/binary/bind/PostgreSQLComBindPacket.java | 15 ++++++++-------
.../bind/protocol/PostgreSQLBinaryProtocolValue.java | 3 ++-
.../protocol/PostgreSQLBoolArrayBinaryProtocolValue.java | 5 ++---
.../bind/protocol/PostgreSQLDateBinaryProtocolValue.java | 2 +-
.../protocol/PostgreSQLDoubleBinaryProtocolValue.java | 2 +-
.../PostgreSQLFloat4ArrayBinaryProtocolValue.java | 5 ++---
.../PostgreSQLFloat8ArrayBinaryProtocolValue.java | 5 ++---
.../bind/protocol/PostgreSQLFloatBinaryProtocolValue.java | 2 +-
.../protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java | 5 ++---
.../bind/protocol/PostgreSQLInt2BinaryProtocolValue.java | 2 +-
.../protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java | 5 ++---
.../bind/protocol/PostgreSQLInt4BinaryProtocolValue.java | 2 +-
.../protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java | 5 ++---
.../bind/protocol/PostgreSQLInt8BinaryProtocolValue.java | 2 +-
.../protocol/PostgreSQLNumericBinaryProtocolValue.java | 5 ++---
.../PostgreSQLStringArrayBinaryProtocolValue.java | 5 ++---
.../protocol/PostgreSQLStringBinaryProtocolValue.java | 5 ++---
.../bind/protocol/PostgreSQLTimeBinaryProtocolValue.java | 2 +-
.../PostgreSQLUnspecifiedBinaryProtocolValue.java | 5 ++---
.../query/binary/bind/PostgreSQLComBindPacketTest.java | 1 -
.../PostgreSQLBoolArrayBinaryProtocolValueTest.java | 5 +++--
.../protocol/PostgreSQLDateBinaryProtocolValueTest.java | 2 +-
.../protocol/PostgreSQLDoubleBinaryProtocolValueTest.java | 2 +-
.../PostgreSQLFloat4ArrayBinaryProtocolValueTest.java | 5 +++--
.../PostgreSQLFloat8ArrayBinaryProtocolValueTest.java | 5 +++--
.../protocol/PostgreSQLFloatBinaryProtocolValueTest.java | 2 +-
.../PostgreSQLInt2ArrayBinaryProtocolValueTest.java | 5 +++--
.../protocol/PostgreSQLInt2BinaryProtocolValueTest.java | 5 ++---
.../PostgreSQLInt4ArrayBinaryProtocolValueTest.java | 5 +++--
.../protocol/PostgreSQLInt4BinaryProtocolValueTest.java | 5 ++---
.../PostgreSQLInt8ArrayBinaryProtocolValueTest.java | 5 +++--
.../protocol/PostgreSQLInt8BinaryProtocolValueTest.java | 5 ++---
.../PostgreSQLNumericBinaryProtocolValueTest.java | 7 ++++---
.../PostgreSQLStringArrayBinaryProtocolValueTest.java | 5 +++--
.../protocol/PostgreSQLStringBinaryProtocolValueTest.java | 10 +++-------
.../protocol/PostgreSQLTimeBinaryProtocolValueTest.java | 5 ++---
.../PostgreSQLUnspecifiedBinaryProtocolValueTest.java | 5 +++--
37 files changed, 79 insertions(+), 87 deletions(-)
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 4a7a498..9bd462a 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
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bi
import lombok.Getter;
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.PostgreSQLBinaryStatementRegistry;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatement;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementParameterType;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementRegistry;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol.PostgreSQLBinaryProtocolValue;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol.PostgreSQLBinaryProtocolValueFactory;
import org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
@@ -50,9 +50,10 @@ public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
payload.readInt4();
payload.readStringNul();
statementId = payload.readStringNul();
- int parameterFormatsLength = payload.readInt2();
- for (int i = 0; i < parameterFormatsLength; i++) {
- payload.readInt2();
+ int parameterFormatCount = payload.readInt2();
+ List<Integer> parameterFormats = new ArrayList<>(parameterFormatCount);
+ for (int i = 0; i < parameterFormatCount; i++) {
+ parameterFormats.add(payload.readInt2());
}
PostgreSQLBinaryStatement binaryStatement = PostgreSQLBinaryStatementRegistry.getInstance().get(connectionId).getBinaryStatement(statementId);
sql = null == binaryStatement ? null : binaryStatement.getSql();
@@ -68,13 +69,13 @@ public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
int parameterCount = payload.readInt2();
List<Object> result = new ArrayList<>(parameterCount);
for (int parameterIndex = 0; parameterIndex < parameterCount; parameterIndex++) {
- int paramValueLen = payload.readInt4();
- if (-1 == paramValueLen) {
+ int parameterValueLength = payload.readInt4();
+ if (-1 == parameterValueLength) {
result.add(null);
continue;
}
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(parameterTypes.get(parameterIndex).getColumnType());
- result.add(binaryProtocolValue.read(payload));
+ result.add(binaryProtocolValue.read(payload, parameterValueLength));
}
return result;
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValue.java
index 5ae69af..39ec3b2 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValue.java
@@ -36,9 +36,10 @@ public interface PostgreSQLBinaryProtocolValue {
* Read binary protocol value.
*
* @param payload payload operation for PostgreSQL packet
+ * @param parameterValueLength parameter value length
* @return binary value result
*/
- Object read(PostgreSQLPacketPayload payload);
+ Object read(PostgreSQLPacketPayload payload, int parameterValueLength);
/**
* Write binary protocol 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/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java
index ccf99bf..5c04c7c 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLBoolArrayBinaryProtocolValue implements PostgreSQLB
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeBoolArray(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValue.java
index 98679f9..2b15bc9 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValue.java
@@ -32,7 +32,7 @@ public final class PostgreSQLDateBinaryProtocolValue implements PostgreSQLBinary
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.readInt8();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValue.java
index e3e3842..49c7989 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValue.java
@@ -30,7 +30,7 @@ public final class PostgreSQLDoubleBinaryProtocolValue implements PostgreSQLBina
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.getByteBuf().readDouble();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java
index 98945b8..fdf1364 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLFloat4ArrayBinaryProtocolValue implements PostgreSQ
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeFloat4Array(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java
index 9d7d039..a5f333e 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLFloat8ArrayBinaryProtocolValue implements PostgreSQ
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeFloat8Array(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValue.java
index ecd00b4..76e90d3 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValue.java
@@ -30,7 +30,7 @@ public final class PostgreSQLFloatBinaryProtocolValue implements PostgreSQLBinar
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.getByteBuf().readFloat();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java
index abaa167..ff5e56d 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLInt2ArrayBinaryProtocolValue implements PostgreSQLB
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeInt2Array(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValue.java
index 0853a38..7cbc445 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValue.java
@@ -30,7 +30,7 @@ public final class PostgreSQLInt2BinaryProtocolValue implements PostgreSQLBinary
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.readInt2();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java
index 8d9525b..18088c6 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLInt4ArrayBinaryProtocolValue implements PostgreSQLB
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeInt4Array(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValue.java
index 4937162..378a69c 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValue.java
@@ -30,7 +30,7 @@ public final class PostgreSQLInt4BinaryProtocolValue implements PostgreSQLBinary
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.readInt4();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java
index b86f6c7..10a7c29 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLInt8ArrayBinaryProtocolValue implements PostgreSQLB
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeInt8Array(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValue.java
index e75d877..8f24ae0 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValue.java
@@ -32,7 +32,7 @@ public final class PostgreSQLInt8BinaryProtocolValue implements PostgreSQLBinary
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.readInt8();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValue.java
index 99a4e22..6165692 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValue.java
@@ -33,9 +33,8 @@ public final class PostgreSQLNumericBinaryProtocolValue implements PostgreSQLBin
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return new BigDecimal(new String(bytes));
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java
index c8ea77d..b1b5701 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java
@@ -32,9 +32,8 @@ public final class PostgreSQLStringArrayBinaryProtocolValue implements PostgreSQ
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
return ARRAY_PARAMETER_DECODER.decodeStringArray(bytes, '{' != bytes[0]);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValue.java
index 000ca45..930e2e1 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValue.java
@@ -30,9 +30,8 @@ public final class PostgreSQLStringBinaryProtocolValue implements PostgreSQLBina
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] result = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] result = new byte[parameterValueLength];
payload.getByteBuf().readBytes(result);
return new String(result);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValue.java
index e52d028..e27d805 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValue.java
@@ -32,7 +32,7 @@ public final class PostgreSQLTimeBinaryProtocolValue implements PostgreSQLBinary
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
return payload.readInt8();
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java
index 0469baa..71b76bb 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java
@@ -31,9 +31,8 @@ public final class PostgreSQLUnspecifiedBinaryProtocolValue implements PostgreSQ
}
@Override
- public Object read(final PostgreSQLPacketPayload payload) {
- payload.getByteBuf().readerIndex(payload.getByteBuf().readerIndex() - 4);
- byte[] bytes = new byte[payload.readInt4()];
+ public Object read(final PostgreSQLPacketPayload payload, final int parameterValueLength) {
+ byte[] bytes = new byte[parameterValueLength];
payload.getByteBuf().readBytes(bytes);
String result = new String(bytes);
return new PostgreSQLTypeUnspecifiedSQLParameter(result);
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 2631960..daccdf0 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
@@ -54,7 +54,6 @@ public final class PostgreSQLComBindPacketTest {
public void assertWrite() {
when(payload.readInt2()).thenReturn(1);
when(payload.readInt4()).thenReturn(1);
- when(payload.readInt8()).thenReturn(11L);
String sql = "select * from order where id = ? ";
PostgreSQLBinaryStatementRegistry.getInstance().get(1).register(
"sts-id", sql, 1, Collections.singletonList(new PostgreSQLBinaryStatementParameterType(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8)));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java
index cbb5c75..cabf82c 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLBoolArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new boolean[] {true, false}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
index df49464..5a76b08 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
@@ -44,7 +44,7 @@ public final class PostgreSQLDateBinaryProtocolValueTest {
@Test
public void assertRead() {
when(payload.readInt8()).thenReturn(1L);
- assertThat(new PostgreSQLDateBinaryProtocolValue().read(payload), is(1L));
+ assertThat(new PostgreSQLDateBinaryProtocolValue().read(payload, 8), is(1L));
}
@Test
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValueTest.java
index 1d84fe4..63cd78a 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLDoubleBinaryProtocolValueTest.java
@@ -43,7 +43,7 @@ public final class PostgreSQLDoubleBinaryProtocolValueTest {
@Test
public void assertRead() {
when(byteBuf.readDouble()).thenReturn(1D);
- assertThat(new PostgreSQLDoubleBinaryProtocolValue().read(new PostgreSQLPacketPayload(byteBuf)), is(1D));
+ assertThat(new PostgreSQLDoubleBinaryProtocolValue().read(new PostgreSQLPacketPayload(byteBuf), 8), is(1D));
}
@Test
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java
index 7328d59..4608856 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLFloat4ArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new float[] {11.1F, 12.1F}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java
index 63d2deb..eecc287 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLFloat8ArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new double[] {11.1D, 12.1D}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValueTest.java
index 8fc5b4c..a3f9c67 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLFloatBinaryProtocolValueTest.java
@@ -43,7 +43,7 @@ public final class PostgreSQLFloatBinaryProtocolValueTest {
@Test
public void assertRead() {
when(byteBuf.readFloat()).thenReturn(1F);
- assertThat(new PostgreSQLFloatBinaryProtocolValue().read(new PostgreSQLPacketPayload(byteBuf)), is(1.0F));
+ assertThat(new PostgreSQLFloatBinaryProtocolValue().read(new PostgreSQLPacketPayload(byteBuf), 4), is(1.0F));
}
@Test
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java
index 94e897c..7b37ce5 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLInt2ArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new short[] {11, 12}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValueTest.java
index 35645ee..2eee4e3 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt2BinaryProtocolValueTest.java
@@ -23,7 +23,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@@ -38,9 +37,9 @@ public final class PostgreSQLInt2BinaryProtocolValueTest {
@Test
public void assertNewInstance() {
PostgreSQLInt2BinaryProtocolValue actual = new PostgreSQLInt2BinaryProtocolValue();
- assertThat(actual.getColumnLength(null), equalTo(2));
+ assertThat(actual.getColumnLength(null), is(2));
when(payload.readInt2()).thenReturn(1);
- assertThat(actual.read(payload), is(1));
+ assertThat(actual.read(payload, 2), is(1));
actual.write(payload, 1);
verify(payload).writeInt2(1);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java
index f4cb93b..2567e39 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLInt4ArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new int[] {11, 12}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValueTest.java
index de0423d..d448dba 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt4BinaryProtocolValueTest.java
@@ -23,7 +23,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@@ -38,9 +37,9 @@ public final class PostgreSQLInt4BinaryProtocolValueTest {
@Test
public void assertNewInstance() {
PostgreSQLInt4BinaryProtocolValue actual = new PostgreSQLInt4BinaryProtocolValue();
- assertThat(actual.getColumnLength(null), equalTo(4));
+ assertThat(actual.getColumnLength(null), is(4));
when(payload.readInt4()).thenReturn(1);
- assertThat(actual.read(payload), is(1));
+ assertThat(actual.read(payload, 4), is(1));
actual.write(payload, 1);
verify(payload).writeInt4(1);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java
index fae8b42..4cbfc03 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLInt8ArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new long[] {11, 12}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValueTest.java
index 447293f..7bdf399 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLInt8BinaryProtocolValueTest.java
@@ -23,7 +23,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@@ -38,9 +37,9 @@ public final class PostgreSQLInt8BinaryProtocolValueTest {
@Test
public void assertNewInstance() {
PostgreSQLInt8BinaryProtocolValue actual = new PostgreSQLInt8BinaryProtocolValue();
- assertThat(actual.getColumnLength(null), equalTo(8));
+ assertThat(actual.getColumnLength(null), is(8));
when(payload.readInt8()).thenReturn(1L);
- assertThat(actual.read(payload), is(1L));
+ assertThat(actual.read(payload, 8), is(1L));
actual.write(payload, 1L);
verify(payload).writeInt8(1L);
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java
index ad837fe..c73dab1 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.math.BigDecimal;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -50,7 +51,7 @@ public final class PostgreSQLNumericBinaryProtocolValueTest {
byteBuf.writeBytes(decimalText.getBytes(StandardCharsets.UTF_8));
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = binaryProtocolValue.read(payload);
+ Object result = binaryProtocolValue.read(payload, columnLength);
assertNotNull(result);
assertTrue(result instanceof BigDecimal);
assertThat(result, is(expectedDecimal));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java
index 8028a96..6a1ea7d 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java
@@ -18,11 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -47,7 +48,7 @@ public final class PostgreSQLStringArrayBinaryProtocolValueTest {
byteBuf.writeCharSequence(parameterValue, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = newInstance().read(payload);
+ Object result = newInstance().read(payload, parameterValue.length());
assertNotNull(result);
assertThat(result, is(new String[] {"a", "b"}));
assertThat(byteBuf.readerIndex(), is(expectedLength));
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValueTest.java
index 482789f..2b2b942 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLStringBinaryProtocolValueTest.java
@@ -26,12 +26,11 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
-import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public final class PostgreSQLStringBinaryProtocolValueTest {
@@ -44,16 +43,13 @@ public final class PostgreSQLStringBinaryProtocolValueTest {
@Test
public void assertNewInstance() {
- when(byteBuf.readerIndex()).thenReturn(8);
doAnswer((Answer<ByteBuf>) invocation -> {
((byte[]) invocation.getArguments()[0])[0] = 97;
return byteBuf;
}).when(byteBuf).readBytes(any(byte[].class));
PostgreSQLStringBinaryProtocolValue actual = new PostgreSQLStringBinaryProtocolValue();
- assertThat(actual.getColumnLength("str"), equalTo("str".length()));
- when(payload.readInt4()).thenReturn(1);
- assertThat(actual.read(payload), equalTo("a"));
- verify(byteBuf).readerIndex(4);
+ assertThat(actual.getColumnLength("str"), is("str".length()));
+ assertThat(actual.read(payload, "a".length()), is("a"));
actual.write(payload, "a");
verify(byteBuf).writeBytes("a".getBytes());
actual.write(payload, new byte[1]);
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValueTest.java
index c1582ed..ffe51b4 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLTimeBinaryProtocolValueTest.java
@@ -25,7 +25,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.sql.Timestamp;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@@ -40,9 +39,9 @@ public final class PostgreSQLTimeBinaryProtocolValueTest {
@Test
public void assertNewInstance() {
PostgreSQLTimeBinaryProtocolValue actual = new PostgreSQLTimeBinaryProtocolValue();
- assertThat(actual.getColumnLength(null), equalTo(8));
+ assertThat(actual.getColumnLength(null), is(8));
when(payload.readInt8()).thenReturn(1L);
- assertThat(actual.read(payload), is(1L));
+ assertThat(actual.read(payload, 8), is(1L));
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
actual.write(payload, timestamp);
verify(payload).writeInt8(timestamp.getTime());
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
index cdeb519..f15a2b4 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.PostgreSQLTypeUnspecifiedSQLParameter;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -46,7 +47,7 @@ public final class PostgreSQLUnspecifiedBinaryProtocolValueTest {
byteBuf.writeCharSequence(timestampStr, StandardCharsets.ISO_8859_1);
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
- Object result = new PostgreSQLUnspecifiedBinaryProtocolValue().read(payload);
+ Object result = new PostgreSQLUnspecifiedBinaryProtocolValue().read(payload, timestampStr.length());
assertNotNull(result);
assertTrue(result instanceof PostgreSQLTypeUnspecifiedSQLParameter);
assertThat(result.toString(), is(timestampStr));