This is an automated email from the ASF dual-hosted git repository.
panjuan 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 a62d3da Add BinaryResultSetRow to refactor BinaryResultSetRowPacket
(#8452)
a62d3da is described below
commit a62d3daaa0771449880b6af3bdb62d3b0a1482d6
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Dec 1 18:57:15 2020 +0800
Add BinaryResultSetRow to refactor BinaryResultSetRowPacket (#8452)
* Fix javadoc
* Move PostgreSQLColumnType and MySQLSQLColumnType usage into protocol
modules
* Add MySQLBinaryResultSetRow to refactor MySQLBinaryResultSetRowPacket
* Add BinaryResultSetRow to refactor BinaryResultSetRowPacket
* Add BinaryResultSetRow to refactor BinaryResultSetRowPacket
* Add SQLColumnType interface
* Add BinaryResultSetRow
* Rename BinaryColumnType
* Add BinaryColumnType.getValue
* Remove PostgreSQLBinaryResultSetRow and MySQLBinaryResultSetRow
* Remove generic type for BinaryResultSetRow
* Update javadoc
---
.../db/protocol/binary/BinaryColumnType.java} | 21 +++----
.../db/protocol/binary/BinaryResultSetRow.java} | 11 ++--
...LColumnType.java => MySQLBinaryColumnType.java} | 15 ++---
.../binlog/row/MySQLBinlogTableMapEventPacket.java | 6 +-
.../binlog/row/column/MySQLBinlogColumnDef.java | 4 +-
.../value/MySQLBinlogProtocolValueFactory.java | 50 ++++++++--------
.../string/MySQLStringBinlogProtocolValue.java | 4 +-
.../query/MySQLColumnDefinition41Packet.java | 12 ++--
.../binary/MySQLBinaryStatementParameterType.java | 4 +-
.../execute/MySQLBinaryResultSetRowPacket.java | 39 ++++++++-----
.../binary/execute/MySQLComStmtExecutePacket.java | 4 +-
.../protocol/MySQLBinaryProtocolValueFactory.java | 65 +++++++++++----------
.../mysql/constant/MySQLBinaryColumnTypeTest.java | 68 ++++++++++++++++++++++
.../mysql/constant/MySQLColumnTypeTest.java | 68 ----------------------
.../binlog/row/MySQLBinlogRowsEventPacketTest.java | 4 +-
.../row/MySQLBinlogTableMapEventPacketTest.java | 16 ++---
.../value/MySQLBinlogProtocolValueFactoryTest.java | 6 +-
.../blob/MySQLBlobBinlogProtocolValueTest.java | 4 +-
.../MySQLDecimalBinlogProtocolValueTest.java | 6 +-
.../string/MySQLJsonBinlogProtocolValueTest.java | 4 +-
.../string/MySQLStringBinlogProtocolValueTest.java | 18 +++---
.../MySQLVarcharBinlogProtocolValueTest.java | 4 +-
.../MySQLDatetime2BinlogProtocolValueTest.java | 4 +-
.../time/MySQLTime2BinlogProtocolValueTest.java | 4 +-
.../MySQLTimestamp2BinlogProtocolValueTest.java | 4 +-
.../query/MySQLColumnDefinition41PacketTest.java | 6 +-
.../execute/MySQLBinaryResultSetRowPacketTest.java | 4 +-
.../MySQLMySQLBinaryProtocolValueFactoryTest.java | 54 ++++++++---------
...mnType.java => PostgreSQLBinaryColumnType.java} | 13 +++--
.../command/query/PostgreSQLColumnDescription.java | 4 +-
.../PostgreSQLBinaryStatementParameterType.java | 4 +-
.../bind/PostgreSQLBinaryResultSetRowPacket.java | 30 ++++++----
.../PostgreSQLBinaryProtocolValueFactory.java | 31 +++++-----
.../binary/parse/PostgreSQLComParsePacket.java | 4 +-
...st.java => PostgreSQLBinaryColumnTypeTest.java} | 16 ++---
.../PostgreSQLBinaryResultSetRowPacketTest.java | 12 ++--
.../binary/bind/PostgreSQLComBindPacketTest.java | 4 +-
.../PostgreSQLBinaryProtocolValueFactoryTest.java | 20 +++----
.../binary/parse/PostgreSQLComParsePacketTest.java | 4 +-
.../header/query/impl/QueryHeaderBuilder.java | 2 +-
.../execute/MySQLComStmtExecuteExecutor.java | 6 +-
.../prepare/MySQLComStmtPrepareExecutor.java | 6 +-
.../query/builder/ResponsePacketBuilder.java | 4 +-
.../fieldlist/MySQLComFieldListPacketExecutor.java | 5 +-
.../binary/bind/PostgreSQLComBindExecutor.java | 6 +-
.../scaling/mysql/binlog/BinlogContextTest.java | 4 +-
46 files changed, 349 insertions(+), 335 deletions(-)
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/binary/BinaryColumnType.java
similarity index 64%
copy from
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
copy to
shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/binary/BinaryColumnType.java
index df463e4..217af69 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/binary/BinaryColumnType.java
@@ -15,20 +15,17 @@
* limitations under the License.
*/
-package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+package org.apache.shardingsphere.db.protocol.binary;
/**
- * Binary prepared statement parameter type for MySQL.
+ * Binary column type.
*/
-@RequiredArgsConstructor
-@Getter
-public final class MySQLBinaryStatementParameterType {
-
- private final MySQLColumnType columnType;
+public interface BinaryColumnType {
- private final int unsignedFlag;
+ /**
+ * Get database protocol binary column type value.
+ *
+ * @return database protocol binary column type value
+ */
+ int getValue();
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/binary/BinaryResultSetRow.java
similarity index 72%
copy from
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
copy to
shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/binary/BinaryResultSetRow.java
index df463e4..08d179a 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/binary/BinaryResultSetRow.java
@@ -15,20 +15,19 @@
* limitations under the License.
*/
-package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary;
+package org.apache.shardingsphere.db.protocol.binary;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
/**
- * Binary prepared statement parameter type for MySQL.
+ * Binary result set row.
*/
@RequiredArgsConstructor
@Getter
-public final class MySQLBinaryStatementParameterType {
+public final class BinaryResultSetRow {
- private final MySQLColumnType columnType;
+ private final BinaryColumnType columnType;
- private final int unsignedFlag;
+ private final Object data;
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLColumnType.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
similarity index 88%
rename from
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLColumnType.java
rename to
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
index b23d43f..7f9d46a 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLColumnType.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnType.java
@@ -19,20 +19,21 @@ package
org.apache.shardingsphere.db.protocol.mysql.constant;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
/**
- * Column types for MySQL.
+ * Binary column type for MySQL.
*
* @see <a
href="https://dev.mysql.com/doc/internals/en/com-query-response.html#column-type">Column
Type</a>
* @see <a href="https://github.com/apache/shardingsphere/issues/4355"></a>
*/
@RequiredArgsConstructor
@Getter
-public enum MySQLColumnType {
+public enum MySQLBinaryColumnType implements BinaryColumnType {
MYSQL_TYPE_DECIMAL(0x00),
@@ -101,9 +102,9 @@ public enum MySQLColumnType {
MYSQL_TYPE_GEOMETRY(0xff);
- private static final Map<Integer, MySQLColumnType>
JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1);
+ private static final Map<Integer, MySQLBinaryColumnType>
JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1);
- private static final Map<Integer, MySQLColumnType>
VALUE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1);
+ private static final Map<Integer, MySQLBinaryColumnType>
VALUE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1);
private final int value;
@@ -129,7 +130,7 @@ public enum MySQLColumnType {
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.LONGVARBINARY,
MYSQL_TYPE_VAR_STRING);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.NULL, MYSQL_TYPE_NULL);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.BLOB, MYSQL_TYPE_BLOB);
- for (MySQLColumnType each : values()) {
+ for (MySQLBinaryColumnType each : values()) {
VALUE_AND_COLUMN_TYPE_MAP.put(each.value, each);
}
}
@@ -140,7 +141,7 @@ public enum MySQLColumnType {
* @param jdbcType JDBC type
* @return column type enum
*/
- public static MySQLColumnType valueOfJDBCType(final int jdbcType) {
+ public static MySQLBinaryColumnType valueOfJDBCType(final int jdbcType) {
if (JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType)) {
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}
@@ -153,7 +154,7 @@ public enum MySQLColumnType {
* @param value value
* @return column type
*/
- public static MySQLColumnType valueOf(final int value) {
+ public static MySQLBinaryColumnType valueOf(final int value) {
if (VALUE_AND_COLUMN_TYPE_MAP.containsKey(value)) {
return VALUE_AND_COLUMN_TYPE_MAP.get(value);
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacket.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacket.java
index 202a676..d23789f 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacket.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacket.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row;
import lombok.Getter;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.AbstractMySQLBinlogEventPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.MySQLBinlogEventHeader;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
@@ -67,7 +67,7 @@ public final class MySQLBinlogTableMapEventPacket extends
AbstractMySQLBinlogEve
private void readColumnDefs(final MySQLPacketPayload payload) {
for (int i = 0; i < columnCount; i++) {
- columnDefs.add(new
MySQLBinlogColumnDef(MySQLColumnType.valueOf(payload.readInt1())));
+ columnDefs.add(new
MySQLBinlogColumnDef(MySQLBinaryColumnType.valueOf(payload.readInt1())));
}
}
@@ -78,7 +78,7 @@ public final class MySQLBinlogTableMapEventPacket extends
AbstractMySQLBinlogEve
}
}
- private int readColumnMetaDef(final MySQLColumnType columnType, final
MySQLPacketPayload payload) {
+ private int readColumnMetaDef(final MySQLBinaryColumnType columnType,
final MySQLPacketPayload payload) {
switch (columnType) {
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_DECIMAL:
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/MySQLBinlogColumnDef.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/MySQLBinlogColumnDef.java
index cef2bc9..0b4178e 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/MySQLBinlogColumnDef.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/MySQLBinlogColumnDef.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -33,7 +33,7 @@ import lombok.Setter;
@Getter
public final class MySQLBinlogColumnDef {
- private final MySQLColumnType columnType;
+ private final MySQLBinaryColumnType columnType;
private int columnMeta;
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactory.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactory.java
index 2e5b122..c4ea7b8 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactory.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactory.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.val
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.blob.MySQLBlobBinlogProtocolValue;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.decimal.MySQLDecimalBinlogProtocolValue;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.decimal.MySQLDoubleBinlogProtocolValue;
@@ -52,7 +52,7 @@ import java.util.Map;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class MySQLBinlogProtocolValueFactory {
- private static final Map<MySQLColumnType, MySQLBinlogProtocolValue>
BINLOG_PROTOCOL_VALUES = new HashMap<>();
+ private static final Map<MySQLBinaryColumnType, MySQLBinlogProtocolValue>
BINLOG_PROTOCOL_VALUES = new HashMap<>();
static {
registerIntegerTypeValue();
@@ -63,40 +63,40 @@ public final class MySQLBinlogProtocolValueFactory {
}
private static void registerIntegerTypeValue() {
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_BIT, new
MySQLBitBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TINY, new
MySQLTinyBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_SHORT, new
MySQLShortBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_INT24, new
MySQLInt24BinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_LONG, new
MySQLLongBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_LONGLONG, new
MySQLLongLongBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_BIT, new
MySQLBitBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TINY, new
MySQLTinyBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_SHORT, new
MySQLShortBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_INT24, new
MySQLInt24BinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_LONG, new
MySQLLongBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG,
new MySQLLongLongBinlogProtocolValue());
}
private static void registerDecimalTypeValue() {
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL, new
MySQLDecimalBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DOUBLE, new
MySQLDoubleBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_FLOAT, new
MySQLFloatBinlogProtocolValue());
+
BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL, new
MySQLDecimalBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DOUBLE,
new MySQLDoubleBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_FLOAT, new
MySQLFloatBinlogProtocolValue());
}
private static void registerTimeTypeValue() {
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_YEAR, new
MySQLYearBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DATE, new
MySQLDateBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TIME, new
MySQLTimeBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TIME2, new
MySQLTime2BinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TIMESTAMP, new
MySQLTimestampBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TIMESTAMP2, new
MySQLTimestamp2BinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DATETIME, new
MySQLDatetimeBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DATETIME2, new
MySQLDatetime2BinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_YEAR, new
MySQLYearBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DATE, new
MySQLDateBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TIME, new
MySQLTimeBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TIME2, new
MySQLTime2BinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TIMESTAMP,
new MySQLTimestampBinlogProtocolValue());
+
BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TIMESTAMP2, new
MySQLTimestamp2BinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DATETIME,
new MySQLDatetimeBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DATETIME2,
new MySQLDatetime2BinlogProtocolValue());
}
private static void registerStringTypeValue() {
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_STRING, new
MySQLStringBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_VARCHAR, new
MySQLVarcharBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_VAR_STRING, new
MySQLVarcharBinlogProtocolValue());
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MySQL_TYPE_JSON, new
MySQLJsonBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_STRING,
new MySQLStringBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR,
new MySQLVarcharBinlogProtocolValue());
+
BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING, new
MySQLVarcharBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MySQL_TYPE_JSON, new
MySQLJsonBinlogProtocolValue());
}
private static void registerBlobTypeValue() {
- BINLOG_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_BLOB, new
MySQLBlobBinlogProtocolValue());
+ BINLOG_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_BLOB, new
MySQLBlobBinlogProtocolValue());
}
/**
@@ -105,7 +105,7 @@ public final class MySQLBinlogProtocolValueFactory {
* @param columnType column type
* @return binlog protocol value
*/
- public static MySQLBinlogProtocolValue getBinlogProtocolValue(final
MySQLColumnType columnType) {
+ public static MySQLBinlogProtocolValue getBinlogProtocolValue(final
MySQLBinaryColumnType columnType) {
Preconditions.checkArgument(BINLOG_PROTOCOL_VALUES.containsKey(columnType),
"Cannot find MySQL type '%s' in column type when process binlog protocol
value", columnType);
return BINLOG_PROTOCOL_VALUES.get(columnType);
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
index 36c25f5..25d6bf4 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.MySQLBinlogProtocolValue;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
@@ -38,7 +38,7 @@ public final class MySQLStringBinlogProtocolValue implements
MySQLBinlogProtocol
length += ((type & 0x30) ^ 0x30) << 4;
type |= 0x30;
}
- switch (MySQLColumnType.valueOf(type)) {
+ switch (MySQLBinaryColumnType.valueOf(type)) {
case MYSQL_TYPE_ENUM:
return readEnumValue(length, payload);
case MYSQL_TYPE_SET:
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41Packet.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41Packet.java
index cd3a3dd..53259f1 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41Packet.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41Packet.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query;
import com.google.common.base.Preconditions;
import lombok.Getter;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerInfo;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
@@ -58,14 +58,14 @@ public final class MySQLColumnDefinition41Packet implements
MySQLPacket {
private final int columnLength;
- private final MySQLColumnType columnType;
+ private final MySQLBinaryColumnType columnType;
private final int decimals;
public MySQLColumnDefinition41Packet(final int sequenceId, final
ResultSetMetaData resultSetMetaData, final int columnIndex) throws SQLException
{
this(sequenceId, resultSetMetaData.getSchemaName(columnIndex),
resultSetMetaData.getTableName(columnIndex),
resultSetMetaData.getTableName(columnIndex),
resultSetMetaData.getColumnLabel(columnIndex),
resultSetMetaData.getColumnName(columnIndex),
resultSetMetaData.getColumnDisplaySize(columnIndex),
-
MySQLColumnType.valueOfJDBCType(resultSetMetaData.getColumnType(columnIndex)),
resultSetMetaData.getScale(columnIndex));
+
MySQLBinaryColumnType.valueOfJDBCType(resultSetMetaData.getColumnType(columnIndex)),
resultSetMetaData.getScale(columnIndex));
}
/*
@@ -74,12 +74,12 @@ public final class MySQLColumnDefinition41Packet implements
MySQLPacket {
* @see <a href="https://github.com/apache/shardingsphere/issues/4358"></a>
*/
public MySQLColumnDefinition41Packet(final int sequenceId, final String
schema, final String table, final String orgTable,
- final String name, final String
orgName, final int columnLength, final MySQLColumnType columnType, final int
decimals) {
+ final String name, final String
orgName, final int columnLength, final MySQLBinaryColumnType columnType, final
int decimals) {
this(sequenceId, 0, schema, table, orgTable, name, orgName,
columnLength, columnType, decimals);
}
public MySQLColumnDefinition41Packet(final int sequenceId, final int
flags, final String schema, final String table, final String orgTable,
- final String name, final String
orgName, final int columnLength, final MySQLColumnType columnType, final int
decimals) {
+ final String name, final String
orgName, final int columnLength, final MySQLBinaryColumnType columnType, final
int decimals) {
this.sequenceId = sequenceId;
characterSet = MySQLServerInfo.CHARSET;
this.flags = flags;
@@ -104,7 +104,7 @@ public final class MySQLColumnDefinition41Packet implements
MySQLPacket {
Preconditions.checkArgument(NEXT_LENGTH == payload.readIntLenenc());
characterSet = payload.readInt2();
columnLength = payload.readInt4();
- columnType = MySQLColumnType.valueOf(payload.readInt1());
+ columnType = MySQLBinaryColumnType.valueOf(payload.readInt1());
flags = payload.readInt2();
decimals = payload.readInt1();
payload.skipReserved(2);
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
index df463e4..03ff4dc 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/MySQLBinaryStatementParameterType.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
/**
* Binary prepared statement parameter type for MySQL.
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
@Getter
public final class MySQLBinaryStatementParameterType {
- private final MySQLColumnType columnType;
+ private final MySQLBinaryColumnType columnType;
private final int unsignedFlag;
}
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 9139974..db86b96 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
@@ -18,12 +18,14 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import org.apache.shardingsphere.db.protocol.binary.BinaryResultSetRow;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.protocol.MySQLBinaryProtocolValueFactory;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -31,7 +33,6 @@ import java.util.List;
*
* @see <a
href="https://dev.mysql.com/doc/internals/en/binary-protocol-resultset-row.html">Binary
Protocol Resultset Row</a>
*/
-@RequiredArgsConstructor
public final class MySQLBinaryResultSetRowPacket implements MySQLPacket {
private static final int PACKET_HEADER = 0x00;
@@ -41,9 +42,20 @@ public final class MySQLBinaryResultSetRowPacket implements
MySQLPacket {
@Getter
private final int sequenceId;
- private final List<Object> data;
+ private final Collection<BinaryResultSetRow> binaryRows;
- private final List<MySQLColumnType> columnTypes;
+ public MySQLBinaryResultSetRowPacket(final int sequenceId, final
List<Object> data, final List<Integer> columnTypes) {
+ this.sequenceId = sequenceId;
+ binaryRows = getBinaryResultSetRows(columnTypes, data);
+ }
+
+ private Collection<BinaryResultSetRow> getBinaryResultSetRows(final
List<Integer> columnTypes, final List<Object> data) {
+ Collection<BinaryResultSetRow> result = new LinkedList<>();
+ for (int i = 0; i < columnTypes.size(); i++) {
+ result.add(new
BinaryResultSetRow(MySQLBinaryColumnType.valueOfJDBCType(columnTypes.get(i)),
data.get(i)));
+ }
+ return result;
+ }
@Override
public void write(final MySQLPacketPayload payload) {
@@ -59,20 +71,21 @@ public final class MySQLBinaryResultSetRowPacket implements
MySQLPacket {
}
private MySQLNullBitmap getNullBitmap() {
- MySQLNullBitmap result = new MySQLNullBitmap(columnTypes.size(),
NULL_BITMAP_OFFSET);
- for (int columnIndex = 0; columnIndex < columnTypes.size();
columnIndex++) {
- if (null == data.get(columnIndex)) {
- result.setNullBit(columnIndex);
+ MySQLNullBitmap result = new MySQLNullBitmap(binaryRows.size(),
NULL_BITMAP_OFFSET);
+ int index = 0;
+ for (BinaryResultSetRow each : binaryRows) {
+ if (null == each.getData()) {
+ result.setNullBit(index);
}
+ index++;
}
return result;
}
private void writeValues(final MySQLPacketPayload payload) {
- for (int i = 0; i < columnTypes.size(); i++) {
- Object value = data.get(i);
- if (null != value) {
-
MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(columnTypes.get(i)).write(payload,
value);
+ for (BinaryResultSetRow each : binaryRows) {
+ if (null != each.getData()) {
+
MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(each.getColumnType()).write(payload,
each.getData());
}
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacket.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacket.java
index a132598..1f7ed31 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacket.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacket.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.ToString;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLNewParametersBoundFlag;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.MySQLCommandPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.MySQLCommandPacketType;
@@ -92,7 +92,7 @@ public final class MySQLComStmtExecutePacket extends
MySQLCommandPacket {
private List<MySQLBinaryStatementParameterType> getParameterTypes(final
MySQLPacketPayload payload, final int parameterCount) {
List<MySQLBinaryStatementParameterType> result = new
ArrayList<>(parameterCount);
for (int parameterIndex = 0; parameterIndex < parameterCount;
parameterIndex++) {
- MySQLColumnType columnType =
MySQLColumnType.valueOf(payload.readInt1());
+ MySQLBinaryColumnType columnType =
MySQLBinaryColumnType.valueOf(payload.readInt1());
int unsignedFlag = payload.readInt1();
result.add(new MySQLBinaryStatementParameterType(columnType,
unsignedFlag));
}
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/MySQLBinaryProtocolValueFactory.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactory.java
index a3747fd..01f52b5 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactory.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactory.java
@@ -20,7 +20,8 @@ package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import java.util.HashMap;
import java.util.Map;
@@ -31,7 +32,7 @@ import java.util.Map;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class MySQLBinaryProtocolValueFactory {
- private static final Map<MySQLColumnType, MySQLBinaryProtocolValue>
BINARY_PROTOCOL_VALUES = new HashMap<>();
+ private static final Map<BinaryColumnType, MySQLBinaryProtocolValue>
BINARY_PROTOCOL_VALUES = new HashMap<>();
static {
setStringLenencBinaryProtocolValue();
@@ -48,77 +49,77 @@ public final class MySQLBinaryProtocolValueFactory {
private static void setStringLenencBinaryProtocolValue() {
MySQLStringLenencBinaryProtocolValue binaryProtocolValue = new
MySQLStringLenencBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_STRING,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_VARCHAR,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_VAR_STRING,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_ENUM,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_SET,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_LONG_BLOB,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_MEDIUM_BLOB,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_BLOB,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TINY_BLOB,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_GEOMETRY,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_BIT,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DECIMAL,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_STRING,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_ENUM,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_SET,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_LONG_BLOB,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_MEDIUM_BLOB,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_BLOB,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TINY_BLOB,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_GEOMETRY,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_BIT,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DECIMAL,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL,
binaryProtocolValue);
}
private static void setInt8BinaryProtocolValue() {
MySQLInt8BinaryProtocolValue binaryProtocolValue = new
MySQLInt8BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_LONGLONG,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG,
binaryProtocolValue);
}
private static void setInt4BinaryProtocolValue() {
MySQLInt4BinaryProtocolValue binaryProtocolValue = new
MySQLInt4BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_LONG,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_INT24,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_LONG,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_INT24,
binaryProtocolValue);
}
private static void setInt2BinaryProtocolValue() {
MySQLInt2BinaryProtocolValue binaryProtocolValue = new
MySQLInt2BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_SHORT,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_YEAR,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_SHORT,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_YEAR,
binaryProtocolValue);
}
private static void setInt1BinaryProtocolValue() {
MySQLInt1BinaryProtocolValue binaryProtocolValue = new
MySQLInt1BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TINY,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TINY,
binaryProtocolValue);
}
private static void setDoubleBinaryProtocolValue() {
MySQLDoubleBinaryProtocolValue binaryProtocolValue = new
MySQLDoubleBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DOUBLE,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DOUBLE,
binaryProtocolValue);
}
private static void setFloatBinaryProtocolValue() {
MySQLFloatBinaryProtocolValue binaryProtocolValue = new
MySQLFloatBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_FLOAT,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_FLOAT,
binaryProtocolValue);
}
private static void setDateBinaryProtocolValue() {
MySQLDateBinaryProtocolValue binaryProtocolValue = new
MySQLDateBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DATE,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_DATETIME,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TIMESTAMP,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DATE,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_DATETIME,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TIMESTAMP,
binaryProtocolValue);
}
private static void setTimeBinaryProtocolValue() {
MySQLTimeBinaryProtocolValue binaryProtocolValue = new
MySQLTimeBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_TIME,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_TIME,
binaryProtocolValue);
}
private static void setNullBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(MySQLColumnType.MYSQL_TYPE_NULL, null);
+ BINARY_PROTOCOL_VALUES.put(MySQLBinaryColumnType.MYSQL_TYPE_NULL,
null);
}
/**
* Get binary protocol value.
*
- * @param columnType column type
+ * @param binaryColumnType binary column type
* @return binary protocol value
*/
- public static MySQLBinaryProtocolValue getBinaryProtocolValue(final
MySQLColumnType columnType) {
-
Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(columnType),
"Cannot find MySQL type '%s' in column type when process binary protocol
value", columnType);
- return BINARY_PROTOCOL_VALUES.get(columnType);
+ public static MySQLBinaryProtocolValue getBinaryProtocolValue(final
BinaryColumnType binaryColumnType) {
+
Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(binaryColumnType),
"Cannot find MySQL type '%s' in column type when process binary protocol
value", binaryColumnType);
+ return BINARY_PROTOCOL_VALUES.get(binaryColumnType);
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnTypeTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnTypeTest.java
new file mode 100644
index 0000000..b656fe4
--- /dev/null
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLBinaryColumnTypeTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.db.protocol.mysql.constant;
+
+import org.junit.Test;
+
+import java.sql.Types;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class MySQLBinaryColumnTypeTest {
+
+ @Test
+ public void assertValueOfJDBC() {
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.BIT),
is(MySQLBinaryColumnType.MYSQL_TYPE_BIT));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.TINYINT),
is(MySQLBinaryColumnType.MYSQL_TYPE_TINY));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.SMALLINT),
is(MySQLBinaryColumnType.MYSQL_TYPE_SHORT));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.INTEGER),
is(MySQLBinaryColumnType.MYSQL_TYPE_LONG));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.BIGINT),
is(MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.FLOAT),
is(MySQLBinaryColumnType.MYSQL_TYPE_FLOAT));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.REAL),
is(MySQLBinaryColumnType.MYSQL_TYPE_FLOAT));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.DOUBLE),
is(MySQLBinaryColumnType.MYSQL_TYPE_DOUBLE));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.NUMERIC),
is(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.DECIMAL),
is(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.CHAR),
is(MySQLBinaryColumnType.MYSQL_TYPE_STRING));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.VARCHAR),
is(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.LONGVARCHAR),
is(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.DATE),
is(MySQLBinaryColumnType.MYSQL_TYPE_DATE));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.TIME),
is(MySQLBinaryColumnType.MYSQL_TYPE_TIME));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.TIMESTAMP),
is(MySQLBinaryColumnType.MYSQL_TYPE_TIMESTAMP));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.BINARY),
is(MySQLBinaryColumnType.MYSQL_TYPE_STRING));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.VARBINARY),
is(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.LONGVARBINARY),
is(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.NULL),
is(MySQLBinaryColumnType.MYSQL_TYPE_NULL));
+ assertThat(MySQLBinaryColumnType.valueOfJDBCType(Types.BLOB),
is(MySQLBinaryColumnType.MYSQL_TYPE_BLOB));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void assertValueOfJDBCIllegalArgument() {
+ MySQLBinaryColumnType.valueOfJDBCType(9999);
+ }
+
+ @Test
+ public void assertValueOf() {
+
assertThat(MySQLBinaryColumnType.valueOf(MySQLBinaryColumnType.MYSQL_TYPE_DECIMAL.getValue()),
is(MySQLBinaryColumnType.MYSQL_TYPE_DECIMAL));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void assertValueOfWithIllegalArgument() {
+ MySQLBinaryColumnType.valueOf(-1);
+ }
+}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLColumnTypeTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLColumnTypeTest.java
deleted file mode 100644
index bffdca1..0000000
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLColumnTypeTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.db.protocol.mysql.constant;
-
-import org.junit.Test;
-
-import java.sql.Types;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class MySQLColumnTypeTest {
-
- @Test
- public void assertValueOfJDBC() {
- assertThat(MySQLColumnType.valueOfJDBCType(Types.BIT),
is(MySQLColumnType.MYSQL_TYPE_BIT));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.TINYINT),
is(MySQLColumnType.MYSQL_TYPE_TINY));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.SMALLINT),
is(MySQLColumnType.MYSQL_TYPE_SHORT));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.INTEGER),
is(MySQLColumnType.MYSQL_TYPE_LONG));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.BIGINT),
is(MySQLColumnType.MYSQL_TYPE_LONGLONG));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.FLOAT),
is(MySQLColumnType.MYSQL_TYPE_FLOAT));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.REAL),
is(MySQLColumnType.MYSQL_TYPE_FLOAT));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.DOUBLE),
is(MySQLColumnType.MYSQL_TYPE_DOUBLE));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.NUMERIC),
is(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.DECIMAL),
is(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.CHAR),
is(MySQLColumnType.MYSQL_TYPE_STRING));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.VARCHAR),
is(MySQLColumnType.MYSQL_TYPE_VAR_STRING));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.LONGVARCHAR),
is(MySQLColumnType.MYSQL_TYPE_VAR_STRING));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.DATE),
is(MySQLColumnType.MYSQL_TYPE_DATE));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.TIME),
is(MySQLColumnType.MYSQL_TYPE_TIME));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.TIMESTAMP),
is(MySQLColumnType.MYSQL_TYPE_TIMESTAMP));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.BINARY),
is(MySQLColumnType.MYSQL_TYPE_STRING));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.VARBINARY),
is(MySQLColumnType.MYSQL_TYPE_VAR_STRING));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.LONGVARBINARY),
is(MySQLColumnType.MYSQL_TYPE_VAR_STRING));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.NULL),
is(MySQLColumnType.MYSQL_TYPE_NULL));
- assertThat(MySQLColumnType.valueOfJDBCType(Types.BLOB),
is(MySQLColumnType.MYSQL_TYPE_BLOB));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfJDBCIllegalArgument() {
- MySQLColumnType.valueOfJDBCType(9999);
- }
-
- @Test
- public void assertValueOf() {
-
assertThat(MySQLColumnType.valueOf(MySQLColumnType.MYSQL_TYPE_DECIMAL.getValue()),
is(MySQLColumnType.MYSQL_TYPE_DECIMAL));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfWithIllegalArgument() {
- MySQLColumnType.valueOf(-1);
- }
-}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogRowsEventPacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogRowsEventPacketTest.java
index 7157d47..c897dfd 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogRowsEventPacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogRowsEventPacketTest.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row;
import io.netty.buffer.ByteBuf;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinlogEventType;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.MySQLBinlogEventHeader;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
@@ -71,7 +71,7 @@ public final class MySQLBinlogRowsEventPacketTest {
private void mockColumnDefs() {
columnDefs = new ArrayList<>();
- columnDefs.add(new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_LONGLONG));
+ columnDefs.add(new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG));
}
@Test
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacketTest.java
index 265d74b..c2e068b 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/MySQLBinlogTableMapEventPacketTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.MySQLBinlogEventHeader;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLNullBitmap;
@@ -54,8 +54,8 @@ public final class MySQLBinlogTableMapEventPacketTest {
public void assertNew() {
when(payload.readInt6()).thenReturn(1L);
when(payload.readInt2()).thenReturn(0, 255);
- when(payload.readInt1()).thenReturn(4, 4,
MySQLColumnType.MYSQL_TYPE_LONGLONG.getValue(),
MySQLColumnType.MYSQL_TYPE_VARCHAR.getValue(),
-
MySQLColumnType.MYSQL_TYPE_NEWDECIMAL.getValue(),
MySQLColumnType.MYSQL_TYPE_DATETIME2.getValue(), 11,
+ when(payload.readInt1()).thenReturn(4, 4,
MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG.getValue(),
MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR.getValue(),
+
MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL.getValue(),
MySQLBinaryColumnType.MYSQL_TYPE_DATETIME2.getValue(), 11,
0x0e);
when(payload.readStringFix(4)).thenReturn("test");
when(payload.readIntLenenc()).thenReturn(4L);
@@ -75,13 +75,13 @@ public final class MySQLBinlogTableMapEventPacketTest {
private void assertColumnDefs(final Collection<MySQLBinlogColumnDef>
columnDefs) {
assertThat(columnDefs.size(), is(4));
Iterator<MySQLBinlogColumnDef> columnDefIterator =
columnDefs.iterator();
- assertColumnDef(columnDefIterator.next(),
MySQLColumnType.MYSQL_TYPE_LONGLONG, 0);
- assertColumnDef(columnDefIterator.next(),
MySQLColumnType.MYSQL_TYPE_VARCHAR, 255);
- assertColumnDef(columnDefIterator.next(),
MySQLColumnType.MYSQL_TYPE_NEWDECIMAL, 10);
- assertColumnDef(columnDefIterator.next(),
MySQLColumnType.MYSQL_TYPE_DATETIME2, 11);
+ assertColumnDef(columnDefIterator.next(),
MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG, 0);
+ assertColumnDef(columnDefIterator.next(),
MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR, 255);
+ assertColumnDef(columnDefIterator.next(),
MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL, 10);
+ assertColumnDef(columnDefIterator.next(),
MySQLBinaryColumnType.MYSQL_TYPE_DATETIME2, 11);
}
- private void assertColumnDef(final MySQLBinlogColumnDef actual, final
MySQLColumnType columnType, final int columnMeta) {
+ private void assertColumnDef(final MySQLBinlogColumnDef actual, final
MySQLBinaryColumnType columnType, final int columnMeta) {
assertThat(actual.getColumnType(), is(columnType));
assertThat(actual.getColumnMeta(), is(columnMeta));
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
index 230a653..dca2925 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.integer.MySQLTinyBinlogProtocolValue;
import org.junit.Test;
@@ -28,11 +28,11 @@ public final class MySQLBinlogProtocolValueFactoryTest {
@Test
public void assertGetBinlogProtocolValue() {
-
assertThat(MySQLBinlogProtocolValueFactory.getBinlogProtocolValue(MySQLColumnType.MYSQL_TYPE_TINY),
instanceOf(MySQLTinyBinlogProtocolValue.class));
+
assertThat(MySQLBinlogProtocolValueFactory.getBinlogProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_TINY),
instanceOf(MySQLTinyBinlogProtocolValue.class));
}
@Test(expected = IllegalArgumentException.class)
public void assertGetBinlogProtocolValueFailure() {
-
MySQLBinlogProtocolValueFactory.getBinlogProtocolValue(MySQLColumnType.MYSQL_TYPE_GEOMETRY);
+
MySQLBinlogProtocolValueFactory.getBinlogProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_GEOMETRY);
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
index 24eb3f4..1976a2c 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.blob;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -44,7 +44,7 @@ public final class MySQLBlobBinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_STRING);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_STRING);
}
@Test
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValueTest.java
index 292bdf9..d92d24d 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/decimal/MySQLDecimalBinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.decimal;
import io.netty.buffer.ByteBufUtil;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -42,7 +42,7 @@ public final class MySQLDecimalBinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL);
columnDef.setColumnMeta((14 << 8) + 4);
}
@@ -64,7 +64,7 @@ public final class MySQLDecimalBinlogProtocolValueTest {
@Test
public void assertDecodeNegativeNewDecimalWithLargeNumber() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL);
columnDef.setColumnMeta(32 << 8 | 6);
byte[] newDecimalBytes =
ByteBufUtil.decodeHexDump("7DFEFDB5CC2741EFDEBE4154FD52E7");
when(payload.readStringFixByBytes(newDecimalBytes.length)).thenReturn(newDecimalBytes);
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
index 9006546..71ac82b 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string.MySQLJsonValueDecoder.JsonValueTypes;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
@@ -52,7 +52,7 @@ public final class MySQLJsonBinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new MySQLBinlogColumnDef(MySQLColumnType.MySQL_TYPE_JSON);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MySQL_TYPE_JSON);
when(payload.getByteBuf()).thenReturn(byteBuf);
mockJsonValue();
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
index 7f91c50..eba693a 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -44,32 +44,32 @@ public final class MySQLStringBinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_STRING);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_STRING);
}
@Test
public void assertReadEnumValueWithMeta1() {
- columnDef.setColumnMeta((MySQLColumnType.MYSQL_TYPE_ENUM.getValue() <<
8) + 1);
+
columnDef.setColumnMeta((MySQLBinaryColumnType.MYSQL_TYPE_ENUM.getValue() << 8)
+ 1);
when(payload.readInt1()).thenReturn(1);
assertThat(new MySQLStringBinlogProtocolValue().read(columnDef,
payload), is(1));
}
@Test
public void assertReadEnumValueWithMeta2() {
- columnDef.setColumnMeta((MySQLColumnType.MYSQL_TYPE_ENUM.getValue() <<
8) + 2);
+
columnDef.setColumnMeta((MySQLBinaryColumnType.MYSQL_TYPE_ENUM.getValue() << 8)
+ 2);
when(payload.readInt2()).thenReturn(32767);
assertThat(new MySQLStringBinlogProtocolValue().read(columnDef,
payload), is(32767));
}
@Test(expected = UnsupportedOperationException.class)
public void assertReadEnumValueWithMetaFailure() {
- columnDef.setColumnMeta((MySQLColumnType.MYSQL_TYPE_ENUM.getValue() <<
8) + 3);
+
columnDef.setColumnMeta((MySQLBinaryColumnType.MYSQL_TYPE_ENUM.getValue() << 8)
+ 3);
new MySQLStringBinlogProtocolValue().read(columnDef, payload);
}
@Test
public void assertReadSetValue() {
- columnDef.setColumnMeta(MySQLColumnType.MYSQL_TYPE_SET.getValue() <<
8);
+
columnDef.setColumnMeta(MySQLBinaryColumnType.MYSQL_TYPE_SET.getValue() << 8);
when(payload.getByteBuf()).thenReturn(byteBuf);
when(byteBuf.readByte()).thenReturn((byte) 0xff);
assertThat(new MySQLStringBinlogProtocolValue().read(columnDef,
payload), is((byte) 0xff));
@@ -78,7 +78,7 @@ public final class MySQLStringBinlogProtocolValueTest {
@Test
public void assertReadStringValue() {
String expected = "test_value";
- columnDef.setColumnMeta(MySQLColumnType.MYSQL_TYPE_STRING.getValue()
<< 8);
+
columnDef.setColumnMeta(MySQLBinaryColumnType.MYSQL_TYPE_STRING.getValue() <<
8);
when(payload.getByteBuf()).thenReturn(byteBuf);
when(byteBuf.readUnsignedByte()).thenReturn((short) expected.length());
when(payload.readStringFix(expected.length())).thenReturn(expected);
@@ -88,7 +88,7 @@ public final class MySQLStringBinlogProtocolValueTest {
@Test
public void assertReadLongStringValue() {
String expected = "test_value";
- columnDef.setColumnMeta((MySQLColumnType.MYSQL_TYPE_STRING.getValue()
^ ((256 & 0x300) >> 4)) << 8);
+
columnDef.setColumnMeta((MySQLBinaryColumnType.MYSQL_TYPE_STRING.getValue() ^
((256 & 0x300) >> 4)) << 8);
when(payload.getByteBuf()).thenReturn(byteBuf);
when(byteBuf.readUnsignedShortLE()).thenReturn(expected.length());
when(payload.readStringFix(expected.length())).thenReturn(expected);
@@ -97,7 +97,7 @@ public final class MySQLStringBinlogProtocolValueTest {
@Test(expected = UnsupportedOperationException.class)
public void assertReadValueWithUnknownType() {
-
columnDef.setColumnMeta(MySQLColumnType.MYSQL_TYPE_VAR_STRING.getValue() << 8);
+
columnDef.setColumnMeta(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING.getValue()
<< 8);
new MySQLStringBinlogProtocolValue().read(columnDef, payload);
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
index 3027c5e..cfbf29a 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -44,7 +44,7 @@ public final class MySQLVarcharBinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_VARCHAR);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR);
}
@Test
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLDatetime2BinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLDatetime2BinlogProtocolValueTest.java
index d2a8af3..430231b 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLDatetime2BinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLDatetime2BinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.time;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -44,7 +44,7 @@ public final class MySQLDatetime2BinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_DATETIME2);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_DATETIME2);
}
@Test
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTime2BinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTime2BinlogProtocolValueTest.java
index c5a70ea..b2cd98f 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTime2BinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTime2BinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.time;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -44,7 +44,7 @@ public final class MySQLTime2BinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_TIME2);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_TIME2);
columnDef.setColumnMeta(0);
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTimestamp2BinlogProtocolValueTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTimestamp2BinlogProtocolValueTest.java
index 4cdd477..703598f 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTimestamp2BinlogProtocolValueTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/time/MySQLTimestamp2BinlogProtocolValueTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.time;
import io.netty.buffer.ByteBuf;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Before;
@@ -46,7 +46,7 @@ public final class MySQLTimestamp2BinlogProtocolValueTest {
@Before
public void setUp() {
- columnDef = new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_TIMESTAMP2);
+ columnDef = new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_TIMESTAMP2);
when(payload.getByteBuf()).thenReturn(byteBuf);
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41PacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41PacketTest.java
index 2b1b41b..ec51e81 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41PacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/MySQLColumnDefinition41PacketTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.db.protocol.mysql.packet.command.query;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerInfo;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Test;
@@ -60,7 +60,7 @@ public final class MySQLColumnDefinition41PacketTest {
@Test
public void assertWriteWithPayload() {
- when(payload.readInt1()).thenReturn(1,
MySQLColumnType.MYSQL_TYPE_LONG.getValue(), 0);
+ when(payload.readInt1()).thenReturn(1,
MySQLBinaryColumnType.MYSQL_TYPE_LONG.getValue(), 0);
when(payload.readInt2()).thenReturn(MySQLServerInfo.CHARSET, 0);
when(payload.readInt4()).thenReturn(10);
when(payload.readIntLenenc()).thenReturn(0x0cL);
@@ -79,7 +79,7 @@ public final class MySQLColumnDefinition41PacketTest {
verify(payload).writeIntLenenc(0x0c);
verify(payload).writeInt2(MySQLServerInfo.CHARSET);
verify(payload).writeInt4(10);
- verify(payload).writeInt1(MySQLColumnType.MYSQL_TYPE_LONG.getValue());
+
verify(payload).writeInt1(MySQLBinaryColumnType.MYSQL_TYPE_LONG.getValue());
verify(payload).writeInt2(0);
verify(payload).writeInt1(0);
verify(payload).writeReserved(2);
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacketTest.java
index ae8f8cc..e3b16a5 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/MySQLBinaryResultSetRowPacketTest.java
@@ -17,13 +17,13 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.Types;
import java.util.Arrays;
import static org.hamcrest.CoreMatchers.is;
@@ -38,7 +38,7 @@ public final class MySQLBinaryResultSetRowPacketTest {
@Test
public void assertWrite() {
- MySQLBinaryResultSetRowPacket actual = new
MySQLBinaryResultSetRowPacket(1, Arrays.asList("value", null),
Arrays.asList(MySQLColumnType.MYSQL_TYPE_STRING,
MySQLColumnType.MYSQL_TYPE_STRING));
+ MySQLBinaryResultSetRowPacket actual = new
MySQLBinaryResultSetRowPacket(1, Arrays.asList("value", null),
Arrays.asList(Types.CHAR, Types.CHAR));
assertThat(actual.getSequenceId(), is(1));
actual.write(payload);
verify(payload).writeInt1(0x00);
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLMySQLBinaryProtocolValueFactoryTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLMySQLBinaryProtocolValueFactoryTest.java
index c1a16ef..ab67bb4 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLMySQLBinaryProtocolValueFactoryTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLMySQLBinaryProtocolValueFactoryTest.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.protocol;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -29,132 +29,132 @@ public final class
MySQLMySQLBinaryProtocolValueFactoryTest {
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeString() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_STRING),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_STRING),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeVarchar() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_VARCHAR),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeVarString() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_VAR_STRING),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeEnum() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_ENUM),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_ENUM),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeSet() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_SET),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_SET),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeLongBlob() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_LONG_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_LONG_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeMediumBlob() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_MEDIUM_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_MEDIUM_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeBlob() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeTinyBlob() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_TINY_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_TINY_BLOB),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeGeometry() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_GEOMETRY),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_GEOMETRY),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeBit() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_BIT),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_BIT),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeDecimal() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_DECIMAL),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_DECIMAL),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeNewDecimal() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_NEWDECIMAL),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_NEWDECIMAL),
instanceOf(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeLongLong() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_LONGLONG),
instanceOf(MySQLInt8BinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_LONGLONG),
instanceOf(MySQLInt8BinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeLong() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_LONG),
instanceOf(MySQLInt4BinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_LONG),
instanceOf(MySQLInt4BinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeInt24() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_INT24),
instanceOf(MySQLInt4BinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_INT24),
instanceOf(MySQLInt4BinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeShort() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_SHORT),
instanceOf(MySQLInt2BinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_SHORT),
instanceOf(MySQLInt2BinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeYear() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_YEAR),
instanceOf(MySQLInt2BinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_YEAR),
instanceOf(MySQLInt2BinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeTiny() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_TINY),
instanceOf(MySQLInt1BinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_TINY),
instanceOf(MySQLInt1BinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeDouble() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_DOUBLE),
instanceOf(MySQLDoubleBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_DOUBLE),
instanceOf(MySQLDoubleBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeFloat() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_FLOAT),
instanceOf(MySQLFloatBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_FLOAT),
instanceOf(MySQLFloatBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeDate() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_DATE),
instanceOf(MySQLDateBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_DATE),
instanceOf(MySQLDateBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeDatetime() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_DATETIME),
instanceOf(MySQLDateBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_DATETIME),
instanceOf(MySQLDateBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeTimestamp() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_TIMESTAMP),
instanceOf(MySQLDateBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_TIMESTAMP),
instanceOf(MySQLDateBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeTime() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_TIME),
instanceOf(MySQLTimeBinaryProtocolValue.class));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_TIME),
instanceOf(MySQLTimeBinaryProtocolValue.class));
}
@Test
public void assertGetBinaryProtocolValueWithMySQLTypeNull() {
-
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLColumnType.MYSQL_TYPE_NULL),
is(nullValue()));
+
assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MYSQL_TYPE_NULL),
is(nullValue()));
}
@Test(expected = IllegalArgumentException.class)
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLColumnType.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLBinaryColumnType.java
similarity index 91%
rename from
shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLColumnType.java
rename to
shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLBinaryColumnType.java
index bb3a1c0..38336e0 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLColumnType.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLBinaryColumnType.java
@@ -19,17 +19,18 @@ package
org.apache.shardingsphere.db.protocol.postgresql.constant;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
/**
- * Column types for PostgreSQL.
+ * Binary column type for PostgreSQL.
*/
@RequiredArgsConstructor
@Getter
-public enum PostgreSQLColumnType {
+public enum PostgreSQLBinaryColumnType implements BinaryColumnType {
POSTGRESQL_TYPE_UNSPECIFIED(0),
@@ -151,7 +152,7 @@ public enum PostgreSQLColumnType {
POSTGRESQL_TYPE_REF_CURSOR_ARRAY(2201);
- private static final Map<Integer, PostgreSQLColumnType>
JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1);
+ private static final Map<Integer, PostgreSQLBinaryColumnType>
JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1);
private final int value;
@@ -179,7 +180,7 @@ public enum PostgreSQLColumnType {
* @param jdbcType JDBC type
* @return PostgreSQL column type enum
*/
- public static PostgreSQLColumnType valueOfJDBCType(final int jdbcType) {
+ public static PostgreSQLBinaryColumnType valueOfJDBCType(final int
jdbcType) {
if (JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType)) {
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}
@@ -192,8 +193,8 @@ public enum PostgreSQLColumnType {
* @param value value
* @return PostgreSQL column type
*/
- public static PostgreSQLColumnType valueOf(final int value) {
- for (PostgreSQLColumnType each : values()) {
+ public static PostgreSQLBinaryColumnType valueOf(final int value) {
+ for (PostgreSQLBinaryColumnType each : values()) {
if (value == each.value) {
return each;
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
index 00f9cf5..405c7c0 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLArrayColumnType;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
import java.sql.Types;
@@ -49,6 +49,6 @@ public final class PostgreSQLColumnDescription {
this.columnName = columnName;
this.columnIndex = columnIndex;
this.columnLength = columnLength;
- typeOID = Types.ARRAY == columnType ?
PostgreSQLArrayColumnType.getTypeOidByColumnTypeName(columnTypeName) :
PostgreSQLColumnType.valueOfJDBCType(columnType).getValue();
+ typeOID = Types.ARRAY == columnType ?
PostgreSQLArrayColumnType.getTypeOidByColumnTypeName(columnTypeName) :
PostgreSQLBinaryColumnType.valueOfJDBCType(columnType).getValue();
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementParameterType.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementParameterType.java
index 6d680d6..2f9698b 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementParameterType.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/PostgreSQLBinaryStatementParameterType.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bi
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
/**
* Bind parameter type for PostgreSQL.
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColum
@Getter
public final class PostgreSQLBinaryStatementParameterType {
- private final PostgreSQLColumnType columnType;
+ private final PostgreSQLBinaryColumnType columnType;
private final int format = 1;
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacket.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacket.java
index cc602ba..f818f2d 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacket.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacket.java
@@ -18,40 +18,50 @@
package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import org.apache.shardingsphere.db.protocol.binary.BinaryResultSetRow;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
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.payload.PostgreSQLPacketPayload;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
/**
* Binary result set row packet for PostgreSQL.
*/
-@RequiredArgsConstructor
public final class PostgreSQLBinaryResultSetRowPacket implements
PostgreSQLPacket {
@Getter
private final char messageType =
PostgreSQLCommandPacketType.DATA_ROW.getValue();
- @Getter
- private final List<Object> data;
+ private final Collection<BinaryResultSetRow> binaryRows;
- private final List<PostgreSQLColumnType> columnTypes;
+ public PostgreSQLBinaryResultSetRowPacket(final List<Object> data, final
List<Integer> columnTypes) {
+ binaryRows = getBinaryResultSetRows(columnTypes, data);
+ }
+
+ private Collection<BinaryResultSetRow> getBinaryResultSetRows(final
List<Integer> columnTypes, final List<Object> data) {
+ Collection<BinaryResultSetRow> result = new LinkedList<>();
+ for (int i = 0; i < columnTypes.size(); i++) {
+ result.add(new
BinaryResultSetRow(PostgreSQLBinaryColumnType.valueOfJDBCType(columnTypes.get(i)),
data.get(i)));
+ }
+ return result;
+ }
@Override
public void write(final PostgreSQLPacketPayload payload) {
- payload.writeInt2(data.size());
+ payload.writeInt2(binaryRows.size());
writeValues(payload);
}
private void writeValues(final PostgreSQLPacketPayload payload) {
- for (int i = 0; i < columnTypes.size(); i++) {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(columnTypes.get(i));
- Object value = data.get(i);
+ for (BinaryResultSetRow each : binaryRows) {
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(each.getColumnType());
+ Object value = each.getData();
payload.writeInt4(binaryProtocolValue.getColumnLength(value));
binaryProtocolValue.write(payload, 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/PostgreSQLBinaryProtocolValueFactory.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
index 625e3fc7..794e653 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
@@ -20,7 +20,8 @@ package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bi
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
import java.util.HashMap;
import java.util.Map;
@@ -31,7 +32,7 @@ import java.util.Map;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class PostgreSQLBinaryProtocolValueFactory {
- private static final Map<PostgreSQLColumnType,
PostgreSQLBinaryProtocolValue> BINARY_PROTOCOL_VALUES = new HashMap<>();
+ private static final Map<BinaryColumnType, PostgreSQLBinaryProtocolValue>
BINARY_PROTOCOL_VALUES = new HashMap<>();
static {
setUnspecifiedBinaryProtocolValue();
@@ -47,57 +48,57 @@ public final class PostgreSQLBinaryProtocolValueFactory {
private static void setUnspecifiedBinaryProtocolValue() {
PostgreSQLUnspecifiedBinaryProtocolValue binaryProtocolValue = new
PostgreSQLUnspecifiedBinaryProtocolValue();
-
BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_UNSPECIFIED,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_UNSPECIFIED,
binaryProtocolValue);
}
private static void setStringLenencBinaryProtocolValue() {
PostgreSQLStringBinaryProtocolValue binaryProtocolValue = new
PostgreSQLStringBinaryProtocolValue();
-
BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_VARCHAR,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_VARCHAR,
binaryProtocolValue);
}
private static void setInt8BinaryProtocolValue() {
PostgreSQLInt8BinaryProtocolValue binaryProtocolValue = new
PostgreSQLInt8BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8,
binaryProtocolValue);
}
private static void setInt4BinaryProtocolValue() {
PostgreSQLInt4BinaryProtocolValue binaryProtocolValue = new
PostgreSQLInt4BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_INT4,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT4,
binaryProtocolValue);
}
private static void setInt2BinaryProtocolValue() {
PostgreSQLInt2BinaryProtocolValue binaryProtocolValue = new
PostgreSQLInt2BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_INT2,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT2,
binaryProtocolValue);
}
private static void setDoubleBinaryProtocolValue() {
PostgreSQLDoubleBinaryProtocolValue binaryProtocolValue = new
PostgreSQLDoubleBinaryProtocolValue();
-
BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_FLOAT8,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_FLOAT8,
binaryProtocolValue);
}
private static void setFloatBinaryProtocolValue() {
PostgreSQLFloatBinaryProtocolValue binaryProtocolValue = new
PostgreSQLFloatBinaryProtocolValue();
-
BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_FLOAT4,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_FLOAT4,
binaryProtocolValue);
}
private static void setDateBinaryProtocolValue() {
PostgreSQLDateBinaryProtocolValue binaryProtocolValue = new
PostgreSQLDateBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_DATE,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_DATE,
binaryProtocolValue);
}
private static void setTimeBinaryProtocolValue() {
PostgreSQLTimeBinaryProtocolValue binaryProtocolValue = new
PostgreSQLTimeBinaryProtocolValue();
-
BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.POSTGRESQL_TYPE_TIMESTAMP,
binaryProtocolValue);
+
BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_TIMESTAMP,
binaryProtocolValue);
}
/**
* Get binary protocol value.
*
- * @param columnType column type
+ * @param binaryColumnType binary column type
* @return binary protocol value
*/
- public static PostgreSQLBinaryProtocolValue getBinaryProtocolValue(final
PostgreSQLColumnType columnType) {
-
Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(columnType),
"Cannot find PostgreSQL type '%s' in column type when process binary protocol
value", columnType);
- return BINARY_PROTOCOL_VALUES.get(columnType);
+ public static PostgreSQLBinaryProtocolValue getBinaryProtocolValue(final
BinaryColumnType binaryColumnType) {
+
Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(binaryColumnType),
"Cannot find PostgreSQL type '%s' in column type when process binary protocol
value", binaryColumnType);
+ return BINARY_PROTOCOL_VALUES.get(binaryColumnType);
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
index 343ab77..911bf55 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacket.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bi
import lombok.Getter;
import lombok.ToString;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
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.PostgreSQLBinaryStatementParameterType;
@@ -53,7 +53,7 @@ public final class PostgreSQLComParsePacket extends
PostgreSQLCommandPacket {
int parameterCount = payload.readInt2();
List<PostgreSQLBinaryStatementParameterType> result = new
ArrayList<>(parameterCount);
for (int i = 0; i < parameterCount; i++) {
- result.add(new
PostgreSQLBinaryStatementParameterType(PostgreSQLColumnType.valueOf(payload.readInt4())));
+ result.add(new
PostgreSQLBinaryStatementParameterType(PostgreSQLBinaryColumnType.valueOf(payload.readInt4())));
}
return result;
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLColumnTypeTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLBinaryColumnTypeTest.java
similarity index 66%
rename from
shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLColumnTypeTest.java
rename to
shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLBinaryColumnTypeTest.java
index 8347545..fed8992 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLColumnTypeTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLBinaryColumnTypeTest.java
@@ -24,32 +24,32 @@ import java.sql.Types;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class PostgreSQLColumnTypeTest {
+public final class PostgreSQLBinaryColumnTypeTest {
@Test
public void assertValueOfJDBCType() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BIGINT);
- assertThat(sqlColumnType,
is(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8));
+ PostgreSQLBinaryColumnType sqlColumnType =
PostgreSQLBinaryColumnType.valueOfJDBCType(Types.BIGINT);
+ assertThat(sqlColumnType,
is(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8));
}
@Test(expected = IllegalArgumentException.class)
public void assertValueOfJDBCTypeExThrown() {
- PostgreSQLColumnType.valueOfJDBCType(Types.REF_CURSOR);
+ PostgreSQLBinaryColumnType.valueOfJDBCType(Types.REF_CURSOR);
}
@Test
public void assertValueOf() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOf(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8.getValue());
- assertThat(sqlColumnType,
is(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8));
+ PostgreSQLBinaryColumnType sqlColumnType =
PostgreSQLBinaryColumnType.valueOf(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8.getValue());
+ assertThat(sqlColumnType,
is(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8));
}
@Test(expected = IllegalArgumentException.class)
public void assertValueOfExThrown() {
- PostgreSQLColumnType.valueOf(9999);
+ PostgreSQLBinaryColumnType.valueOf(9999);
}
@Test
public void assertGetValue() {
- assertThat(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8.getValue(),
is(20));
+ assertThat(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8.getValue(),
is(20));
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacketTest.java
index 97100a9..23f5896 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/PostgreSQLBinaryResultSetRowPacketTest.java
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
@@ -25,6 +24,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import java.sql.Types;
import java.util.Arrays;
import java.util.Collections;
@@ -40,9 +40,7 @@ public final class PostgreSQLBinaryResultSetRowPacketTest {
@Test
public void assertWriteStringData() {
- PostgreSQLBinaryResultSetRowPacket rowPacket = new
PostgreSQLBinaryResultSetRowPacket(Arrays.asList("value", "b"),
- Arrays.asList(PostgreSQLColumnType.POSTGRESQL_TYPE_VARCHAR,
PostgreSQLColumnType.POSTGRESQL_TYPE_VARCHAR));
- assertThat(rowPacket.getData().size(), is(2));
+ PostgreSQLBinaryResultSetRowPacket rowPacket = new
PostgreSQLBinaryResultSetRowPacket(Arrays.asList("value", "b"),
Arrays.asList(Types.VARCHAR, Types.VARCHAR));
rowPacket.write(payload);
verify(payload).writeInt2(2);
verify(payload).writeInt4(5);
@@ -53,8 +51,7 @@ public final class PostgreSQLBinaryResultSetRowPacketTest {
@Test
public void assertWriteIntData() {
- PostgreSQLBinaryResultSetRowPacket rowPacket = new
PostgreSQLBinaryResultSetRowPacket(Collections.singletonList(10),
Collections.singletonList(PostgreSQLColumnType.POSTGRESQL_TYPE_INT4));
- assertThat(rowPacket.getData().size(), is(1));
+ PostgreSQLBinaryResultSetRowPacket rowPacket = new
PostgreSQLBinaryResultSetRowPacket(Collections.singletonList(10),
Collections.singletonList(Types.INTEGER));
rowPacket.write(payload);
verify(payload).writeInt2(1);
verify(payload).writeInt4(4);
@@ -63,8 +60,7 @@ public final class PostgreSQLBinaryResultSetRowPacketTest {
@Test
public void assertGetMessageType() {
- PostgreSQLBinaryResultSetRowPacket rowPacket = new
PostgreSQLBinaryResultSetRowPacket(null, null);
+ PostgreSQLBinaryResultSetRowPacket rowPacket = new
PostgreSQLBinaryResultSetRowPacket(Collections.emptyList(),
Collections.emptyList());
assertThat(rowPacket.getMessageType(),
is(PostgreSQLCommandPacketType.DATA_ROW.getValue()));
}
-
}
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 43eaf67..54d7759 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
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.BinaryStatementRegistry;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementParameterType;
@@ -57,7 +57,7 @@ public final class PostgreSQLComBindPacketTest {
when(payload.readInt4()).thenReturn(1);
when(payload.readInt8()).thenReturn(11L);
String sql = "select * from order where id = ? ";
- BinaryStatementRegistry.getInstance().get(1).register("sts-id", sql,
1, Collections.singletonList(new
PostgreSQLBinaryStatementParameterType(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8)));
+ BinaryStatementRegistry.getInstance().get(1).register("sts-id", sql,
1, Collections.singletonList(new
PostgreSQLBinaryStatementParameterType(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8)));
PostgreSQLComBindPacket bindPacket = new
PostgreSQLComBindPacket(payload, 1);
bindPacket.write(payload);
assertThat(bindPacket.getSql(), is(sql));
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/PostgreSQLBinaryProtocolValueFactoryTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
index 2b42a1e..2f6408c 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.bind.protocol;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -27,54 +27,54 @@ public final class PostgreSQLBinaryProtocolValueFactoryTest
{
@Test
public void assertGetStringBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_VARCHAR);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_VARCHAR);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLStringBinaryProtocolValue.class));
}
@Test
public void assertGetInt8BinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT8);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLInt8BinaryProtocolValue.class));
}
@Test
public void assertGetInt4BinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_INT4);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT4);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLInt4BinaryProtocolValue.class));
}
@Test
public void assertGetInt2BinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_INT2);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_INT2);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLInt2BinaryProtocolValue.class));
}
@Test
public void assertGetDoubleBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_FLOAT8);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_FLOAT8);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLDoubleBinaryProtocolValue.class));
}
@Test
public void assertGetFloatBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_FLOAT4);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_FLOAT4);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLFloatBinaryProtocolValue.class));
}
@Test
public void assertGetDateBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_DATE);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_DATE);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLDateBinaryProtocolValue.class));
}
@Test
public void assertGetTimeBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_TIMESTAMP);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_TIMESTAMP);
assertThat(binaryProtocolValue,
instanceOf(PostgreSQLTimeBinaryProtocolValue.class));
}
@Test(expected = IllegalArgumentException.class)
public void assertGetBinaryProtocolValueExThrown() {
-
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.POSTGRESQL_TYPE_XML);
+
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_XML);
}
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacketTest.java
index 665fcc2..7a9d3ec 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/parse/PostgreSQLComParsePacketTest.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
+import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.PostgreSQLBinaryStatementParameterType;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
@@ -53,7 +53,7 @@ public final class PostgreSQLComParsePacketTest {
List<PostgreSQLBinaryStatementParameterType> types =
actual.getBinaryStatementParameterTypes();
assertNotNull(types);
assertThat(types.size(), equalTo(1));
- assertThat(types.get(0).getColumnType(),
is(PostgreSQLColumnType.POSTGRESQL_TYPE_UNSPECIFIED));
+ assertThat(types.get(0).getColumnType(),
is(PostgreSQLBinaryColumnType.POSTGRESQL_TYPE_UNSPECIFIED));
assertTrue(actual.toString().startsWith("PostgreSQLComParsePacket(statementId=sql,
sql=sql, binaryStatementParameterTypes=["));
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/impl/QueryHeaderBuilder.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/impl/QueryHeaderBuilder.java
index 96a75f3..565aaf0 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/impl/QueryHeaderBuilder.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/impl/QueryHeaderBuilder.java
@@ -31,7 +31,7 @@ import java.sql.SQLException;
import java.util.Optional;
/**
- * Query header.
+ * Query header builder.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class QueryHeaderBuilder {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
index 1675f40..5f4fd53 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
@@ -18,7 +18,6 @@
package
org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.execute;
import lombok.Getter;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLBinaryResultSetRowPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLComStmtExecutePacket;
@@ -29,8 +28,8 @@ import
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicati
import
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngineFactory;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseData;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
import
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import
org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
@@ -40,7 +39,6 @@ import
org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.stream.Collectors;
/**
* COM_STMT_EXECUTE command executor for MySQL.
@@ -87,6 +85,6 @@ public final class MySQLComStmtExecuteExecutor implements
QueryCommandExecutor {
@Override
public MySQLPacket getQueryData() throws SQLException {
QueryResponseData queryData =
databaseCommunicationEngine.getQueryResponseData();
- return new MySQLBinaryResultSetRowPacket(++currentSequenceId,
queryData.getData(),
queryData.getColumnTypes().stream().map(MySQLColumnType::valueOfJDBCType).collect(Collectors.toList()));
+ return new MySQLBinaryResultSetRowPacket(++currentSequenceId,
queryData.getData(), queryData.getColumnTypes());
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
index e13ed30..cc707f9 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.prepare;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLColumnDefinition41Packet;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.MySQLBinaryStatementRegistry;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.prepare.MySQLComStmtPrepareOKPacket;
@@ -81,7 +81,7 @@ public final class MySQLComStmtPrepareExecutor implements
CommandExecutor {
private Collection<DatabasePacket<?>>
createParameterColumnDefinition41Packets(final int parameterCount) {
Collection<DatabasePacket<?>> result = new LinkedList<>();
for (int i = 0; i < parameterCount; i++) {
- result.add(new MySQLColumnDefinition41Packet(++currentSequenceId,
"", "", "", "?", "", 0, MySQLColumnType.MYSQL_TYPE_VAR_STRING, 0));
+ result.add(new MySQLColumnDefinition41Packet(++currentSequenceId,
"", "", "", "?", "", 0, MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING, 0));
}
result.add(new MySQLEofPacket(++currentSequenceId));
return result;
@@ -90,7 +90,7 @@ public final class MySQLComStmtPrepareExecutor implements
CommandExecutor {
private Collection<DatabasePacket<?>>
createProjectionColumnDefinition41Packets(final int projectionCount) {
Collection<DatabasePacket<?>> result = new LinkedList<>();
for (int i = 0; i < projectionCount; i++) {
- result.add(new MySQLColumnDefinition41Packet(++currentSequenceId,
"", "", "", "", "", 0, MySQLColumnType.MYSQL_TYPE_VAR_STRING, 0));
+ result.add(new MySQLColumnDefinition41Packet(++currentSequenceId,
"", "", "", "", "", 0, MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING, 0));
}
result.add(new MySQLEofPacket(++currentSequenceId));
return result;
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
index 4816981..d6842ff 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLColumnDefinition41Packet;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLColumnFieldDetailFlag;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLFieldCountPacket;
@@ -54,7 +54,7 @@ public final class ResponsePacketBuilder {
result.add(new MySQLFieldCountPacket(++sequenceId,
queryHeader.size()));
for (QueryHeader each : queryHeader) {
result.add(new MySQLColumnDefinition41Packet(++sequenceId,
getColumnFieldDetailFlag(each), each.getSchema(), each.getTable(),
each.getTable(),
- each.getColumnLabel(), each.getColumnName(),
each.getColumnLength(), MySQLColumnType.valueOfJDBCType(each.getColumnType()),
each.getDecimals()));
+ each.getColumnLabel(), each.getColumnName(),
each.getColumnLength(),
MySQLBinaryColumnType.valueOfJDBCType(each.getColumnType()),
each.getDecimals()));
}
result.add(new MySQLEofPacket(++sequenceId));
return result;
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
index 0a0c799..d7ddea5 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.fieldlist;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLColumnDefinition41Packet;
import
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.fieldlist.MySQLComFieldListPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLEofPacket;
@@ -70,7 +70,8 @@ public final class MySQLComFieldListPacketExecutor implements
CommandExecutor {
Collection<DatabasePacket<?>> result = new LinkedList<>();
while (databaseCommunicationEngine.next()) {
String columnName =
databaseCommunicationEngine.getQueryResponseData().getData().get(0).toString();
- result.add(new MySQLColumnDefinition41Packet(++currentSequenceId,
schemaName, packet.getTable(), packet.getTable(), columnName, columnName, 100,
MySQLColumnType.MYSQL_TYPE_VARCHAR, 0));
+ result.add(new MySQLColumnDefinition41Packet(
+ ++currentSequenceId, schemaName, packet.getTable(),
packet.getTable(), columnName, columnName, 100,
MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR, 0));
}
result.add(new MySQLEofPacket(++currentSequenceId));
return result;
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
index 9d3150c..0fbdf51 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
@@ -19,7 +19,6 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary
import lombok.Getter;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLColumnType;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
@@ -49,7 +48,6 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
-import java.util.stream.Collectors;
/**
* Command bind executor for PostgreSQL.
@@ -126,8 +124,6 @@ public final class PostgreSQLComBindExecutor implements
QueryCommandExecutor {
@Override
public PostgreSQLPacket getQueryData() throws SQLException {
QueryResponseData queryData =
databaseCommunicationEngine.getQueryResponseData();
- return packet.isBinaryRowData()
- ? new PostgreSQLBinaryResultSetRowPacket(queryData.getData(),
queryData.getColumnTypes().stream().map(PostgreSQLColumnType::valueOfJDBCType).collect(Collectors.toList()))
- : new PostgreSQLDataRowPacket(queryData.getData());
+ return packet.isBinaryRowData() ? new
PostgreSQLBinaryResultSetRowPacket(queryData.getData(),
queryData.getColumnTypes()) : new PostgreSQLDataRowPacket(queryData.getData());
}
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/binlog/BinlogContextTest.java
b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/binlog/BinlogContextTest.java
index 0512526..dd9529d 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/binlog/BinlogContextTest.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/binlog/BinlogContextTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.scaling.mysql.binlog;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLColumnType;
+import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.MySQLBinlogTableMapEventPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.junit.Before;
@@ -70,7 +70,7 @@ public final class BinlogContextTest {
public void assertGetColumnDefs() {
binlogContext.putTableMapEvent(TEST_TABLE_ID, tableMapEventPacket);
List<MySQLBinlogColumnDef> columnDefs = new ArrayList<>(1);
- columnDefs.add(new
MySQLBinlogColumnDef(MySQLColumnType.MYSQL_TYPE_LONG));
+ columnDefs.add(new
MySQLBinlogColumnDef(MySQLBinaryColumnType.MYSQL_TYPE_LONG));
when(tableMapEventPacket.getColumnDefs()).thenReturn(columnDefs);
assertThat(binlogContext.getColumnDefs(TEST_TABLE_ID), is(columnDefs));
}