You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by az...@apache.org on 2023/06/01 07:41:35 UTC
[shardingsphere] branch master updated: Add PostgreSQLTextValueParser (#25982)
This is an automated email from the ASF dual-hosted git repository.
azexin 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 498c2f79f97 Add PostgreSQLTextValueParser (#25982)
498c2f79f97 is described below
commit 498c2f79f977a6eab2fcec454fbc1c3f916457d1
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jun 1 15:41:26 2023 +0800
Add PostgreSQLTextValueParser (#25982)
* Refactor PostgreSQLComBindPacket
* Add PostgreSQLTextValueParser
* Add PostgreSQLTextValueParser
---
.../extended/bind/OpenGaussComBatchBindPacket.java | 41 +-----
.../query/extended/PostgreSQLColumnType.java | 148 ++++++++++++---------
.../extended/bind/PostgreSQLComBindPacket.java | 82 +++---------
.../protocol/text/PostgreSQLTextValueParser.java} | 29 ++--
.../impl/PostgreSQLBitValueParser.java} | 26 ++--
.../text/impl/PostgreSQLBoolValueParser.java} | 22 ++-
.../text/impl/PostgreSQLDateValueParser.java} | 22 ++-
.../text/impl/PostgreSQLDoubleValueParser.java} | 22 ++-
.../text/impl/PostgreSQLFloatValueParser.java} | 22 ++-
.../text/impl/PostgreSQLIntValueParser.java} | 22 ++-
.../impl/PostgreSQLJsonValueParser.java} | 22 +--
.../text/impl/PostgreSQLLongValueParser.java} | 22 ++-
.../text/impl/PostgreSQLNumericValueParser.java} | 30 +++--
.../impl/PostgreSQLTimeValueParser.java} | 21 +--
.../impl/PostgreSQLTimestampValueParser.java} | 19 +--
.../impl/PostgreSQLUnspecifiedValueParser.java} | 23 ++--
.../text/impl/PostgreSQLVarcharValueParser.java} | 22 ++-
.../bind/protocol/util/PostgreSQLTextBitUtils.java | 22 ---
.../impl/PostgreSQLBitValueParserTest.java} | 11 +-
.../impl/PostgreSQLBoolValueParserTest.java} | 13 +-
.../impl/PostgreSQLDateValueParserTest.java} | 16 +--
.../impl/PostgreSQLDoubleValueParserTest.java} | 10 +-
.../impl/PostgreSQLFloatValueParserTest.java} | 10 +-
.../impl/PostgreSQLIntValueParserTest.java} | 10 +-
.../impl/PostgreSQLJsonValueParserTest.java} | 9 +-
.../impl/PostgreSQLLongValueParserTest.java} | 10 +-
.../impl/PostgreSQLNumericValueParserTest.java} | 25 ++--
.../impl/PostgreSQLTimeValueParserTest.java} | 6 +-
.../impl/PostgreSQLTimestampValueParserTest.java} | 6 +-
.../PostgreSQLUnspecifiedValueParserTest.java} | 10 +-
.../impl/PostgreSQLVarcharValueParserTest.java} | 10 +-
.../protocol/util/PostgreSQLTextBitUtilsTest.java | 9 --
.../driver/jdbc/context/JDBCContextTest.java | 8 +-
.../ddlgenerator/PostgreSQLColumnType.java | 8 +-
.../statement/type/OracleDMLStatementVisitor.java | 6 +-
.../postgresql/command/query/extended/Portal.java | 4 +-
36 files changed, 307 insertions(+), 491 deletions(-)
diff --git a/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacket.java b/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacket.java
index 3352c18d789..7fc1fac32b3 100644
--- a/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacket.java
+++ b/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/query/extended/bind/OpenGaussComBatchBindPacket.java
@@ -25,12 +25,8 @@ import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValue
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValue;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValueFactory;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextTimeUtils;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextTimestampUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
-import java.math.BigDecimal;
-import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
@@ -108,42 +104,7 @@ public final class OpenGaussComBatchBindPacket extends OpenGaussCommandPacket {
private Object getTextParameters(final int paramValueLength, final PostgreSQLColumnType paramType) {
String value = payload.getByteBuf().readCharSequence(paramValueLength, payload.getCharset()).toString();
- return getTextParameters(value, paramType);
- }
-
- private Object getTextParameters(final String textValue, final PostgreSQLColumnType columnType) {
- switch (columnType) {
- case BOOL:
- return Boolean.valueOf(textValue);
- case INT2:
- case INT4:
- return Integer.parseInt(textValue);
- case INT8:
- return Long.parseLong(textValue);
- case FLOAT4:
- return Float.parseFloat(textValue);
- case FLOAT8:
- return Double.parseDouble(textValue);
- case NUMERIC:
- try {
- return Integer.parseInt(textValue);
- } catch (final NumberFormatException ignored) {
- }
- try {
- return Long.parseLong(textValue);
- } catch (final NumberFormatException ignored) {
- }
- return new BigDecimal(textValue);
- case DATE:
- return Date.valueOf(textValue);
- case TIME:
- return PostgreSQLTextTimeUtils.parse(textValue);
- case TIMESTAMP:
- case TIMESTAMPTZ:
- return PostgreSQLTextTimestampUtils.parse(textValue);
- default:
- return textValue;
- }
+ return paramType.getTextValueParser().parse(value);
}
private Object getBinaryParameters(final int paramValueLength, final PostgreSQLColumnType columnType) {
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
index 47d97c1d6e5..f3dea2e37d9 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
@@ -22,6 +22,20 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.binary.BinaryColumnType;
import org.apache.shardingsphere.db.protocol.postgresql.exception.PostgreSQLProtocolException;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLBitValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLBoolValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLDateValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLDoubleValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLFloatValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLIntValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLJsonValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLLongValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLNumericValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLTimeValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLTimestampValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLUnspecifiedValueParser;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl.PostgreSQLVarcharValueParser;
import java.sql.Types;
import java.util.HashMap;
@@ -34,130 +48,132 @@ import java.util.Map;
@Getter
public enum PostgreSQLColumnType implements BinaryColumnType {
- UNSPECIFIED(0),
+ UNSPECIFIED(0, new PostgreSQLUnspecifiedValueParser()),
- INT2(21),
+ INT2(21, new PostgreSQLIntValueParser()),
- INT2_ARRAY(1005),
+ INT2_ARRAY(1005, new PostgreSQLVarcharValueParser()),
- INT4(23),
+ INT4(23, new PostgreSQLIntValueParser()),
- INT4_ARRAY(1007),
+ INT4_ARRAY(1007, new PostgreSQLVarcharValueParser()),
- INT8(20),
+ INT8(20, new PostgreSQLLongValueParser()),
- INT8_ARRAY(1016),
+ INT8_ARRAY(1016, new PostgreSQLVarcharValueParser()),
- TEXT(25),
+ TEXT(25, new PostgreSQLVarcharValueParser()),
- TEXT_ARRAY(1009),
+ TEXT_ARRAY(1009, new PostgreSQLVarcharValueParser()),
- NUMERIC(1700),
+ NUMERIC(1700, new PostgreSQLNumericValueParser()),
- NUMERIC_ARRAY(1231),
+ NUMERIC_ARRAY(1231, new PostgreSQLVarcharValueParser()),
- FLOAT4(700),
+ FLOAT4(700, new PostgreSQLFloatValueParser()),
- FLOAT4_ARRAY(1021),
+ FLOAT4_ARRAY(1021, new PostgreSQLVarcharValueParser()),
- FLOAT8(701),
+ FLOAT8(701, new PostgreSQLDoubleValueParser()),
- FLOAT8_ARRAY(1022),
+ FLOAT8_ARRAY(1022, new PostgreSQLVarcharValueParser()),
- BOOL(16),
+ BOOL(16, new PostgreSQLBoolValueParser()),
- BOOL_ARRAY(1000),
+ BOOL_ARRAY(1000, new PostgreSQLVarcharValueParser()),
- DATE(1082),
+ DATE(1082, new PostgreSQLDateValueParser()),
- DATE_ARRAY(1182),
+ DATE_ARRAY(1182, new PostgreSQLVarcharValueParser()),
- TIME(1083),
+ TIME(1083, new PostgreSQLTimeValueParser()),
- TIME_ARRAY(1183),
+ TIME_ARRAY(1183, new PostgreSQLVarcharValueParser()),
- TIMETZ(1266),
+ TIMETZ(1266, new PostgreSQLTimeValueParser()),
- TIMETZ_ARRAY(1270),
+ TIMETZ_ARRAY(1270, new PostgreSQLVarcharValueParser()),
- TIMESTAMP(1114),
+ TIMESTAMP(1114, new PostgreSQLTimestampValueParser()),
- TIMESTAMP_ARRAY(1115),
+ TIMESTAMP_ARRAY(1115, new PostgreSQLVarcharValueParser()),
- TIMESTAMPTZ(1184),
+ TIMESTAMPTZ(1184, new PostgreSQLTimestampValueParser()),
- TIMESTAMPTZ_ARRAY(1185),
+ TIMESTAMPTZ_ARRAY(1185, new PostgreSQLVarcharValueParser()),
- BYTEA(17),
+ BYTEA(17, new PostgreSQLVarcharValueParser()),
- BYTEA_ARRAY(1001),
+ BYTEA_ARRAY(1001, new PostgreSQLVarcharValueParser()),
- VARCHAR(1043),
+ VARCHAR(1043, new PostgreSQLVarcharValueParser()),
- VARCHAR_ARRAY(1015),
+ VARCHAR_ARRAY(1015, new PostgreSQLVarcharValueParser()),
- OID(26),
+ OID(26, new PostgreSQLVarcharValueParser()),
- OID_ARRAY(1028),
+ OID_ARRAY(1028, new PostgreSQLVarcharValueParser()),
- BPCHAR(1042),
+ BPCHAR(1042, new PostgreSQLVarcharValueParser()),
- BPCHAR_ARRAY(1014),
+ BPCHAR_ARRAY(1014, new PostgreSQLVarcharValueParser()),
- MONEY(790),
+ MONEY(790, new PostgreSQLVarcharValueParser()),
- MONEY_ARRAY(791),
+ MONEY_ARRAY(791, new PostgreSQLVarcharValueParser()),
- NAME(19),
+ NAME(19, new PostgreSQLVarcharValueParser()),
- NAME_ARRAY(1003),
+ NAME_ARRAY(1003, new PostgreSQLVarcharValueParser()),
- BIT(1560),
+ BIT(1560, new PostgreSQLBitValueParser()),
- BIT_ARRAY(1561),
+ BIT_ARRAY(1561, new PostgreSQLVarcharValueParser()),
- VOID(2278),
+ VOID(2278, new PostgreSQLVarcharValueParser()),
- INTERVAL(1186),
+ INTERVAL(1186, new PostgreSQLVarcharValueParser()),
- INTERVAL_ARRAY(1187),
+ INTERVAL_ARRAY(1187, new PostgreSQLVarcharValueParser()),
- CHAR(18),
+ CHAR(18, new PostgreSQLVarcharValueParser()),
- CHAR_ARRAY(1002),
+ CHAR_ARRAY(1002, new PostgreSQLVarcharValueParser()),
- VARBIT(1562),
+ VARBIT(1562, new PostgreSQLVarcharValueParser()),
- VARBIT_ARRAY(1563),
+ VARBIT_ARRAY(1563, new PostgreSQLVarcharValueParser()),
- UUID(2950),
+ UUID(2950, new PostgreSQLVarcharValueParser()),
- UUID_ARRAY(2951),
+ UUID_ARRAY(2951, new PostgreSQLVarcharValueParser()),
- XML(142),
+ XML(142, new PostgreSQLVarcharValueParser()),
- XML_ARRAY(143),
+ XML_ARRAY(143, new PostgreSQLVarcharValueParser()),
- POINT(600),
+ POINT(600, new PostgreSQLVarcharValueParser()),
- POINT_ARRAY(1017),
+ POINT_ARRAY(1017, new PostgreSQLVarcharValueParser()),
- BOX(603),
+ BOX(603, new PostgreSQLVarcharValueParser()),
- JSONB_ARRAY(3807),
+ JSONB_ARRAY(3807, new PostgreSQLVarcharValueParser()),
- JSON(114),
+ JSON(114, new PostgreSQLJsonValueParser()),
- JSON_ARRAY(199),
+ JSON_ARRAY(199, new PostgreSQLVarcharValueParser()),
- REF_CURSOR(1790),
+ REF_CURSOR(1790, new PostgreSQLVarcharValueParser()),
- REF_CURSOR_ARRAY(2201);
+ REF_CURSOR_ARRAY(2201, new PostgreSQLVarcharValueParser());
private static final Map<Integer, PostgreSQLColumnType> JDBC_TYPE_AND_COLUMN_TYPE_MAP = new HashMap<>(values().length, 1F);
private final int value;
+ private final PostgreSQLTextValueParser<?> textValueParser;
+
static {
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.TINYINT, INT2);
JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.SMALLINT, INT2);
@@ -200,34 +216,34 @@ public enum PostgreSQLColumnType implements BinaryColumnType {
* @return PostgreSQL column type enum
*/
public static PostgreSQLColumnType valueOfJDBCType(final int jdbcType, final String columnTypeName) {
- if (isPgBit(jdbcType, columnTypeName)) {
+ if (isBit(jdbcType, columnTypeName)) {
return BIT;
}
- if (isPgBool(jdbcType, columnTypeName)) {
+ if (isBool(jdbcType, columnTypeName)) {
return BOOL;
}
return valueOfJDBCType(jdbcType);
}
/**
- * check if pg bit type.
+ * Check if pg PostgreSQL type.
*
* @param jdbcType JDBC type
* @param columnTypeName column type name
* @return whether is PostgreSQL bit
*/
- public static boolean isPgBit(final int jdbcType, final String columnTypeName) {
+ public static boolean isBit(final int jdbcType, final String columnTypeName) {
return Types.BIT == jdbcType && "bit".equalsIgnoreCase(columnTypeName);
}
/**
- * check if pg bit type.
+ * Check if PostgreSQL bit type.
*
* @param jdbcType JDBC type
* @param columnTypeName column type name
* @return whether is PostgreSQL bit
*/
- public static boolean isPgBool(final int jdbcType, final String columnTypeName) {
+ public static boolean isBool(final int jdbcType, final String columnTypeName) {
return Types.BIT == jdbcType && "bool".equalsIgnoreCase(columnTypeName);
}
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
index b2f37d52a14..70c4b14b9b8 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/PostgreSQLComBindPacket.java
@@ -24,15 +24,9 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQ
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValue;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.PostgreSQLBinaryProtocolValueFactory;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextBitUtils;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextJsonUtils;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextTimeUtils;
-import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util.PostgreSQLTextTimestampUtils;
import org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
-import java.math.BigDecimal;
-import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -40,13 +34,14 @@ import java.util.List;
/**
* Command bind packet for PostgreSQL.
*/
-@Getter
public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
private final PostgreSQLPacketPayload payload;
+ @Getter
private final String portal;
+ @Getter
private final String statementId;
public PostgreSQLComBindPacket(final PostgreSQLPacketPayload payload) {
@@ -63,11 +58,7 @@ public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
* @return values of parameter
*/
public List<Object> readParameters(final List<PostgreSQLColumnType> paramTypes) {
- int parameterFormatCount = payload.readInt2();
- List<Integer> paramFormats = new ArrayList<>(parameterFormatCount);
- for (int i = 0; i < parameterFormatCount; i++) {
- paramFormats.add(payload.readInt2());
- }
+ List<Integer> paramFormats = getParameterFormats();
int parameterCount = payload.readInt2();
List<Object> result = new ArrayList<>(parameterCount);
for (int paramIndex = 0; paramIndex < parameterCount; paramIndex++) {
@@ -77,76 +68,41 @@ public final class PostgreSQLComBindPacket extends PostgreSQLCommandPacket {
continue;
}
Object paramValue = isTextParameterValue(paramFormats, paramIndex)
- ? getTextParameters(payload, parameterValueLength, paramTypes.get(paramIndex))
- : getBinaryParameters(payload, parameterValueLength, paramTypes.get(paramIndex));
+ ? getTextParameterValue(payload, parameterValueLength, paramTypes.get(paramIndex))
+ : getBinaryParameterValue(payload, parameterValueLength, paramTypes.get(paramIndex));
result.add(paramValue);
}
return result;
}
+ private List<Integer> getParameterFormats() {
+ int parameterFormatCount = payload.readInt2();
+ List<Integer> result = new ArrayList<>(parameterFormatCount);
+ for (int i = 0; i < parameterFormatCount; i++) {
+ result.add(payload.readInt2());
+ }
+ return result;
+ }
+
private boolean isTextParameterValue(final List<Integer> paramFormats, final int paramIndex) {
if (paramFormats.isEmpty()) {
return true;
}
- if (1 == paramFormats.size()) {
- return 0 == paramFormats.get(0);
- }
- return 0 == paramFormats.get(paramIndex);
+ return PostgreSQLValueFormat.TEXT.getCode() == paramFormats.get(1 == paramFormats.size() ? 0 : paramIndex);
}
- private Object getTextParameters(final PostgreSQLPacketPayload payload, final int paramValueLength, final PostgreSQLColumnType paramType) {
+ private Object getTextParameterValue(final PostgreSQLPacketPayload payload, final int paramValueLength, final PostgreSQLColumnType paramType) {
String value = payload.getByteBuf().readCharSequence(paramValueLength, payload.getCharset()).toString();
- return getTextParameters(value, paramType);
- }
-
- private Object getTextParameters(final String textValue, final PostgreSQLColumnType paramType) {
- switch (paramType) {
- case UNSPECIFIED:
- return new PostgreSQLTypeUnspecifiedSQLParameter(textValue);
- case BOOL:
- return Boolean.valueOf(textValue);
- case INT2:
- case INT4:
- return Integer.parseInt(textValue);
- case INT8:
- return Long.parseLong(textValue);
- case FLOAT4:
- return Float.parseFloat(textValue);
- case FLOAT8:
- return Double.parseDouble(textValue);
- case NUMERIC:
- try {
- return Integer.parseInt(textValue);
- } catch (final NumberFormatException ignored) {
- }
- try {
- return Long.parseLong(textValue);
- } catch (final NumberFormatException ignored) {
- }
- return new BigDecimal(textValue);
- case DATE:
- return Date.valueOf(textValue);
- case TIME:
- return PostgreSQLTextTimeUtils.parse(textValue);
- case TIMESTAMP:
- case TIMESTAMPTZ:
- return PostgreSQLTextTimestampUtils.parse(textValue);
- case JSON:
- return PostgreSQLTextJsonUtils.parse(textValue);
- case BIT:
- return PostgreSQLTextBitUtils.parse(textValue);
- default:
- return textValue;
- }
+ return paramType.getTextValueParser().parse(value);
}
- private Object getBinaryParameters(final PostgreSQLPacketPayload payload, final int paramValueLength, final PostgreSQLColumnType paramType) {
+ private Object getBinaryParameterValue(final PostgreSQLPacketPayload payload, final int paramValueLength, final PostgreSQLColumnType paramType) {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(paramType);
return binaryProtocolValue.read(payload, paramValueLength);
}
/**
- * Read result formats from Bind message.
+ * Read result formats from bind message.
*
* @return formats of value
*/
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/PostgreSQLTextValueParser.java
similarity index 63%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/PostgreSQLTextValueParser.java
index a9c969ecf5f..9bd57025f32 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/PostgreSQLTextValueParser.java
@@ -15,21 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Text value parser of PostgreSQL.
+ *
+ * @param <T> type of parsed value
+ */
+public interface PostgreSQLTextValueParser<T> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
- }
+ /**
+ * Parse text value to current type.
+ *
+ * @param value text value
+ * @return parsed value
+ */
+ T parse(String value);
}
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtils.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParser.java
similarity index 65%
copy from db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtils.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParser.java
index a839a87cf4c..ab31d1c3ed7 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtils.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParser.java
@@ -15,35 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.wrapper.SQLWrapperException;
import org.postgresql.util.PGobject;
import java.sql.SQLException;
/**
- * Text Json utility class of PostgreSQL.
+ * Bit value parser of PostgreSQL.
*/
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class PostgreSQLTextJsonUtils {
+public final class PostgreSQLBitValueParser implements PostgreSQLTextValueParser<PGobject> {
- /**
- * Parse json in PostgreSQL text format.
- *
- * @param jsonText text value to be parsed
- * @return json PostgreSQL object
- * @throws SQLWrapperException thrown if value is invalid for json type
- */
- public static PGobject parse(final String jsonText) {
+ @Override
+ public PGobject parse(final String value) {
try {
PGobject result = new PGobject();
- result.setType("json");
- result.setValue(jsonText);
+ result.setType("bit");
+ result.setValue(value);
return result;
- } catch (final SQLException ex) {
+ } catch (SQLException ex) {
throw new SQLWrapperException(ex);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBoolValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBoolValueParser.java
index a9c969ecf5f..a2b1ff4f929 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBoolValueParser.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Bool value parser of PostgreSQL.
+ */
+public final class PostgreSQLBoolValueParser implements PostgreSQLTextValueParser<Boolean> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Boolean parse(final String value) {
+ return Boolean.valueOf(value);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParser.java
index a9c969ecf5f..7f94c7a2625 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParser.java
@@ -15,21 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import java.sql.Date;
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Date value parser of PostgreSQL.
+ */
+public final class PostgreSQLDateValueParser implements PostgreSQLTextValueParser<Date> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Date parse(final String value) {
+ return Date.valueOf(value);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDoubleValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDoubleValueParser.java
index a9c969ecf5f..af64a0bdad9 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDoubleValueParser.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Double value parser of PostgreSQL.
+ */
+public final class PostgreSQLDoubleValueParser implements PostgreSQLTextValueParser<Double> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Double parse(final String value) {
+ return Double.parseDouble(value);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLFloatValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLFloatValueParser.java
index a9c969ecf5f..f6efa1f3352 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLFloatValueParser.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Float value parser of PostgreSQL.
+ */
+public final class PostgreSQLFloatValueParser implements PostgreSQLTextValueParser<Float> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Float parse(final String value) {
+ return Float.parseFloat(value);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLIntValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLIntValueParser.java
index a9c969ecf5f..5be4df836c7 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLIntValueParser.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Int value parser of PostgreSQL.
+ */
+public final class PostgreSQLIntValueParser implements PostgreSQLTextValueParser<Integer> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Integer parse(final String value) {
+ return Integer.parseInt(value);
}
}
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtils.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParser.java
similarity index 69%
rename from db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtils.java
rename to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParser.java
index a839a87cf4c..554c375af24 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtils.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParser.java
@@ -15,33 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.wrapper.SQLWrapperException;
import org.postgresql.util.PGobject;
import java.sql.SQLException;
/**
- * Text Json utility class of PostgreSQL.
+ * Json value parser of PostgreSQL.
*/
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class PostgreSQLTextJsonUtils {
+public final class PostgreSQLJsonValueParser implements PostgreSQLTextValueParser<PGobject> {
- /**
- * Parse json in PostgreSQL text format.
- *
- * @param jsonText text value to be parsed
- * @return json PostgreSQL object
- * @throws SQLWrapperException thrown if value is invalid for json type
- */
- public static PGobject parse(final String jsonText) {
+ @Override
+ public PGobject parse(final String value) {
try {
PGobject result = new PGobject();
result.setType("json");
- result.setValue(jsonText);
+ result.setValue(value);
return result;
} catch (final SQLException ex) {
throw new SQLWrapperException(ex);
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLLongValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLLongValueParser.java
index a9c969ecf5f..7a979dc1ab9 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLLongValueParser.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Long value parser of PostgreSQL.
+ */
+public final class PostgreSQLLongValueParser implements PostgreSQLTextValueParser<Long> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Long parse(final String value) {
+ return Long.parseLong(value);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLNumericValueParser.java
similarity index 55%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLNumericValueParser.java
index a9c969ecf5f..fde93c9265b 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLNumericValueParser.java
@@ -15,21 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import java.math.BigDecimal;
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Numeric value parser of PostgreSQL.
+ */
+public final class PostgreSQLNumericValueParser implements PostgreSQLTextValueParser<Number> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public Number parse(final String value) {
+ try {
+ return Integer.parseInt(value);
+ } catch (final NumberFormatException ignored) {
+ }
+ try {
+ return Long.parseLong(value);
+ } catch (final NumberFormatException ignored) {
+ }
+ return new BigDecimal(value);
}
}
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimeUtils.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParser.java
similarity index 72%
rename from db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimeUtils.java
rename to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParser.java
index eb6619c9a4c..35d09442920 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimeUtils.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParser.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
import java.time.LocalTime;
@@ -26,10 +25,9 @@ import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
/**
- * Text time utility class of PostgreSQL.
+ * Time value parser of PostgreSQL.
*/
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class PostgreSQLTextTimeUtils {
+public final class PostgreSQLTimeValueParser implements PostgreSQLTextValueParser<LocalTime> {
private static final DateTimeFormatter POSTGRESQL_TIME_FORMATTER = DateTimeFormatter.ofPattern(
"[HH:mm:ss][HHmmss][HH:mm][HHmm]"
@@ -37,15 +35,8 @@ public final class PostgreSQLTextTimeUtils {
+ "[ ]"
+ "[XXXXX][XXXX][XXX][XX][X]");
- /**
- * Parse time in PostgreSQL text format.<br>
- * NOTICE: PostgreSQL allows 6 fractional digits retained in the seconds field, which is unsupported by {@link java.sql.Time}.
- *
- * @param value text value to be parsed
- * @return time
- * @throws UnsupportedSQLOperationException unsupported SQL operation exception
- */
- public static LocalTime parse(final String value) {
+ @Override
+ public LocalTime parse(final String value) {
try {
return POSTGRESQL_TIME_FORMATTER.parse(value, LocalTime::from);
} catch (final DateTimeParseException ignored) {
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimestampUtils.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParser.java
similarity index 83%
rename from db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimestampUtils.java
rename to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParser.java
index e10f450d7fa..5407751e8ca 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimestampUtils.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParser.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.wrapper.SQLWrapperException;
import org.postgresql.jdbc.TimestampUtils;
@@ -29,10 +28,9 @@ import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
/**
- * Text timestamp utility class of PostgreSQL.
+ * Timestamp value parser of PostgreSQL.
*/
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class PostgreSQLTextTimestampUtils {
+public final class PostgreSQLTimestampValueParser implements PostgreSQLTextValueParser<Timestamp> {
private static final DateTimeFormatter POSTGRESQL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(
"[yyyy-MM-dd][yyyy_MM_dd][yyyyMMdd][yyyy-M-d][MM/dd/yy][yyMMdd]"
@@ -42,13 +40,8 @@ public final class PostgreSQLTextTimestampUtils {
+ "[ ]"
+ "[XXXXX][XXXX][XXX][XX][X]");
- /**
- * Parse timestamp in PostgreSQL text format.
- *
- * @param value text value to be parsed
- * @return timestamp
- */
- public static Timestamp parse(final String value) {
+ @Override
+ public Timestamp parse(final String value) {
try {
return Timestamp.valueOf(LocalDateTime.from(POSTGRESQL_DATE_TIME_FORMATTER.parse(value)));
} catch (final DateTimeParseException ignored) {
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLUnspecifiedValueParser.java
similarity index 57%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLUnspecifiedValueParser.java
index a9c969ecf5f..1263e0c5752 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLUnspecifiedValueParser.java
@@ -15,21 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLTypeUnspecifiedSQLParameter;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Unspecified value parser of PostgreSQL.
+ */
+public final class PostgreSQLUnspecifiedValueParser implements PostgreSQLTextValueParser<PostgreSQLTypeUnspecifiedSQLParameter> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public PostgreSQLTypeUnspecifiedSQLParameter parse(final String value) {
+ return new PostgreSQLTypeUnspecifiedSQLParameter(value);
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharValueParser.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharValueParser.java
index a9c969ecf5f..b9522e05e9f 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharValueParser.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
-import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.PostgreSQLTextValueParser;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLTextJsonUtilsTest {
+/**
+ * Varchar value parser of PostgreSQL.
+ */
+public final class PostgreSQLVarcharValueParser implements PostgreSQLTextValueParser<String> {
- @Test
- void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ @Override
+ public String parse(final String value) {
+ return value;
}
}
diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtils.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtils.java
index 0ff35d2fe09..a7a4057c37c 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtils.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtils.java
@@ -19,10 +19,6 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.util.exception.external.sql.type.wrapper.SQLWrapperException;
-import org.postgresql.util.PGobject;
-
-import java.sql.SQLException;
/**
* Text bit utility class of PostgreSQL.
@@ -30,24 +26,6 @@ import java.sql.SQLException;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PostgreSQLTextBitUtils {
- /**
- * Parse bit in PostgreSQL text format.
- *
- * @param bitText text value to be parsed
- * @return bit PostgreSQL object
- * @throws SQLWrapperException thrown if value is invalid for bit type
- */
- public static PGobject parse(final String bitText) {
- try {
- PGobject result = new PGobject();
- result.setType("bit");
- result.setValue(bitText);
- return result;
- } catch (SQLException ex) {
- throw new SQLWrapperException(ex);
- }
- }
-
/**
* Get bit Text value in PostgreSQL text format.
*
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
similarity index 78%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
index a9c969ecf5f..7eca860ee08 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
import org.postgresql.util.PGobject;
@@ -23,13 +23,12 @@ import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLBitValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ PGobject actual = new PostgreSQLBitValueParser().parse("1");
+ assertThat(actual.getType(), is("bit"));
+ assertThat(actual.getValue(), is("1"));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBoolValueParserTest.java
similarity index 69%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBoolValueParserTest.java
index a9c969ecf5f..bf970370043 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBoolValueParserTest.java
@@ -15,21 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLBoolValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertTrue(new PostgreSQLBoolValueParser().parse("true"));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParserTest.java
similarity index 73%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParserTest.java
index a9c969ecf5f..a2683083d5b 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParserTest.java
@@ -15,21 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
-import static org.hamcrest.CoreMatchers.is;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.Date;
+
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLDateValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLDateValueParser().parse("2020-01-01"), is(Date.from(LocalDate.of(2020, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDoubleValueParserTest.java
similarity index 76%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDoubleValueParserTest.java
index a9c969ecf5f..79340184a45 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDoubleValueParserTest.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLDoubleValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLDoubleValueParser().parse("1"), is(1D));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLFloatValueParserTest.java
similarity index 76%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLFloatValueParserTest.java
index a9c969ecf5f..20fa15a53a6 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLFloatValueParserTest.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLFloatValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLFloatValueParser().parse("1"), is(1F));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLIntValueParserTest.java
similarity index 76%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLIntValueParserTest.java
index a9c969ecf5f..a2260c17bdd 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLIntValueParserTest.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLIntValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLIntValueParser().parse("1"), is(1));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParserTest.java
similarity index 82%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParserTest.java
index a9c969ecf5f..ab98f3912e0 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParserTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
import org.postgresql.util.PGobject;
@@ -23,13 +23,12 @@ import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLJsonValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
+ PGobject actual = new PostgreSQLJsonValueParser().parse("['input']");
assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(actual.getValue(), is("['input']"));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLLongValueParserTest.java
similarity index 76%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLLongValueParserTest.java
index a9c969ecf5f..9e593eb0efa 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLLongValueParserTest.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLLongValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLLongValueParser().parse("1"), is(1L));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLNumericValueParserTest.java
similarity index 64%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLNumericValueParserTest.java
index a67a65cd48b..e110cf77d72 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLNumericValueParserTest.java
@@ -15,28 +15,29 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
+
+import java.math.BigDecimal;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextBitUtilsTest {
+class PostgreSQLNumericValueParserTest {
+
+ @Test
+ void assertParseWithInt() {
+ assertThat(new PostgreSQLNumericValueParser().parse("1"), is(1));
+ }
@Test
- void assertParse() {
- String textValue = "1";
- PGobject actual = PostgreSQLTextBitUtils.parse(textValue);
- assertThat(actual.getType(), is("bit"));
- assertThat(actual.getValue(), is(textValue));
+ void assertParseWithLong() {
+ assertThat(new PostgreSQLNumericValueParser().parse(Long.valueOf(Long.MAX_VALUE).toString()), is(Long.MAX_VALUE));
}
@Test
- void assertGetTextBitValue() {
- Object jdbcBitValue = true;
- String textValue = PostgreSQLTextBitUtils.getTextValue(jdbcBitValue);
- assertThat(textValue, is("1"));
+ void assertParseWithBigDecimal() {
+ assertThat(new PostgreSQLNumericValueParser().parse(Long.MAX_VALUE + "0"), is(new BigDecimal(Long.MAX_VALUE + "0")));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimeUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParserTest.java
similarity index 95%
rename from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimeUtilsTest.java
rename to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParserTest.java
index eda01e6b5f6..f6475f73ff3 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimeUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParserTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
@@ -29,12 +29,12 @@ import java.util.stream.Stream;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextTimeUtilsTest {
+class PostgreSQLTimeValueParserTest {
@ParameterizedTest(name = "{0}")
@ArgumentsSource(TestCaseArgumentsProvider.class)
void assertParse(final String input, final LocalTime expected) {
- assertThat(PostgreSQLTextTimeUtils.parse(input), is(expected));
+ assertThat(new PostgreSQLTimeValueParser().parse(input), is(expected));
}
private static class TestCaseArgumentsProvider implements ArgumentsProvider {
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimestampUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
similarity index 96%
rename from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimestampUtilsTest.java
rename to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
index 8ac379eae66..267eb74c81c 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextTimestampUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
@@ -29,12 +29,12 @@ import java.util.stream.Stream;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextTimestampUtilsTest {
+class PostgreSQLTimestampValueParserTest {
@ParameterizedTest(name = "{0}")
@ArgumentsSource(TestCaseArgumentsProvider.class)
void assertGetLocalDateTimeNoExceptionOccurs(final String input, final Timestamp expected) {
- assertThat(PostgreSQLTextTimestampUtils.parse(input), is(expected));
+ assertThat(new PostgreSQLTimestampValueParser().parse(input), is(expected));
}
private static class TestCaseArgumentsProvider implements ArgumentsProvider {
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLUnspecifiedValueParserTest.java
similarity index 76%
copy from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
copy to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLUnspecifiedValueParserTest.java
index a9c969ecf5f..edf17b0b3d6 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLUnspecifiedValueParserTest.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLUnspecifiedValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLUnspecifiedValueParser().parse("1").toString(), is("1"));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharValueParserTest.java
similarity index 76%
rename from db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
rename to db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharValueParserTest.java
index a9c969ecf5f..a08214b5ba6 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextJsonUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharValueParserTest.java
@@ -15,21 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
+package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-class PostgreSQLTextJsonUtilsTest {
+class PostgreSQLVarcharValueParserTest {
@Test
void assertParse() {
- String textValue = "['input']";
- PGobject actual = PostgreSQLTextJsonUtils.parse(textValue);
- assertThat(actual.getType(), is("json"));
- assertThat(actual.getValue(), is(textValue));
+ assertThat(new PostgreSQLVarcharValueParser().parse("1"), is("1"));
}
}
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java
index a67a65cd48b..b1dd8e27369 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/util/PostgreSQLTextBitUtilsTest.java
@@ -18,21 +18,12 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol.util;
import org.junit.jupiter.api.Test;
-import org.postgresql.util.PGobject;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
class PostgreSQLTextBitUtilsTest {
- @Test
- void assertParse() {
- String textValue = "1";
- PGobject actual = PostgreSQLTextBitUtils.parse(textValue);
- assertThat(actual.getType(), is("bit"));
- assertThat(actual.getValue(), is(textValue));
- }
-
@Test
void assertGetTextBitValue() {
Object jdbcBitValue = true;
diff --git a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/context/JDBCContextTest.java b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/context/JDBCContextTest.java
index 137624f78d0..7f76de99535 100644
--- a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/context/JDBCContextTest.java
+++ b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/context/JDBCContextTest.java
@@ -34,20 +34,20 @@ import static org.mockito.Mockito.mock;
@ExtendWith(MockitoExtension.class)
class JDBCContextTest {
-
+
@Test
void assertNullCachedDbMetadataWithEmptyDatasource() throws Exception {
JDBCContext actual = new JDBCContext(new HashMap<>());
assertNull(actual.getCachedDatabaseMetaData());
}
-
+
@Test
void assertNotNullCashedDbMetadataWith() throws SQLException {
Map<String, DataSource> dataSourceMap = getStringDataSourceMap();
JDBCContext jdbcContext = new JDBCContext(dataSourceMap);
assertNotNull(jdbcContext.getCachedDatabaseMetaData());
}
-
+
@Test
void assetNullMetadataAfterRefreshingExisting() throws SQLException {
Map<String, DataSource> stringDataSourceMap = getStringDataSourceMap();
@@ -56,7 +56,7 @@ class JDBCContextTest {
jdbcContext.refreshCachedDatabaseMetaData(event);
assertNull(jdbcContext.getCachedDatabaseMetaData());
}
-
+
private static Map<String, DataSource> getStringDataSourceMap() {
Map<String, DataSource> result = new HashMap<>();
result.put("test_db", new CircuitBreakerDataSource());
diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java
index 3266e468f8b..649a20e900b 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgreSQLColumnType.java
@@ -27,13 +27,13 @@ import java.util.Arrays;
@RequiredArgsConstructor
public enum PostgreSQLColumnType {
- NUMERIC(new Long[] {1231L, 1700L}),
+ NUMERIC(new Long[]{1231L, 1700L}),
- DATE(new Long[] {1083L, 1114L, 1115L, 1183L, 1184L, 1185L, 1186L, 1187L, 1266L, 1270L}),
+ DATE(new Long[]{1083L, 1114L, 1115L, 1183L, 1184L, 1185L, 1186L, 1187L, 1266L, 1270L}),
- VARCHAR(new Long[] {1560L, 1561L, 1562L, 1563L, 1042L, 1043L, 1014L, 1015L}),
+ VARCHAR(new Long[]{1560L, 1561L, 1562L, 1563L, 1042L, 1043L, 1014L, 1015L}),
- UNKNOWN(new Long[] {});
+ UNKNOWN(new Long[]{});
private final Long[] values;
diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
index f08f3512bc2..9f289342724 100644
--- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
+++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java
@@ -732,7 +732,7 @@ public final class OracleDMLStatementVisitor extends OracleStatementVisitor impl
return null == datetimeExpression.getRight()
? new DatetimeProjectionSegment(datetimeExpression.getStartIndex(), datetimeExpression.getStopIndex(), datetimeExpression.getLeft(), datetimeExpression.getText())
: new DatetimeProjectionSegment(datetimeExpression.getStartIndex(), datetimeExpression.getStopIndex(),
- datetimeExpression.getLeft(), datetimeExpression.getRight(), datetimeExpression.getText());
+ datetimeExpression.getLeft(), datetimeExpression.getRight(), datetimeExpression.getText());
}
if (projection instanceof XmlQueryAndExistsFunctionSegment) {
XmlQueryAndExistsFunctionSegment xmlExistsFunctionSegment = (XmlQueryAndExistsFunctionSegment) projection;
@@ -743,9 +743,9 @@ public final class OracleDMLStatementVisitor extends OracleStatementVisitor impl
XmlPiFunctionSegment xmlPiFunctionSegment = (XmlPiFunctionSegment) projection;
return null == xmlPiFunctionSegment.getIdentifier()
? new XmlPiFunctionSegment(xmlPiFunctionSegment.getStartIndex(), xmlPiFunctionSegment.getStopIndex(),
- xmlPiFunctionSegment.getFunctionName(), xmlPiFunctionSegment.getEvalNameValueExpr(), xmlPiFunctionSegment.getValueExpr(), xmlPiFunctionSegment.getText())
+ xmlPiFunctionSegment.getFunctionName(), xmlPiFunctionSegment.getEvalNameValueExpr(), xmlPiFunctionSegment.getValueExpr(), xmlPiFunctionSegment.getText())
: new XmlPiFunctionSegment(xmlPiFunctionSegment.getStartIndex(), xmlPiFunctionSegment.getStopIndex(),
- xmlPiFunctionSegment.getFunctionName(), xmlPiFunctionSegment.getIdentifier(), xmlPiFunctionSegment.getValueExpr(), xmlPiFunctionSegment.getText());
+ xmlPiFunctionSegment.getFunctionName(), xmlPiFunctionSegment.getIdentifier(), xmlPiFunctionSegment.getValueExpr(), xmlPiFunctionSegment.getText());
}
if (projection instanceof XmlSerializeFunctionSegment) {
XmlSerializeFunctionSegment xmlSerializeFunctionSegment = (XmlSerializeFunctionSegment) projection;
diff --git a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
index cc375c84cfa..47977e2c646 100644
--- a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
+++ b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/Portal.java
@@ -195,10 +195,10 @@ public final class Portal {
}
private Object getCellData(final QueryResponseCell cell) {
- if (PostgreSQLColumnType.isPgBit(cell.getJdbcType(), cell.getColumnTypeName().orElse(null))) {
+ if (PostgreSQLColumnType.isBit(cell.getJdbcType(), cell.getColumnTypeName().orElse(null))) {
return PostgreSQLTextBitUtils.getTextValue(cell.getData());
}
- if (PostgreSQLColumnType.isPgBool(cell.getJdbcType(), cell.getColumnTypeName().orElse(null))) {
+ if (PostgreSQLColumnType.isBool(cell.getJdbcType(), cell.getColumnTypeName().orElse(null))) {
return PostgreSQLTextBoolUtils.getTextValue(cell.getData());
}
return cell.getData();