This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 6e56e4de06a Rename PostgreSQLColumnType to PostgreSQLBinaryColumnType
(#38208)
6e56e4de06a is described below
commit 6e56e4de06a2593d551bbd7d409833a8d78d1e41
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Feb 26 14:46:18 2026 +0800
Rename PostgreSQLColumnType to PostgreSQLBinaryColumnType (#38208)
---
.../command/bind/OpenGaussComBatchBindPacket.java | 10 +-
.../bind/OpenGaussComBatchBindPacketTest.java | 12 +-
.../command/query/PostgreSQLColumnDescription.java | 4 +-
.../PostgreSQLParameterDescriptionPacket.java | 6 +-
...mnType.java => PostgreSQLBinaryColumnType.java} | 14 +-
.../extended/bind/PostgreSQLComBindPacket.java | 8 +-
.../PostgreSQLBinaryProtocolValueFactory.java | 48 +++---
.../extended/parse/PostgreSQLComParsePacket.java | 8 +-
.../command/query/PostgreSQLDataRowPacketTest.java | 6 +-
.../PostgreSQLParameterDescriptionPacketTest.java | 10 +-
.../extended/PostgreSQLBinaryColumnTypeTest.java | 135 ++++++++++++++++
.../query/extended/PostgreSQLColumnTypeTest.java | 171 ---------------------
.../extended/bind/PostgreSQLComBindPacketTest.java | 4 +-
.../PostgreSQLBinaryProtocolValueFactoryTest.java | 26 ++--
.../parse/PostgreSQLComParsePacketTest.java | 6 +-
.../ddl/column/PostgreSQLColumnTypeTest.java | 28 ++--
.../postgresql/command/query/extended/Portal.java | 8 +-
...AggregatedBatchedStatementsCommandExecutor.java | 4 +-
.../PostgreSQLServerPreparedStatement.java | 4 +-
.../describe/PostgreSQLComDescribeExecutor.java | 14 +-
.../extended/parse/PostgreSQLComParseExecutor.java | 10 +-
.../command/query/extended/PortalTest.java | 6 +-
...egatedBatchedStatementsCommandExecutorTest.java | 6 +-
.../PostgreSQLBatchedStatementsExecutorTest.java | 10 +-
.../PostgreSQLServerPreparedStatementTest.java | 4 +-
.../bind/PostgreSQLComBindExecutorTest.java | 4 +-
.../PostgreSQLComDescribeExecutorTest.java | 60 ++++----
.../parse/PostgreSQLComParseExecutorTest.java | 10 +-
28 files changed, 302 insertions(+), 334 deletions(-)
diff --git
a/database/protocol/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacket.java
b/database/protocol/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacket.java
index 5f35e19376c..b42669bc245 100644
---
a/database/protocol/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacket.java
+++
b/database/protocol/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacket.java
@@ -22,7 +22,7 @@ import
org.apache.shardingsphere.database.protocol.opengauss.packet.command.Open
import
org.apache.shardingsphere.database.protocol.opengauss.packet.command.OpenGaussCommandPacketType;
import
org.apache.shardingsphere.database.protocol.opengauss.packet.identifier.OpenGaussIdentifierTag;
import
org.apache.shardingsphere.database.protocol.postgresql.constant.PostgreSQLValueFormat;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValue;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValueFactory;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
@@ -73,7 +73,7 @@ public final class OpenGaussComBatchBindPacket extends
OpenGaussCommandPacket {
* @param parameterTypes types of parameters
* @return parameter sets
*/
- public List<List<Object>> readParameterSets(final
List<PostgreSQLColumnType> parameterTypes) {
+ public List<List<Object>> readParameterSets(final
List<PostgreSQLBinaryColumnType> parameterTypes) {
List<List<Object>> result = new ArrayList<>(batchNum);
for (int i = 0; i < batchNum; i++) {
result.add(readOneGroupOfParameters(parameterTypes));
@@ -82,7 +82,7 @@ public final class OpenGaussComBatchBindPacket extends
OpenGaussCommandPacket {
return result;
}
- private List<Object> readOneGroupOfParameters(final
List<PostgreSQLColumnType> parameterTypes) {
+ private List<Object> readOneGroupOfParameters(final
List<PostgreSQLBinaryColumnType> parameterTypes) {
List<Object> result = new ArrayList<>(eachGroupParametersCount);
for (int paramIndex = 0; paramIndex < eachGroupParametersCount;
paramIndex++) {
int paramValueLength = payload.readInt4();
@@ -102,12 +102,12 @@ public final class OpenGaussComBatchBindPacket extends
OpenGaussCommandPacket {
return parameterFormats.isEmpty() || 0 ==
parameterFormats.get(paramIndex % parameterFormats.size());
}
- private Object getTextParameters(final int paramValueLength, final
PostgreSQLColumnType paramType) {
+ private Object getTextParameters(final int paramValueLength, final
PostgreSQLBinaryColumnType paramType) {
String value = payload.getByteBuf().readCharSequence(paramValueLength,
payload.getCharset()).toString();
return paramType.getTextValueParser().parse(value);
}
- private Object getBinaryParameters(final int paramValueLength, final
PostgreSQLColumnType columnType) {
+ private Object getBinaryParameters(final int paramValueLength, final
PostgreSQLBinaryColumnType columnType) {
PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(columnType);
return binaryProtocolValue.read(payload, paramValueLength);
}
diff --git
a/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacketTest.java
b/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacketTest.java
index 144177c3e49..9ff20a3ff72 100644
---
a/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacketTest.java
+++
b/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/bind/OpenGaussComBatchBindPacketTest.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.database.protocol.opengauss.packet.command.bin
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import
org.apache.shardingsphere.database.protocol.opengauss.packet.command.OpenGaussCommandPacketType;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -67,7 +67,7 @@ class OpenGaussComBatchBindPacketTest {
assertThat(actual.getEachGroupParametersCount(), is(3));
assertThat(actual.getParameterFormats(), is(Arrays.asList(0, 0, 0)));
assertTrue(actual.getResultFormats().isEmpty());
- List<List<Object>> actualParameterSets =
actual.readParameterSets(Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.VARCHAR, PostgreSQLColumnType.INT4));
+ List<List<Object>> actualParameterSets =
actual.readParameterSets(Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR, PostgreSQLBinaryColumnType.INT4));
assertThat(actualParameterSets.size(), is(3));
assertThat(actualParameterSets, is(Arrays.asList(Arrays.asList(1,
"Foo", 18), Arrays.asList(2, "Bar", 36), Arrays.asList(3, "Tom", 54))));
}
@@ -75,7 +75,7 @@ class OpenGaussComBatchBindPacketTest {
@ParameterizedTest(name = "{0}")
@MethodSource("readParameterSetsCases")
void assertReadParameterSets(final String name, final
OpenGaussComBatchBindPacket packet, final PostgreSQLPacketPayload payload,
- final List<PostgreSQLColumnType>
parameterTypes, final List<List<Object>> expectedParameterSets, final int
expectedSkipReservedBytes) {
+ final List<PostgreSQLBinaryColumnType>
parameterTypes, final List<List<Object>> expectedParameterSets, final int
expectedSkipReservedBytes) {
List<List<Object>> actualParameterSets =
packet.readParameterSets(parameterTypes);
assertThat(actualParameterSets, is(expectedParameterSets));
verify(payload).skipReserved(expectedSkipReservedBytes);
@@ -124,11 +124,11 @@ class OpenGaussComBatchBindPacketTest {
OpenGaussComBatchBindPacket emptyFormatPacket = new
OpenGaussComBatchBindPacket(emptyFormatPayload);
OpenGaussComBatchBindPacket binaryPacket = new
OpenGaussComBatchBindPacket(binaryPayload);
return Stream.of(
- Arguments.of("textParametersWithSingleTextFormat", textPacket,
textPayload, Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.VARCHAR),
+ Arguments.of("textParametersWithSingleTextFormat", textPacket,
textPayload, Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR),
Collections.singletonList(Arrays.asList(7, "foo")), 6),
- Arguments.of("textParametersWhenFormatListIsEmpty",
emptyFormatPacket, emptyFormatPayload,
Collections.singletonList(PostgreSQLColumnType.INT4),
+ Arguments.of("textParametersWhenFormatListIsEmpty",
emptyFormatPacket, emptyFormatPayload,
Collections.singletonList(PostgreSQLBinaryColumnType.INT4),
Collections.singletonList(Collections.singletonList(42)), 0),
- Arguments.of("nullAndBinaryParameters", binaryPacket,
binaryPayload, Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.INT4),
+ Arguments.of("nullAndBinaryParameters", binaryPacket,
binaryPayload, Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.INT4),
Collections.singletonList(Arrays.asList(null, 9)), 3));
}
diff --git
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
index fe4ee4caef1..2c6d16729a0 100644
---
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
+++
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLColumnDescription.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.qu
import lombok.Getter;
import
org.apache.shardingsphere.database.protocol.postgresql.constant.PostgreSQLArrayColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.constant.PostgreSQLValueFormat;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import java.sql.Types;
@@ -53,6 +53,6 @@ public final class PostgreSQLColumnDescription {
this.columnIndex = columnIndex;
this.columnLength = columnLength;
this.dataFormat = dataFormat;
- typeOID = Types.ARRAY == columnType ?
PostgreSQLArrayColumnType.getTypeOid(columnTypeName) :
PostgreSQLColumnType.valueOfJDBCType(columnType, columnTypeName).getValue();
+ typeOID = Types.ARRAY == columnType ?
PostgreSQLArrayColumnType.getTypeOid(columnTypeName) :
PostgreSQLBinaryColumnType.valueOfJDBCType(columnType,
columnTypeName).getValue();
}
}
diff --git
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacket.java
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacket.java
index 83f599cd97a..5c048f2bfeb 100644
---
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacket.java
+++
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacket.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query;
import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLIdentifierPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
@@ -32,12 +32,12 @@ import java.util.List;
@RequiredArgsConstructor
public final class PostgreSQLParameterDescriptionPacket extends
PostgreSQLIdentifierPacket {
- private final List<PostgreSQLColumnType> parameterTypes;
+ private final List<PostgreSQLBinaryColumnType> parameterTypes;
@Override
protected void write(final PostgreSQLPacketPayload payload) {
payload.writeInt2(parameterTypes.size());
- for (PostgreSQLColumnType each : parameterTypes) {
+ for (PostgreSQLBinaryColumnType each : parameterTypes) {
payload.writeInt4(each.getValue());
}
}
diff --git
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLBinaryColumnType.java
similarity index 95%
rename from
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
rename to
database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLBinaryColumnType.java
index 515cff27520..bab8896370a 100644
---
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
+++
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLBinaryColumnType.java
@@ -44,11 +44,11 @@ import java.util.HashMap;
import java.util.Map;
/**
- * Column type for PostgreSQL.
+ * Binary column type for PostgreSQL.
*/
@RequiredArgsConstructor
@Getter
-public enum PostgreSQLColumnType implements BinaryColumnType {
+public enum PostgreSQLBinaryColumnType implements BinaryColumnType {
UNSPECIFIED(0, new PostgreSQLUnspecifiedValueParser()),
@@ -170,7 +170,7 @@ public enum PostgreSQLColumnType implements
BinaryColumnType {
REF_CURSOR_ARRAY(2201, new PostgreSQLVarcharValueParser());
- private static final Map<Integer, PostgreSQLColumnType>
JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1F);
+ private static final Map<Integer, PostgreSQLBinaryColumnType>
JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1F);
private final int value;
@@ -206,7 +206,7 @@ public enum PostgreSQLColumnType implements
BinaryColumnType {
* @param jdbcType JDBC type
* @return PostgreSQL column type enum
*/
- public static PostgreSQLColumnType valueOfJDBCType(final int jdbcType) {
+ public static PostgreSQLBinaryColumnType valueOfJDBCType(final int
jdbcType) {
Preconditions.checkArgument(JDBC_TYPE_AND_COLUMN_TYPE_MAP.containsKey(jdbcType),
"Can not find JDBC type `%s` in PostgreSQL column type", jdbcType);
return JDBC_TYPE_AND_COLUMN_TYPE_MAP.get(jdbcType);
}
@@ -218,7 +218,7 @@ public enum PostgreSQLColumnType implements
BinaryColumnType {
* @param columnTypeName column type name
* @return PostgreSQL column type enum
*/
- public static PostgreSQLColumnType valueOfJDBCType(final int jdbcType,
final String columnTypeName) {
+ public static PostgreSQLBinaryColumnType valueOfJDBCType(final int
jdbcType, final String columnTypeName) {
if (isBit(jdbcType, columnTypeName)) {
return BIT;
}
@@ -271,8 +271,8 @@ public enum PostgreSQLColumnType implements
BinaryColumnType {
* @return PostgreSQL column type
* @throws PostgreSQLProtocolException PostgreSQL protocol exception
*/
- 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/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
index a7c18749ccb..4479f03b084 100644
---
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
+++
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
@@ -21,7 +21,7 @@ import lombok.Getter;
import
org.apache.shardingsphere.database.protocol.postgresql.constant.PostgreSQLValueFormat;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValue;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValueFactory;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
@@ -57,7 +57,7 @@ public final class PostgreSQLComBindPacket extends
PostgreSQLCommandPacket {
* @param paramTypes parameter types
* @return values of parameter
*/
- public List<Object> readParameters(final List<PostgreSQLColumnType>
paramTypes) {
+ public List<Object> readParameters(final List<PostgreSQLBinaryColumnType>
paramTypes) {
List<Integer> paramFormats = getParameterFormats();
int parameterCount = payload.readInt2();
List<Object> result = new ArrayList<>(parameterCount);
@@ -91,12 +91,12 @@ public final class PostgreSQLComBindPacket extends
PostgreSQLCommandPacket {
return PostgreSQLValueFormat.TEXT.getCode() == paramFormats.get(1 ==
paramFormats.size() ? 0 : paramIndex);
}
- private Object getTextParameterValue(final PostgreSQLPacketPayload
payload, final int paramValueLength, final PostgreSQLColumnType paramType) {
+ private Object getTextParameterValue(final PostgreSQLPacketPayload
payload, final int paramValueLength, final PostgreSQLBinaryColumnType
paramType) {
String value = payload.getByteBuf().readCharSequence(paramValueLength,
payload.getCharset()).toString();
return paramType.getTextValueParser().parse(value);
}
- private Object getBinaryParameterValue(final PostgreSQLPacketPayload
payload, final int paramValueLength, final PostgreSQLColumnType paramType) {
+ private Object getBinaryParameterValue(final PostgreSQLPacketPayload
payload, final int paramValueLength, final PostgreSQLBinaryColumnType
paramType) {
PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(paramType);
return binaryProtocolValue.read(payload, paramValueLength);
}
diff --git
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
index 984f7dd86fa..ac7410b89f5 100644
---
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
+++
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactory.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.database.protocol.binary.BinaryColumnType;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import java.util.HashMap;
import java.util.Map;
@@ -59,95 +59,95 @@ public final class PostgreSQLBinaryProtocolValueFactory {
private static void setUnspecifiedBinaryProtocolValue() {
PostgreSQLUnspecifiedBinaryProtocolValue binaryProtocolValue = new
PostgreSQLUnspecifiedBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.UNSPECIFIED,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.UNSPECIFIED,
binaryProtocolValue);
}
private static void setStringLenencBinaryProtocolValue() {
PostgreSQLStringBinaryProtocolValue binaryProtocolValue = new
PostgreSQLStringBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.VARCHAR,
binaryProtocolValue);
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.CHAR,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.VARCHAR,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.CHAR,
binaryProtocolValue);
}
private static void setInt8BinaryProtocolValue() {
PostgreSQLInt8BinaryProtocolValue binaryProtocolValue = new
PostgreSQLInt8BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.INT8,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.INT8,
binaryProtocolValue);
}
private static void setInt4BinaryProtocolValue() {
PostgreSQLInt4BinaryProtocolValue binaryProtocolValue = new
PostgreSQLInt4BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.INT4,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.INT4,
binaryProtocolValue);
}
private static void setInt2BinaryProtocolValue() {
PostgreSQLInt2BinaryProtocolValue binaryProtocolValue = new
PostgreSQLInt2BinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.INT2,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.INT2,
binaryProtocolValue);
}
private static void setDoubleBinaryProtocolValue() {
PostgreSQLDoubleBinaryProtocolValue binaryProtocolValue = new
PostgreSQLDoubleBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.FLOAT8,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.FLOAT8,
binaryProtocolValue);
}
private static void setFloatBinaryProtocolValue() {
PostgreSQLFloatBinaryProtocolValue binaryProtocolValue = new
PostgreSQLFloatBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.FLOAT4,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.FLOAT4,
binaryProtocolValue);
}
private static void setNumericBinaryProtocolValue() {
PostgreSQLNumericBinaryProtocolValue binaryProtocolValue = new
PostgreSQLNumericBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.NUMERIC,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.NUMERIC,
binaryProtocolValue);
}
private static void setDateBinaryProtocolValue() {
PostgreSQLDateBinaryProtocolValue binaryProtocolValue = new
PostgreSQLDateBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.DATE,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.DATE,
binaryProtocolValue);
}
private static void setTimeBinaryProtocolValue() {
PostgreSQLTimeBinaryProtocolValue binaryProtocolValue = new
PostgreSQLTimeBinaryProtocolValue();
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.TIMESTAMP,
binaryProtocolValue);
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.TIMESTAMP,
binaryProtocolValue);
}
private static void setInt2ArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.INT2_ARRAY, new
PostgreSQLInt2ArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.INT2_ARRAY, new
PostgreSQLInt2ArrayBinaryProtocolValue());
}
private static void setInt4ArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.INT4_ARRAY, new
PostgreSQLInt4ArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.INT4_ARRAY, new
PostgreSQLInt4ArrayBinaryProtocolValue());
}
private static void setInt8ArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.INT8_ARRAY, new
PostgreSQLInt8ArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.INT8_ARRAY, new
PostgreSQLInt8ArrayBinaryProtocolValue());
}
private static void setFloat4ArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.FLOAT4_ARRAY, new
PostgreSQLFloat4ArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.FLOAT4_ARRAY,
new PostgreSQLFloat4ArrayBinaryProtocolValue());
}
private static void setFloat8ArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.FLOAT8_ARRAY, new
PostgreSQLFloat8ArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.FLOAT8_ARRAY,
new PostgreSQLFloat8ArrayBinaryProtocolValue());
}
private static void setBoolArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.BOOL_ARRAY, new
PostgreSQLBoolArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.BOOL_ARRAY, new
PostgreSQLBoolArrayBinaryProtocolValue());
}
private static void setStringArrayBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.VARCHAR_ARRAY, new
PostgreSQLStringArrayBinaryProtocolValue());
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.CHAR_ARRAY, new
PostgreSQLStringArrayBinaryProtocolValue());
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.TEXT_ARRAY, new
PostgreSQLTextArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.VARCHAR_ARRAY,
new PostgreSQLStringArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.CHAR_ARRAY, new
PostgreSQLStringArrayBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.TEXT_ARRAY, new
PostgreSQLTextArrayBinaryProtocolValue());
}
private static void setByteaBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.BYTEA, new
PostgreSQLByteaBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.BYTEA, new
PostgreSQLByteaBinaryProtocolValue());
}
private static void setUUIDBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.UUID, new
PostgreSQLUUIDBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.UUID, new
PostgreSQLUUIDBinaryProtocolValue());
}
private static void setBoolBinaryProtocolValue() {
- BINARY_PROTOCOL_VALUES.put(PostgreSQLColumnType.BOOL, new
PostgreSQLBoolBinaryProtocolValue());
+ BINARY_PROTOCOL_VALUES.put(PostgreSQLBinaryColumnType.BOOL, new
PostgreSQLBoolBinaryProtocolValue());
}
/**
diff --git
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacket.java
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacket.java
index a2610c8c0a8..ba827264548 100644
---
a/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacket.java
+++
b/database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacket.java
@@ -22,7 +22,7 @@ import lombok.Getter;
import
org.apache.shardingsphere.database.protocol.packet.sql.SQLReceivedPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.apache.shardingsphere.infra.hint.HintValueContext;
@@ -60,11 +60,11 @@ public final class PostgreSQLComParsePacket extends
PostgreSQLCommandPacket impl
*
* @return types of parameters
*/
- public List<PostgreSQLColumnType> readParameterTypes() {
+ public List<PostgreSQLBinaryColumnType> readParameterTypes() {
int parameterCount = payload.readInt2();
- List<PostgreSQLColumnType> result = new ArrayList<>(parameterCount);
+ List<PostgreSQLBinaryColumnType> result = new
ArrayList<>(parameterCount);
for (int i = 0; i < parameterCount; i++) {
- result.add(PostgreSQLColumnType.valueOf(payload.readInt4()));
+ result.add(PostgreSQLBinaryColumnType.valueOf(payload.readInt4()));
}
return result;
}
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
index 965d01fe66c..ce1fb7f70b9 100644
---
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
+++
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.qu
import org.apache.shardingsphere.database.protocol.binary.BinaryCell;
import org.apache.shardingsphere.database.protocol.payload.PacketPayload;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.jupiter.api.Test;
@@ -115,7 +115,7 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteWithBinaryNullValue() {
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.nCopies(1, new
BinaryCell(PostgreSQLColumnType.INT4, null)));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.nCopies(1, new
BinaryCell(PostgreSQLBinaryColumnType.INT4, null)));
actual.write((PacketPayload) payload);
verify(payload).writeInt2(1);
verify(payload).writeInt4(0xFFFFFFFF);
@@ -124,7 +124,7 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteWithBinaryInt4Value() {
int value = 12345678;
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(new
BinaryCell(PostgreSQLColumnType.INT4, value)));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(new
BinaryCell(PostgreSQLBinaryColumnType.INT4, value)));
actual.write((PacketPayload) payload);
verify(payload).writeInt2(1);
verify(payload).writeInt4(4);
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.java
index 197f0eec7fd..97753fe489a 100644
---
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.java
+++
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.jupiter.api.Test;
@@ -41,17 +41,17 @@ class PostgreSQLParameterDescriptionPacketTest {
@Test
void assertWrite() {
- new
PostgreSQLParameterDescriptionPacket(Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.TEXT)).write(payload);
+ new
PostgreSQLParameterDescriptionPacket(Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.TEXT)).write(payload);
InOrder inOrder = inOrder(payload);
inOrder.verify(payload).writeInt2(2);
-
inOrder.verify(payload).writeInt4(PostgreSQLColumnType.INT4.getValue());
-
inOrder.verify(payload).writeInt4(PostgreSQLColumnType.TEXT.getValue());
+
inOrder.verify(payload).writeInt4(PostgreSQLBinaryColumnType.INT4.getValue());
+
inOrder.verify(payload).writeInt4(PostgreSQLBinaryColumnType.TEXT.getValue());
verifyNoMoreInteractions(payload);
}
@Test
void assertGetIdentifier() {
- assertThat(new
PostgreSQLParameterDescriptionPacket(Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.TEXT)).getIdentifier(),
+ assertThat(new
PostgreSQLParameterDescriptionPacket(Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.TEXT)).getIdentifier(),
is(PostgreSQLMessagePacketType.PARAMETER_DESCRIPTION));
}
}
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLBinaryColumnTypeTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLBinaryColumnTypeTest.java
new file mode 100644
index 00000000000..65f62b14505
--- /dev/null
+++
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLBinaryColumnTypeTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.database.protocol.postgresql.packet.command.query.extended;
+
+import
org.apache.shardingsphere.database.protocol.postgresql.exception.PostgreSQLProtocolException;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.sql.Types;
+import java.util.stream.Stream;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class PostgreSQLBinaryColumnTypeTest {
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("assertValueOfJDBCTypeArguments")
+ void assertValueOfJDBCType(final String name, final int jdbcType, final
PostgreSQLBinaryColumnType expectedColumnType) {
+ assertThat(PostgreSQLBinaryColumnType.valueOfJDBCType(jdbcType),
is(expectedColumnType));
+ }
+
+ @Test
+ void assertValueOfJDBCTypeThrowsIllegalArgumentException() {
+ assertThrows(IllegalArgumentException.class, () ->
PostgreSQLBinaryColumnType.valueOfJDBCType(Types.REF_CURSOR));
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("assertValueOfJDBCTypeWithColumnTypeNameArguments")
+ void assertValueOfJDBCTypeWithColumnTypeName(final String name, final int
jdbcType, final String columnTypeName, final PostgreSQLBinaryColumnType
expectedColumnType) {
+ assertThat(PostgreSQLBinaryColumnType.valueOfJDBCType(jdbcType,
columnTypeName), is(expectedColumnType));
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("assertIsBitArguments")
+ void assertIsBit(final String name, final int jdbcType, final String
columnTypeName, final boolean expected) {
+ assertThat(PostgreSQLBinaryColumnType.isBit(jdbcType, columnTypeName),
is(expected));
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("assertIsBoolArguments")
+ void assertIsBool(final String name, final int jdbcType, final String
columnTypeName, final boolean expected) {
+ assertThat(PostgreSQLBinaryColumnType.isBool(jdbcType,
columnTypeName), is(expected));
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("assertIsUUIDArguments")
+ void assertIsUUID(final String name, final int jdbcType, final String
columnTypeName, final boolean expected) {
+ assertThat(PostgreSQLBinaryColumnType.isUUID(jdbcType,
columnTypeName), is(expected));
+ }
+
+ @Test
+ void assertValueOf() {
+ assertThat(PostgreSQLBinaryColumnType.valueOf(20),
is(PostgreSQLBinaryColumnType.INT8));
+ }
+
+ @Test
+ void assertValueOfThrowsPostgreSQLProtocolException() {
+ assertThrows(PostgreSQLProtocolException.class, () ->
PostgreSQLBinaryColumnType.valueOf(9999));
+ }
+
+ private static Stream<Arguments> assertValueOfJDBCTypeArguments() {
+ return Stream.of(
+ Arguments.of("tinyint", Types.TINYINT,
PostgreSQLBinaryColumnType.INT2),
+ Arguments.of("smallint", Types.SMALLINT,
PostgreSQLBinaryColumnType.INT2),
+ Arguments.of("integer", Types.INTEGER,
PostgreSQLBinaryColumnType.INT4),
+ Arguments.of("bigint", Types.BIGINT,
PostgreSQLBinaryColumnType.INT8),
+ Arguments.of("numeric", Types.NUMERIC,
PostgreSQLBinaryColumnType.NUMERIC),
+ Arguments.of("decimal", Types.DECIMAL,
PostgreSQLBinaryColumnType.NUMERIC),
+ Arguments.of("real", Types.REAL,
PostgreSQLBinaryColumnType.FLOAT4),
+ Arguments.of("double", Types.DOUBLE,
PostgreSQLBinaryColumnType.FLOAT8),
+ Arguments.of("char", Types.CHAR,
PostgreSQLBinaryColumnType.CHAR),
+ Arguments.of("varchar", Types.VARCHAR,
PostgreSQLBinaryColumnType.VARCHAR),
+ Arguments.of("binary", Types.BINARY,
PostgreSQLBinaryColumnType.BYTEA),
+ Arguments.of("bit", Types.BIT, PostgreSQLBinaryColumnType.BIT),
+ Arguments.of("date", Types.DATE,
PostgreSQLBinaryColumnType.DATE),
+ Arguments.of("time", Types.TIME,
PostgreSQLBinaryColumnType.TIME),
+ Arguments.of("timestamp", Types.TIMESTAMP,
PostgreSQLBinaryColumnType.TIMESTAMP),
+ Arguments.of("other", Types.OTHER,
PostgreSQLBinaryColumnType.JSON),
+ Arguments.of("sqlxml", Types.SQLXML,
PostgreSQLBinaryColumnType.XML),
+ Arguments.of("boolean", Types.BOOLEAN,
PostgreSQLBinaryColumnType.BOOL),
+ Arguments.of("struct", Types.STRUCT,
PostgreSQLBinaryColumnType.VARCHAR),
+ Arguments.of("array", Types.ARRAY,
PostgreSQLBinaryColumnType.TEXT_ARRAY));
+ }
+
+ private static Stream<Arguments>
assertValueOfJDBCTypeWithColumnTypeNameArguments() {
+ return Stream.of(
+ Arguments.of("bit override", Types.BIT, "bit",
PostgreSQLBinaryColumnType.BIT),
+ Arguments.of("bool override", Types.BIT, "bool",
PostgreSQLBinaryColumnType.BOOL),
+ Arguments.of("uuid override", Types.OTHER, "uuid",
PostgreSQLBinaryColumnType.UUID),
+ Arguments.of("fallback to jdbc type map", Types.INTEGER,
"INT4", PostgreSQLBinaryColumnType.INT4));
+ }
+
+ private static Stream<Arguments> assertIsBitArguments() {
+ return Stream.of(
+ Arguments.of("bit exact", Types.BIT, "bit", true),
+ Arguments.of("bit ignore case", Types.BIT, "BiT", true),
+ Arguments.of("bit type with bool name", Types.BIT, "bool",
false),
+ Arguments.of("non bit jdbc type", Types.INTEGER, "bit",
false));
+ }
+
+ private static Stream<Arguments> assertIsBoolArguments() {
+ return Stream.of(
+ Arguments.of("bool exact", Types.BIT, "bool", true),
+ Arguments.of("bool ignore case", Types.BIT, "BoOl", true),
+ Arguments.of("bit type with bit name", Types.BIT, "bit",
false),
+ Arguments.of("non bit jdbc type", Types.BOOLEAN, "bool",
false));
+ }
+
+ private static Stream<Arguments> assertIsUUIDArguments() {
+ return Stream.of(
+ Arguments.of("uuid exact", Types.OTHER, "uuid", true),
+ Arguments.of("uuid ignore case", Types.OTHER, "UUID", true),
+ Arguments.of("other type with non uuid name", Types.OTHER,
"json", false),
+ Arguments.of("non other jdbc type", Types.VARCHAR, "uuid",
false));
+ }
+}
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
deleted file mode 100644
index 8201ec0b1eb..00000000000
---
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
+++ /dev/null
@@ -1,171 +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.database.protocol.postgresql.packet.command.query.extended;
-
-import
org.apache.shardingsphere.database.protocol.postgresql.exception.PostgreSQLProtocolException;
-import org.junit.jupiter.api.Test;
-
-import java.sql.Types;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class PostgreSQLColumnTypeTest {
-
- @Test
- void assertValueOfJDBCTypeForTinyint() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.TINYINT);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.INT2));
- }
-
- @Test
- void assertValueOfJDBCTypeForSmallint() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.SMALLINT);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.INT2));
- }
-
- @Test
- void assertValueOfJDBCTypeForInteger() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.INTEGER);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.INT4));
- }
-
- @Test
- void assertValueOfJDBCTypeForBigint() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BIGINT);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.INT8));
- }
-
- @Test
- void assertValueOfJDBCTypeForNumeric() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.NUMERIC);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.NUMERIC));
- }
-
- @Test
- void assertValueOfJDBCTypeForDecimal() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.DECIMAL);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.NUMERIC));
- }
-
- @Test
- void assertValueOfJDBCTypeForReal() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.REAL);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.FLOAT4));
- }
-
- @Test
- void assertValueOfJDBCTypeForDouble() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.DOUBLE);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.FLOAT8));
- }
-
- @Test
- void assertValueOfJDBCTypeForChar() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.CHAR);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.CHAR));
- }
-
- @Test
- void assertValueOfJDBCTypeForVarchar() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.VARCHAR);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.VARCHAR));
- }
-
- @Test
- void assertValueOfJDBCTypeForBinary() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BINARY);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.BYTEA));
- }
-
- @Test
- void assertValueOfJDBCTypeForBit() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BIT);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.BIT));
- }
-
- @Test
- void assertValueOfPgTypeForBit() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BIT, "bit");
- assertThat(sqlColumnType, is(PostgreSQLColumnType.BIT));
- }
-
- @Test
- void assertValueOfPgTypeForBool() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BIT, "bool");
- assertThat(sqlColumnType, is(PostgreSQLColumnType.BOOL));
- }
-
- @Test
- void assertValueOfJDBCTypeForDate() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.DATE);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.DATE));
- }
-
- @Test
- void assertValueOfJDBCTypeForTime() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.TIME);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.TIME));
- }
-
- @Test
- void assertValueOfJDBCTypeForTimestamp() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.TIMESTAMP);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.TIMESTAMP));
- }
-
- @Test
- void assertValueOfJDBCTypeForOther() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.OTHER);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.JSON));
- }
-
- @Test
- void assertValueOfJDBCTypeForSQLXML() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.SQLXML);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.XML));
- }
-
- @Test
- void assertValueOfJDBCTypeForBoolean() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOfJDBCType(Types.BOOLEAN);
- assertThat(sqlColumnType, is(PostgreSQLColumnType.BOOL));
- }
-
- @Test
- void assertValueOfJDBCTypeExThrown() {
- assertThrows(IllegalArgumentException.class, () ->
PostgreSQLColumnType.valueOfJDBCType(Types.REF_CURSOR));
- }
-
- @Test
- void assertValueOf() {
- PostgreSQLColumnType sqlColumnType =
PostgreSQLColumnType.valueOf(PostgreSQLColumnType.INT8.getValue());
- assertThat(sqlColumnType, is(PostgreSQLColumnType.INT8));
- }
-
- @Test
- void assertValueOfExThrown() {
- assertThrows(PostgreSQLProtocolException.class, () ->
PostgreSQLColumnType.valueOf(9999));
- }
-
- @Test
- void assertGetValue() {
- assertThat(PostgreSQLColumnType.INT8.getValue(), is(20));
- }
-}
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
index 1c3d55f2214..04309a670bb 100644
---
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
+++
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacketTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind;
import io.netty.buffer.Unpooled;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.jupiter.api.Test;
@@ -43,7 +43,7 @@ class PostgreSQLComBindPacketTest {
PostgreSQLComBindPacket actual = new PostgreSQLComBindPacket(new
PostgreSQLPacketPayload(Unpooled.wrappedBuffer(BIND_MESSAGE_BYTES),
StandardCharsets.UTF_8));
assertThat(actual.getPortal(), is(""));
assertThat(actual.getStatementId(), is("S_1"));
-
assertThat(actual.readParameters(Collections.singletonList(PostgreSQLColumnType.INT4)),
is(Collections.singletonList(10)));
+
assertThat(actual.readParameters(Collections.singletonList(PostgreSQLBinaryColumnType.INT4)),
is(Collections.singletonList(10)));
assertTrue(actual.readResultFormats().isEmpty());
}
}
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
index bb18b78fce9..dd8b86f695a 100644
---
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
+++
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
@@ -17,7 +17,7 @@
package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -28,72 +28,72 @@ class PostgreSQLBinaryProtocolValueFactoryTest {
@Test
void assertGetStringBinaryProtocolValueByVarchar() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.VARCHAR);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.VARCHAR);
assertThat(binaryProtocolValue,
isA(PostgreSQLStringBinaryProtocolValue.class));
}
@Test
void assertGetStringBinaryProtocolValueByChar() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.CHAR);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.CHAR);
assertThat(binaryProtocolValue,
isA(PostgreSQLStringBinaryProtocolValue.class));
}
@Test
void assertGetInt8BinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.INT8);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.INT8);
assertThat(binaryProtocolValue,
isA(PostgreSQLInt8BinaryProtocolValue.class));
}
@Test
void assertGetInt4BinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.INT4);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.INT4);
assertThat(binaryProtocolValue,
isA(PostgreSQLInt4BinaryProtocolValue.class));
}
@Test
void assertGetInt2BinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.INT2);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.INT2);
assertThat(binaryProtocolValue,
isA(PostgreSQLInt2BinaryProtocolValue.class));
}
@Test
void assertGetDoubleBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.FLOAT8);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.FLOAT8);
assertThat(binaryProtocolValue,
isA(PostgreSQLDoubleBinaryProtocolValue.class));
}
@Test
void assertGetFloatBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.FLOAT4);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.FLOAT4);
assertThat(binaryProtocolValue,
isA(PostgreSQLFloatBinaryProtocolValue.class));
}
@Test
void assertGetNumericBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.NUMERIC);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.NUMERIC);
assertThat(binaryProtocolValue,
isA(PostgreSQLNumericBinaryProtocolValue.class));
}
@Test
void assertGetDateBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.DATE);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.DATE);
assertThat(binaryProtocolValue,
isA(PostgreSQLDateBinaryProtocolValue.class));
}
@Test
void assertGetTimeBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.TIMESTAMP);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.TIMESTAMP);
assertThat(binaryProtocolValue,
isA(PostgreSQLTimeBinaryProtocolValue.class));
}
@Test
void assertGetBoolBinaryProtocolValue() {
- PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.BOOL);
+ PostgreSQLBinaryProtocolValue binaryProtocolValue =
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.BOOL);
assertThat(binaryProtocolValue,
isA(PostgreSQLBoolBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueExThrown() {
- assertThrows(IllegalArgumentException.class, () ->
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.XML));
+ assertThrows(IllegalArgumentException.class, () ->
PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLBinaryColumnType.XML));
}
}
diff --git
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacketTest.java
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacketTest.java
index 18cc34522ca..a963f6f5d2b 100644
---
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacketTest.java
+++
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/parse/PostgreSQLComParsePacketTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.parse;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -47,8 +47,8 @@ class PostgreSQLComParsePacketTest {
assertThat(actual.getIdentifier(),
is(PostgreSQLCommandPacketType.PARSE_COMMAND));
assertThat(actual.getSQL(), is("sql"));
assertThat(actual.getStatementId(), is("sql"));
- List<PostgreSQLColumnType> types = actual.readParameterTypes();
+ List<PostgreSQLBinaryColumnType> types = actual.readParameterTypes();
assertThat(types.size(), is(1));
- assertThat(types.get(0), is(PostgreSQLColumnType.UNSPECIFIED));
+ assertThat(types.get(0), is(PostgreSQLBinaryColumnType.UNSPECIFIED));
}
}
diff --git
a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/ddl/column/PostgreSQLColumnTypeTest.java
b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/ddl/column/PostgreSQLColumnTypeTest.java
index 12781d466f4..3f2754c027f 100644
---
a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/ddl/column/PostgreSQLColumnTypeTest.java
+++
b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/ddl/column/PostgreSQLColumnTypeTest.java
@@ -17,25 +17,29 @@
package
org.apache.shardingsphere.data.pipeline.postgresql.sqlbuilder.ddl.column;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
class PostgreSQLColumnTypeTest {
- @Test
- void assertValueOfZeroValue() {
- assertThat(PostgreSQLColumnType.valueOf(0L),
is(PostgreSQLColumnType.UNKNOWN));
- }
-
- @Test
- void assertValueOfFoundValue() {
- assertThat(PostgreSQLColumnType.valueOf(1231L),
is(PostgreSQLColumnType.NUMERIC));
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("assertValueOfArguments")
+ void assertValueOf(final String name, final Long elemoid, final
PostgreSQLColumnType expectedColumnType) {
+ assertThat(PostgreSQLColumnType.valueOf(elemoid),
is(expectedColumnType));
}
- @Test
- void assertValueOfNotExistedValue() {
- assertThat(PostgreSQLColumnType.valueOf(1L),
is(PostgreSQLColumnType.UNKNOWN));
+ private static Stream<Arguments> assertValueOfArguments() {
+ return Stream.of(
+ Arguments.of("numeric", 1231L, PostgreSQLColumnType.NUMERIC),
+ Arguments.of("date", 1083L, PostgreSQLColumnType.DATE),
+ Arguments.of("varchar", 1043L, PostgreSQLColumnType.VARCHAR),
+ Arguments.of("unknownZero", 0L, PostgreSQLColumnType.UNKNOWN),
+ Arguments.of("unknownNotExisted", 1L,
PostgreSQLColumnType.UNKNOWN));
}
}
diff --git
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
index fb38e601df3..954a292c53d 100644
---
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
+++
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
@@ -29,7 +29,7 @@ import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.que
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLEmptyQueryResponsePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextBitUtils;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextBoolUtils;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLPortalSuspendedPacket;
@@ -190,14 +190,14 @@ public final class Portal {
}
private BinaryCell createBinaryCell(final QueryResponseCell cell) {
- return new
BinaryCell(PostgreSQLColumnType.valueOfJDBCType(cell.getJdbcType(),
cell.getColumnTypeName().orElse(null)), getCellData(cell));
+ return new
BinaryCell(PostgreSQLBinaryColumnType.valueOfJDBCType(cell.getJdbcType(),
cell.getColumnTypeName().orElse(null)), getCellData(cell));
}
private Object getCellData(final QueryResponseCell cell) {
- if (PostgreSQLColumnType.isBit(cell.getJdbcType(),
cell.getColumnTypeName().orElse(null))) {
+ if (PostgreSQLBinaryColumnType.isBit(cell.getJdbcType(),
cell.getColumnTypeName().orElse(null))) {
return PostgreSQLTextBitUtils.getTextValue(cell.getData());
}
- if (PostgreSQLColumnType.isBool(cell.getJdbcType(),
cell.getColumnTypeName().orElse(null))) {
+ if (PostgreSQLBinaryColumnType.isBool(cell.getJdbcType(),
cell.getColumnTypeName().orElse(null))) {
return PostgreSQLTextBoolUtils.getTextValue(cell.getData());
}
return cell.getData();
diff --git
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutor.java
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutor.java
index 88e0839dacd..7af06507d92 100644
---
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutor.java
+++
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutor.java
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLBindCompletePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.describe.PostgreSQLComDescribePacket;
@@ -74,7 +74,7 @@ public final class
PostgreSQLAggregatedBatchedStatementsCommandExecutor implemen
return
connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(bindPacket.getStatementId());
}
- private List<List<Object>> readParameterSets(final
List<PostgreSQLColumnType> parameterTypes) {
+ private List<List<Object>> readParameterSets(final
List<PostgreSQLBinaryColumnType> parameterTypes) {
List<List<Object>> result = new LinkedList<>();
for (PostgreSQLCommandPacket each : packets) {
if (each instanceof PostgreSQLComBindPacket) {
diff --git
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatement.java
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatement.java
index 34058dc67a3..394b0b66fc8 100644
---
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatement.java
+++
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatement.java
@@ -23,7 +23,7 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLParameterDescriptionPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.apache.shardingsphere.proxy.backend.session.ServerPreparedStatement;
@@ -46,7 +46,7 @@ public final class PostgreSQLServerPreparedStatement
implements ServerPreparedSt
private final HintValueContext hintValueContext;
- private final List<PostgreSQLColumnType> parameterTypes;
+ private final List<PostgreSQLBinaryColumnType> parameterTypes;
private final List<Integer> actualParameterMarkerIndexes;
diff --git
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
index 60f7132f57b..99f76a619ad 100644
---
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
+++
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.database.protocol.postgresql.packet.PostgreSQLP
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.describe.PostgreSQLComDescribePacket;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.binder.engine.SQLBindEngine;
@@ -147,16 +147,16 @@ public final class PostgreSQLComDescribeExecutor
implements CommandExecutor {
}
String columnName = columnNamesOfInsert.get(i).toString();
ShardingSpherePreconditions.checkState(table.containsColumn(columnName), () ->
new ColumnNotFoundException(logicTableName, columnName));
-
preparedStatement.getParameterTypes().set(parameterMarkerIndex++,
PostgreSQLColumnType.valueOfJDBCType(table.getColumn(columnName).getDataType()));
+
preparedStatement.getParameterTypes().set(parameterMarkerIndex++,
PostgreSQLBinaryColumnType.valueOfJDBCType(table.getColumn(columnName).getDataType()));
}
}
}
private Collection<Integer> getUnspecifiedTypeParameterIndexes(final
PostgreSQLServerPreparedStatement preparedStatement) {
Collection<Integer> result = new HashSet<>();
- ListIterator<PostgreSQLColumnType> parameterTypesListIterator =
preparedStatement.getParameterTypes().listIterator();
+ ListIterator<PostgreSQLBinaryColumnType> parameterTypesListIterator =
preparedStatement.getParameterTypes().listIterator();
for (int index = parameterTypesListIterator.nextIndex();
parameterTypesListIterator.hasNext(); index =
parameterTypesListIterator.nextIndex()) {
- if (PostgreSQLColumnType.UNSPECIFIED ==
parameterTypesListIterator.next()) {
+ if (PostgreSQLBinaryColumnType.UNSPECIFIED ==
parameterTypesListIterator.next()) {
result.add(index);
}
}
@@ -255,13 +255,13 @@ public final class PostgreSQLComDescribeExecutor
implements CommandExecutor {
private void populateParameterTypes(final
PostgreSQLServerPreparedStatement logicPreparedStatement, final
PreparedStatement actualPreparedStatement) throws SQLException {
if (0 ==
logicPreparedStatement.getSqlStatementContext().getSqlStatement().getParameterCount()
- ||
logicPreparedStatement.getParameterTypes().stream().noneMatch(each ->
PostgreSQLColumnType.UNSPECIFIED == each)) {
+ ||
logicPreparedStatement.getParameterTypes().stream().noneMatch(each ->
PostgreSQLBinaryColumnType.UNSPECIFIED == each)) {
return;
}
ParameterMetaData parameterMetaData =
actualPreparedStatement.getParameterMetaData();
for (int i = 0; i <
logicPreparedStatement.getSqlStatementContext().getSqlStatement().getParameterCount();
i++) {
- if (PostgreSQLColumnType.UNSPECIFIED ==
logicPreparedStatement.getParameterTypes().get(i)) {
- logicPreparedStatement.getParameterTypes().set(i,
PostgreSQLColumnType.valueOfJDBCType(parameterMetaData.getParameterType(i + 1),
parameterMetaData.getParameterTypeName(i + 1)));
+ if (PostgreSQLBinaryColumnType.UNSPECIFIED ==
logicPreparedStatement.getParameterTypes().get(i)) {
+ logicPreparedStatement.getParameterTypes().set(i,
PostgreSQLBinaryColumnType.valueOfJDBCType(parameterMetaData.getParameterType(i
+ 1), parameterMetaData.getParameterTypeName(i + 1)));
}
}
}
diff --git
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
index cf6a26db4c9..15a35ed2573 100644
---
a/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
+++
b/proxy/frontend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutor.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.parse.PostgreSQLComParsePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.parse.PostgreSQLParseCompletePacket;
import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
@@ -77,7 +77,7 @@ public final class PostgreSQLComParseExecutor implements
CommandExecutor {
sql = convertSQLToJDBCStyle(parameterMarkerSegments, sql);
sqlStatement = sqlParserEngine.parse(sql, true);
}
- List<PostgreSQLColumnType> paddedColumnTypes =
paddingColumnTypes(sqlStatement.getParameterCount(),
packet.readParameterTypes());
+ List<PostgreSQLBinaryColumnType> paddedColumnTypes =
paddingColumnTypes(sqlStatement.getParameterCount(),
packet.readParameterTypes());
SQLStatementContext sqlStatementContext = sqlStatement instanceof
DistSQLStatement
? new DistSQLStatementContext((DistSQLStatement) sqlStatement)
: new SQLBindEngine(metaData,
connectionSession.getCurrentDatabaseName(),
packet.getHintValueContext()).bind(sqlStatement);
@@ -101,15 +101,15 @@ public final class PostgreSQLComParseExecutor implements
CommandExecutor {
return result.toString();
}
- private List<PostgreSQLColumnType> paddingColumnTypes(final int
parameterCount, final List<PostgreSQLColumnType> specifiedColumnTypes) {
+ private List<PostgreSQLBinaryColumnType> paddingColumnTypes(final int
parameterCount, final List<PostgreSQLBinaryColumnType> specifiedColumnTypes) {
if (parameterCount == specifiedColumnTypes.size()) {
return specifiedColumnTypes;
}
- List<PostgreSQLColumnType> result = new ArrayList<>(parameterCount);
+ List<PostgreSQLBinaryColumnType> result = new
ArrayList<>(parameterCount);
result.addAll(specifiedColumnTypes);
int unspecifiedCount = parameterCount - specifiedColumnTypes.size();
for (int i = 0; i < unspecifiedCount; i++) {
- result.add(PostgreSQLColumnType.UNSPECIFIED);
+ result.add(PostgreSQLBinaryColumnType.UNSPECIFIED);
}
return result;
}
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
index c7fa95076eb..1521f1ccb25 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.que
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLEmptyQueryResponsePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.execute.PostgreSQLPortalSuspendedPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.handshake.PostgreSQLParameterStatusPacket;
@@ -299,11 +299,11 @@ class PortalTest {
PostgreSQLDataRowPacket dataRowPacket = (PostgreSQLDataRowPacket)
actualPackets.get(0);
List<Object> actualData = new ArrayList<>(dataRowPacket.getData());
BinaryCell bitBinaryCell = (BinaryCell) actualData.get(0);
- assertThat(bitBinaryCell.getColumnType(),
is(PostgreSQLColumnType.BIT));
+ assertThat(bitBinaryCell.getColumnType(),
is(PostgreSQLBinaryColumnType.BIT));
assertThat(bitBinaryCell.getData(), is("1"));
assertThat(actualData.get(1), is("f"));
BinaryCell varcharBinaryCell = (BinaryCell) actualData.get(2);
- assertThat(varcharBinaryCell.getColumnType(),
is(PostgreSQLColumnType.VARCHAR));
+ assertThat(varcharBinaryCell.getColumnType(),
is(PostgreSQLBinaryColumnType.VARCHAR));
assertThat(varcharBinaryCell.getData(), is("foo"));
}
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
index 0a299111220..5b19c886b3f 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
@@ -21,7 +21,7 @@ import
org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLBindCompletePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.describe.PostgreSQLComDescribePacket;
@@ -120,7 +120,7 @@ class
PostgreSQLAggregatedBatchedStatementsCommandExecutorTest {
when(result.getConnectionContext()).thenReturn(connectionContext);
when(result.getServerPreparedStatementRegistry()).thenReturn(new
ServerPreparedStatementRegistry());
result.getServerPreparedStatementRegistry().addPreparedStatement(STATEMENT_ID,
- new PostgreSQLServerPreparedStatement(SQL,
sqlStatementContext, new HintValueContext(),
Collections.singletonList(PostgreSQLColumnType.INT4),
Collections.singletonList(0)));
+ new PostgreSQLServerPreparedStatement(SQL,
sqlStatementContext, new HintValueContext(),
Collections.singletonList(PostgreSQLBinaryColumnType.INT4),
Collections.singletonList(0)));
when(result.getConnectionId()).thenReturn(CONNECTION_ID);
ProxyDatabaseConnectionManager databaseConnectionManager =
mock(ProxyDatabaseConnectionManager.class);
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
@@ -141,7 +141,7 @@ class
PostgreSQLAggregatedBatchedStatementsCommandExecutorTest {
for (int i = 0; i < BATCH_SIZE; i++) {
PostgreSQLComBindPacket bindPacket =
mock(PostgreSQLComBindPacket.class);
when(bindPacket.getStatementId()).thenReturn(STATEMENT_ID);
-
when(bindPacket.readParameters(Collections.singletonList(PostgreSQLColumnType.INT4))).thenReturn(Collections.singletonList(i));
+
when(bindPacket.readParameters(Collections.singletonList(PostgreSQLBinaryColumnType.INT4))).thenReturn(Collections.singletonList(i));
PostgreSQLComDescribePacket describePacket =
mock(PostgreSQLComDescribePacket.class);
PostgreSQLComExecutePacket executePacket =
mock(PostgreSQLComExecutePacket.class);
result.add(bindPacket);
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
index db649c93ed2..6c8c0b8e9d0 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.SneakyThrows;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLTypeUnspecifiedSQLParameter;
import
org.apache.shardingsphere.infra.binder.context.statement.type.dml.InsertStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.type.dml.UpdateStatementContext;
@@ -111,7 +111,7 @@ class PostgreSQLBatchedStatementsExecutorTest {
ContextManager contextManager = mockContextManager(databaseType);
ConnectionSession connectionSession = mockConnectionSession();
PostgreSQLServerPreparedStatement postgresqlPreparedStatement = new
PostgreSQLServerPreparedStatement("INSERT INTO t (id, col) VALUES (?, ?)",
mockInsertStatementContext(),
- new HintValueContext(),
Arrays.asList(PostgreSQLColumnType.INT4, PostgreSQLColumnType.VARCHAR),
Arrays.asList(0, 1));
+ new HintValueContext(),
Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR), Arrays.asList(0, 1));
List<List<Object>> parameterSets = Arrays.asList(Arrays.asList(1, new
PostgreSQLTypeUnspecifiedSQLParameter("foo")),
Arrays.asList(2, new
PostgreSQLTypeUnspecifiedSQLParameter("bar")), Arrays.asList(3, new
PostgreSQLTypeUnspecifiedSQLParameter("baz")));
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
@@ -140,7 +140,7 @@ class PostgreSQLBatchedStatementsExecutorTest {
ContextManager contextManager = mockContextManager(mysqlDatabaseType);
ConnectionSession connectionSession = mockConnectionSession();
PostgreSQLServerPreparedStatement postgresqlPreparedStatement = new
PostgreSQLServerPreparedStatement("UPDATE t SET col = ? WHERE id = ?",
mockUpdateStatementContext(),
- new HintValueContext(),
Arrays.asList(PostgreSQLColumnType.INT4, PostgreSQLColumnType.VARCHAR),
Arrays.asList(0, 1));
+ new HintValueContext(),
Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR), Arrays.asList(0, 1));
List<List<Object>> parameterSets =
Collections.singletonList(Arrays.asList(10, "foo"));
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
PostgreSQLBatchedStatementsExecutor actual = new
PostgreSQLBatchedStatementsExecutor(connectionSession,
postgresqlPreparedStatement, parameterSets);
@@ -167,7 +167,7 @@ class PostgreSQLBatchedStatementsExecutorTest {
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ConnectionSession connectionSession = mockConnectionSession();
PostgreSQLServerPreparedStatement postgresqlPreparedStatement = new
PostgreSQLServerPreparedStatement("INSERT INTO t (id, col) VALUES (?, ?)",
mockInsertStatementContext(),
- new HintValueContext(),
Arrays.asList(PostgreSQLColumnType.INT4, PostgreSQLColumnType.VARCHAR),
Arrays.asList(0, 1));
+ new HintValueContext(),
Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR), Arrays.asList(0, 1));
PostgreSQLBatchedStatementsExecutor actual = new
PostgreSQLBatchedStatementsExecutor(connectionSession,
postgresqlPreparedStatement, Collections.emptyList());
Map<ExecutionUnit, List<List<Object>>> executionUnitParams =
(Map<ExecutionUnit, List<List<Object>>>) Plugins.getMemberAccessor()
.get(PostgreSQLBatchedStatementsExecutor.class.getDeclaredField("executionUnitParams"),
actual);
@@ -184,7 +184,7 @@ class PostgreSQLBatchedStatementsExecutorTest {
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ConnectionSession connectionSession = mockConnectionSession();
PostgreSQLServerPreparedStatement postgresqlPreparedStatement = new
PostgreSQLServerPreparedStatement("UPDATE t SET col = ? WHERE id = ?",
mockUpdateStatementContext(),
- new HintValueContext(),
Arrays.asList(PostgreSQLColumnType.INT4, PostgreSQLColumnType.VARCHAR),
Arrays.asList(0, 1));
+ new HintValueContext(),
Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR), Arrays.asList(0, 1));
List<List<Object>> parameterSets = Arrays.asList(Arrays.asList(1,
"foo"), Arrays.asList(2, "bar"));
PostgreSQLBatchedStatementsExecutor actual = new
PostgreSQLBatchedStatementsExecutor(connectionSession,
postgresqlPreparedStatement, parameterSets);
Map<ExecutionUnit, List<List<Object>>> executionUnitParams =
(Map<ExecutionUnit, List<List<Object>>>) Plugins.getMemberAccessor()
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatementTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatementTest.java
index 55929673046..bc3b14a5786 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatementTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLServerPreparedStatementTest.java
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extended;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.PostgreSQLPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import org.apache.shardingsphere.infra.hint.HintValueContext;
import org.junit.jupiter.api.Test;
@@ -57,6 +57,6 @@ class PostgreSQLServerPreparedStatementTest {
private PostgreSQLServerPreparedStatement createPreparedStatement() {
return new PostgreSQLServerPreparedStatement(
- "INSERT INTO t VALUES ($1, $2)", mock(), new
HintValueContext(), Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.VARCHAR), Arrays.asList(1, 0));
+ "INSERT INTO t VALUES ($1, $2)", mock(), new
HintValueContext(), Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.VARCHAR), Arrays.asList(1, 0));
}
}
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
index b9e35adde9a..b0eb0b476c5 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/bind/PostgreSQLComBindExecutorTest.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLBindCompletePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLComBindPacket;
import
org.apache.shardingsphere.infra.binder.context.statement.type.CommonSQLStatementContext;
@@ -129,7 +129,7 @@ class PostgreSQLComBindExecutorTest {
List<Object> parameters = Arrays.asList(1, "updated_name");
PostgreSQLServerPreparedStatement serverPreparedStatement = new
PostgreSQLServerPreparedStatement("UPDATE test SET name = $2 WHERE id = $1",
new CommonSQLStatementContext(new
EmptyStatement(databaseType)), new HintValueContext(),
- Arrays.asList(PostgreSQLColumnType.VARCHAR,
PostgreSQLColumnType.INT4), Arrays.asList(1, 0));
+ Arrays.asList(PostgreSQLBinaryColumnType.VARCHAR,
PostgreSQLBinaryColumnType.INT4), Arrays.asList(1, 0));
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId,
serverPreparedStatement);
when(bindPacket.getStatementId()).thenReturn(statementId);
when(bindPacket.getPortal()).thenReturn("C_1");
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index 7793202f7bf..199d593bedb 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.que
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLParameterDescriptionPacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.PostgreSQLRowDescriptionPacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.describe.PostgreSQLComDescribePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -173,9 +173,9 @@ class PostgreSQLComDescribeExecutorTest {
when(packet.getType()).thenReturn('S');
when(packet.getName()).thenReturn(statementId);
SQLStatement sqlStatement = SQL_PARSER_ENGINE.parse(sql, false);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
for (int i = 0; i < sqlStatement.getParameterCount(); i++) {
- parameterTypes.add(PostgreSQLColumnType.UNSPECIFIED);
+ parameterTypes.add(PostgreSQLBinaryColumnType.UNSPECIFIED);
}
SQLStatementContext sqlStatementContext =
mock(InsertStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
@@ -190,8 +190,8 @@ class PostgreSQLComDescribeExecutorTest {
PostgreSQLPacketPayload mockPayload =
mock(PostgreSQLPacketPayload.class);
actualParameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(expectedParamCount);
- verify(mockPayload,
times(expectedInt4Count)).writeInt4(PostgreSQLColumnType.INT4.getValue());
- verify(mockPayload,
times(expectedCharCount)).writeInt4(PostgreSQLColumnType.CHAR.getValue());
+ verify(mockPayload,
times(expectedInt4Count)).writeInt4(PostgreSQLBinaryColumnType.INT4.getValue());
+ verify(mockPayload,
times(expectedCharCount)).writeInt4(PostgreSQLBinaryColumnType.CHAR.getValue());
assertThat(actualPacketsIterator.next(),
is(PostgreSQLNoDataPacket.getInstance()));
}
@@ -224,7 +224,7 @@ class PostgreSQLComDescribeExecutorTest {
when(packet.getName()).thenReturn(statementId);
String sql = "INSERT INTO public.t_small (col1, col2) VALUES (?, ?)
RETURNING *, col1 + col2 expr_sum";
SQLStatement sqlStatement = SQL_PARSER_ENGINE.parse(sql, false);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.UNSPECIFIED));
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.UNSPECIFIED));
SQLStatementContext sqlStatementContext =
mock(InsertStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
ShardingSphereTable table = new ShardingSphereTable("t_small",
@@ -243,8 +243,8 @@ class PostgreSQLComDescribeExecutorTest {
PostgreSQLPacketPayload mockPayload =
mock(PostgreSQLPacketPayload.class);
parameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(2);
- verify(mockPayload).writeInt4(PostgreSQLColumnType.INT4.getValue());
- verify(mockPayload).writeInt4(PostgreSQLColumnType.INT2.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.INT4.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.INT2.getValue());
PostgreSQLRowDescriptionPacket rowDescriptionPacket =
(PostgreSQLRowDescriptionPacket) actualIterator.next();
List<PostgreSQLColumnDescription> columnDescriptions =
getColumnDescriptions(rowDescriptionPacket);
assertThat(columnDescriptions.size(), is(3));
@@ -253,7 +253,7 @@ class PostgreSQLComDescribeExecutorTest {
assertThat(columnDescriptions.get(1).getColumnName(), is("col2"));
assertThat(columnDescriptions.get(1).getColumnLength(), is(2));
assertThat(columnDescriptions.get(2).getColumnName(), is("expr_sum"));
- assertThat(columnDescriptions.get(2).getTypeOID(),
is(PostgreSQLColumnType.VARCHAR.getValue()));
+ assertThat(columnDescriptions.get(2).getTypeOID(),
is(PostgreSQLBinaryColumnType.VARCHAR.getValue()));
assertThat(columnDescriptions.get(2).getColumnLength(), is(-1));
}
@@ -264,9 +264,9 @@ class PostgreSQLComDescribeExecutorTest {
when(packet.getName()).thenReturn(statementId);
String sql = "INSERT INTO t_order (iD, k, c, PaD) VALUES (1, ?, ?, ?),
(?, 2, ?, '')";
SQLStatement sqlStatement = SQL_PARSER_ENGINE.parse(sql, false);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
for (int i = 0; i < sqlStatement.getParameterCount(); i++) {
- parameterTypes.add(PostgreSQLColumnType.UNSPECIFIED);
+ parameterTypes.add(PostgreSQLBinaryColumnType.UNSPECIFIED);
}
SQLStatementContext sqlStatementContext =
mock(InsertStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
@@ -294,9 +294,9 @@ class PostgreSQLComDescribeExecutorTest {
when(packet.getName()).thenReturn(statementId);
String sql = "INSERT INTO t_order (undefined_column, k, c, pad) VALUES
(1, ?, ?, ?), (?, 2, ?, '')";
SQLStatement sqlStatement = SQL_PARSER_ENGINE.parse(sql, false);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
for (int i = 0; i < sqlStatement.getParameterCount(); i++) {
- parameterTypes.add(PostgreSQLColumnType.UNSPECIFIED);
+ parameterTypes.add(PostgreSQLBinaryColumnType.UNSPECIFIED);
}
SQLStatementContext sqlStatementContext =
mock(InsertStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
@@ -319,7 +319,7 @@ class PostgreSQLComDescribeExecutorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(Collections.singletonList(PostgreSQLColumnType.UNSPECIFIED));
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(Collections.singletonList(PostgreSQLBinaryColumnType.UNSPECIFIED));
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(
statementId, new PostgreSQLServerPreparedStatement(sql,
sqlStatementContext, new HintValueContext(), parameterTypes,
Collections.emptyList()));
Collection<DatabasePacket> actualPackets = executor.execute();
@@ -328,20 +328,20 @@ class PostgreSQLComDescribeExecutorTest {
PostgreSQLPacketPayload mockPayload =
mock(PostgreSQLPacketPayload.class);
parameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(1);
-
verify(mockPayload).writeInt4(PostgreSQLColumnType.UNSPECIFIED.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.UNSPECIFIED.getValue());
assertThat(actualIterator.next(),
is(PostgreSQLNoDataPacket.getInstance()));
}
@ParameterizedTest(name = "{0}")
@MethodSource("provideReturningCases")
void assertDescribePreparedStatementInsertWithReturning(final String
testName, final String statementId, final String sql,
- final
List<PostgreSQLColumnType> expectedParamTypes, final
List<PostgreSQLColumnDescription> expectedColumns) throws SQLException {
+ final
List<PostgreSQLBinaryColumnType> expectedParamTypes, final
List<PostgreSQLColumnDescription> expectedColumns) throws SQLException {
when(packet.getType()).thenReturn('S');
when(packet.getName()).thenReturn(statementId);
SQLStatement sqlStatement = SQL_PARSER_ENGINE.parse(sql, false);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(sqlStatement.getParameterCount());
for (int i = 0; i < sqlStatement.getParameterCount(); i++) {
- parameterTypes.add(PostgreSQLColumnType.UNSPECIFIED);
+ parameterTypes.add(PostgreSQLBinaryColumnType.UNSPECIFIED);
}
SQLStatementContext sqlStatementContext =
mock(InsertStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
@@ -357,7 +357,7 @@ class PostgreSQLComDescribeExecutorTest {
parameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(expectedParamTypes.size());
Map<Integer, Long> expectedTypeCounts = expectedParamTypes.stream()
- .collect(Collectors.groupingBy(PostgreSQLColumnType::getValue,
Collectors.counting()));
+
.collect(Collectors.groupingBy(PostgreSQLBinaryColumnType::getValue,
Collectors.counting()));
for (Entry<Integer, Long> entry : expectedTypeCounts.entrySet()) {
verify(mockPayload,
times(entry.getValue().intValue())).writeInt4(entry.getKey());
}
@@ -383,7 +383,7 @@ class PostgreSQLComDescribeExecutorTest {
SQLStatementContext sqlStatementContext =
mock(SelectStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
prepareJDBCBackendConnection(sql);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(Collections.singleton(PostgreSQLColumnType.UNSPECIFIED));
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(Collections.singleton(PostgreSQLBinaryColumnType.UNSPECIFIED));
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
List<Integer> parameterIndexes = IntStream.range(0,
sqlStatement.getParameterCount()).boxed().collect(Collectors.toList());
@@ -400,7 +400,7 @@ class PostgreSQLComDescribeExecutorTest {
PostgreSQLPacketPayload mockPayload =
mock(PostgreSQLPacketPayload.class);
actualParameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(1);
- verify(mockPayload).writeInt4(PostgreSQLColumnType.INT4.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.INT4.getValue());
PostgreSQLRowDescriptionPacket actualRowDescription =
(PostgreSQLRowDescriptionPacket) actualPacketsIterator.next();
List<PostgreSQLColumnDescription> actualColumnDescriptions =
getColumnDescriptions(actualRowDescription);
List<PostgreSQLColumnDescription> expectedColumnDescriptions =
Arrays.asList(
@@ -430,7 +430,7 @@ class PostgreSQLComDescribeExecutorTest {
prepareJDBCBackendConnectionWithNullMetaData(sql);
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- List<PostgreSQLColumnType> parameterTypes = new ArrayList<>();
+ List<PostgreSQLBinaryColumnType> parameterTypes = new ArrayList<>();
List<Integer> parameterIndexes = Collections.emptyList();
ConnectionContext connectionContext = mock(ConnectionContext.class);
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.of(DATABASE_NAME));
@@ -456,7 +456,7 @@ class PostgreSQLComDescribeExecutorTest {
SQLStatement sqlStatement = SQL_PARSER_ENGINE.parse(sql, false);
SQLStatementContext sqlStatementContext =
mock(SelectStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(Collections.singleton(PostgreSQLColumnType.INT4));
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(Collections.singleton(PostgreSQLBinaryColumnType.INT4));
List<Integer> parameterIndexes = IntStream.range(0,
sqlStatement.getParameterCount()).boxed().collect(Collectors.toList());
PostgreSQLServerPreparedStatement preparedStatement =
mock(PostgreSQLServerPreparedStatement.class);
when(preparedStatement.describeRows()).thenReturn(Optional.empty(),
Optional.of(PostgreSQLNoDataPacket.getInstance()));
@@ -479,7 +479,7 @@ class PostgreSQLComDescribeExecutorTest {
PostgreSQLPacketPayload mockPayload =
mock(PostgreSQLPacketPayload.class);
parameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(1);
- verify(mockPayload).writeInt4(PostgreSQLColumnType.INT4.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.INT4.getValue());
assertThat(actualIterator.next(),
is(PostgreSQLNoDataPacket.getInstance()));
}
@@ -493,7 +493,7 @@ class PostgreSQLComDescribeExecutorTest {
SQLStatementContext sqlStatementContext =
mock(SelectStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
prepareJDBCBackendConnectionWithParamTypes(sql, new
int[]{Types.INTEGER, Types.SMALLINT}, new String[]{"int4", "int2"});
- List<PostgreSQLColumnType> parameterTypes = new
ArrayList<>(Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.UNSPECIFIED));
+ List<PostgreSQLBinaryColumnType> parameterTypes = new
ArrayList<>(Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.UNSPECIFIED));
List<Integer> parameterIndexes = IntStream.range(0,
sqlStatement.getParameterCount()).boxed().collect(Collectors.toList());
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
@@ -508,8 +508,8 @@ class PostgreSQLComDescribeExecutorTest {
PostgreSQLPacketPayload mockPayload =
mock(PostgreSQLPacketPayload.class);
parameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(2);
- verify(mockPayload).writeInt4(PostgreSQLColumnType.INT4.getValue());
- verify(mockPayload).writeInt4(PostgreSQLColumnType.INT2.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.INT4.getValue());
+
verify(mockPayload).writeInt4(PostgreSQLBinaryColumnType.INT2.getValue());
}
private ContextManager mockContextManager() {
@@ -656,15 +656,15 @@ class PostgreSQLComDescribeExecutorTest {
Arguments.of("returning complex columns",
"S_returning_complex",
"INSERT INTO t_order (k, c, pad) VALUES (?, ?, ?)
RETURNING"
+ " id, id alias_id, 'anonymous', 'OK'
literal_string, 1 literal_int, 4294967296 literal_bigint, 1.1 literal_numeric,
t_order.*, t_order, t_order alias_t_order",
- Arrays.asList(PostgreSQLColumnType.INT4,
PostgreSQLColumnType.CHAR, PostgreSQLColumnType.CHAR),
+ Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.CHAR, PostgreSQLBinaryColumnType.CHAR),
getExpectedReturningColumns()),
Arguments.of("returning numeric literal",
"S_numeric_returning",
"INSERT INTO t_order (k) VALUES (?) RETURNING 1.2
numeric_value",
- Collections.singletonList(PostgreSQLColumnType.INT4),
+
Collections.singletonList(PostgreSQLBinaryColumnType.INT4),
Collections.singletonList(expectedColumn("numeric_value", Types.NUMERIC, -1,
"numeric"))),
Arguments.of("returning boolean literal",
"S_boolean_returning",
"INSERT INTO t_order (k) VALUES (?) RETURNING true
bool_value",
- Collections.singletonList(PostgreSQLColumnType.INT4),
+
Collections.singletonList(PostgreSQLBinaryColumnType.INT4),
Collections.singletonList(expectedColumn("bool_value",
Types.VARCHAR, -1, "varchar"))),
Arguments.of("returning without parameters",
"S_returning_only",
"INSERT INTO t_order VALUES (1) RETURNING id",
diff --git
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
index 87e946007a6..cef1899bb96 100644
---
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
+++
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.protocol.packet.DatabasePacket;
-import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLBinaryColumnType;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.parse.PostgreSQLComParsePacket;
import
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.parse.PostgreSQLParseCompletePacket;
import
org.apache.shardingsphere.distsql.statement.type.ral.queryable.show.ShowDistVariableStatement;
@@ -115,7 +115,7 @@ class PostgreSQLComParseExecutorTest {
final String statementId = "S_2";
when(parsePacket.getSQL()).thenReturn(rawSQL);
when(parsePacket.getStatementId()).thenReturn(statementId);
-
when(parsePacket.readParameterTypes()).thenReturn(Collections.singletonList(PostgreSQLColumnType.INT4));
+
when(parsePacket.readParameterTypes()).thenReturn(Collections.singletonList(PostgreSQLBinaryColumnType.INT4));
when(parsePacket.getHintValueContext()).thenReturn(new
HintValueContext());
when(connectionSession.getCurrentDatabaseName()).thenReturn("foo_db");
Plugins.getMemberAccessor().set(PostgreSQLComParseExecutor.class.getDeclaredField("connectionSession"),
executor, connectionSession);
@@ -128,7 +128,7 @@ class PostgreSQLComParseExecutorTest {
assertThat(actualPreparedStatement.getSqlStatementContext(),
isA(InsertStatementContext.class));
assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(),
isA(InsertStatement.class));
assertThat(actualPreparedStatement.getSql(), is(expectedSQL));
- assertThat(actualPreparedStatement.getParameterTypes(),
is(Arrays.asList(PostgreSQLColumnType.INT4, PostgreSQLColumnType.UNSPECIFIED)));
+ assertThat(actualPreparedStatement.getParameterTypes(),
is(Arrays.asList(PostgreSQLBinaryColumnType.INT4,
PostgreSQLBinaryColumnType.UNSPECIFIED)));
}
@Test
@@ -139,14 +139,14 @@ class PostgreSQLComParseExecutorTest {
when(parsePacket.getSQL()).thenReturn(rawSQL);
when(parsePacket.getHintValueContext()).thenReturn(new
HintValueContext());
when(parsePacket.getStatementId()).thenReturn(statementId);
-
when(parsePacket.readParameterTypes()).thenReturn(Arrays.asList(PostgreSQLColumnType.JSON,
PostgreSQLColumnType.INT4));
+
when(parsePacket.readParameterTypes()).thenReturn(Arrays.asList(PostgreSQLBinaryColumnType.JSON,
PostgreSQLBinaryColumnType.INT4));
Plugins.getMemberAccessor().set(PostgreSQLComParseExecutor.class.getDeclaredField("connectionSession"),
executor, connectionSession);
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
executor.execute();
PostgreSQLServerPreparedStatement actualPreparedStatement =
connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(statementId);
assertThat(actualPreparedStatement.getSql(), is(expectedSQL));
- assertThat(actualPreparedStatement.getParameterTypes(),
is(Arrays.asList(PostgreSQLColumnType.JSON, PostgreSQLColumnType.INT4)));
+ assertThat(actualPreparedStatement.getParameterTypes(),
is(Arrays.asList(PostgreSQLBinaryColumnType.JSON,
PostgreSQLBinaryColumnType.INT4)));
assertThat(actualPreparedStatement.getActualParameterMarkerIndexes(),
is(Arrays.asList(1, 0)));
}