You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/09/08 15:03:56 UTC
[shardingsphere] branch master updated: Add UnsupportedSQLOperationException (#20892)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 a4c025be946 Add UnsupportedSQLOperationException (#20892)
a4c025be946 is described below
commit a4c025be9469c27804f428594a2fa095ab0bdcd9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Sep 8 23:03:44 2022 +0800
Add UnsupportedSQLOperationException (#20892)
---
.../user-manual/error-code/sql-error-code.cn.md | 1 +
.../user-manual/error-code/sql-error-code.en.md | 1 +
.../value/blob/MySQLBlobBinlogProtocolValue.java | 3 +-
.../value/string/MySQLJsonBinlogProtocolValue.java | 3 +-
.../column/value/string/MySQLJsonValueDecoder.java | 7 +-
.../string/MySQLStringBinlogProtocolValue.java | 10 +-
.../packet/handshake/MySQLAuthMoreDataPacket.java | 3 +-
.../blob/MySQLBlobBinlogProtocolValueTest.java | 3 +-
.../string/MySQLJsonBinlogProtocolValueTest.java | 3 +-
.../string/MySQLStringBinlogProtocolValueTest.java | 5 +-
.../postgresql/constant/PostgreSQLValueFormat.java | 3 +-
.../protocol/PostgreSQLArrayParameterDecoder.java | 121 ++++++++++-----------
.../PostgreSQLBoolArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLFloat4ArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLFloat8ArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLInt2ArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLInt4ArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLInt8ArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLStringArrayBinaryProtocolValue.java | 5 +-
.../PostgreSQLUnspecifiedBinaryProtocolValue.java | 5 +-
...PostgreSQLBoolArrayBinaryProtocolValueTest.java | 5 +-
...stgreSQLFloat4ArrayBinaryProtocolValueTest.java | 5 +-
...stgreSQLFloat8ArrayBinaryProtocolValueTest.java | 6 +-
...PostgreSQLInt2ArrayBinaryProtocolValueTest.java | 5 +-
...PostgreSQLInt4ArrayBinaryProtocolValueTest.java | 5 +-
...PostgreSQLInt8ArrayBinaryProtocolValueTest.java | 5 +-
...stgreSQLStringArrayBinaryProtocolValueTest.java | 5 +-
...stgreSQLUnspecifiedBinaryProtocolValueTest.java | 5 +-
.../complex/ComplexInlineShardingAlgorithm.java | 9 +-
.../datetime/IntervalShardingAlgorithm.java | 3 +-
.../sharding/inline/InlineShardingAlgorithm.java | 9 +-
.../range/AbstractRangeShardingAlgorithm.java | 3 +-
.../aggregation/AggregationUnitFactory.java | 3 +-
.../update/AddMigrationSourceResourceUpdater.java | 9 +-
.../handler/enums/ShardingStrategyType.java | 7 +-
.../infra/binder/SQLStatementContextFactory.java | 19 ++--
.../statement/CommonSQLStatementContext.java | 3 +-
.../props/DataSourcePropertiesValidator.java | 4 +-
.../query/impl/driver/vertx/VertxQueryResult.java | 5 +-
.../sql/UnsupportedSQLOperationException.java | 16 ++-
.../AbstractUnsupportedOperationConnection.java | 5 +-
.../driver/state/lock/LockDriverState.java | 3 +-
.../UnsupportedOperationConnectionTest.java | 5 +-
.../PipelineDataSourceConfigurationFactory.java | 3 +-
.../spi/sqlbuilder/PipelineSQLBuilder.java | 3 +-
.../pipeline/core/importer/DataRecordMerger.java | 10 +-
.../ingest/dumper/AbstractInventoryDumper.java | 3 +-
.../core/sqlbuilder/OraclePipelineSQLBuilder.java | 3 +-
.../pipeline/mysql/ingest/client/MySQLClient.java | 3 +-
.../client/netty/MySQLNegotiatePackageDecoder.java | 6 +-
.../opengauss/ingest/OpenGaussWalDumper.java | 3 +-
.../postgresql/ingest/PostgreSQLWalDumper.java | 3 +-
.../postgresql/ingest/wal/WalEventConverter.java | 7 +-
.../ingest/wal/WalEventConverterTest.java | 3 +-
.../segment/expression/ExpressionConverter.java | 35 +++---
.../converter/segment/from/TableConverter.java | 11 +-
.../orderby/item/OrderByItemConverterUtil.java | 5 +-
.../translatable/FederationTranslatableTable.java | 7 +-
.../transaction/xa/fixture/DataSourceUtils.java | 5 +-
.../mode/lock/ShardingSphereLockContext.java | 3 +-
.../mode/lock/ShardingSphereLockContextTest.java | 3 +-
.../callback/ProxyJDBCExecutorCallbackFactory.java | 3 +-
.../vertx/VertxBackendConnection.java | 18 +--
.../vertx/VertxBackendDataSource.java | 7 +-
.../vertx/VertxDatabaseCommunicationEngine.java | 3 +-
.../handler/ProxyBackendHandlerFactory.java | 9 +-
.../DatabaseOperateBackendHandlerFactory.java | 5 +-
.../distsql/DistSQLBackendHandlerFactory.java | 5 +-
.../distsql/ral/RALBackendHandlerFactory.java | 8 +-
.../distsql/ral/hint/HintRALBackendHandler.java | 10 +-
.../ral/hint/HintRALStatementExecutorFactory.java | 5 +-
.../distsql/ral/hint/enums/HintSourceType.java | 3 +-
.../ral/updatable/LabelInstanceHandler.java | 7 +-
.../ral/updatable/SetInstanceStatusHandler.java | 26 ++---
.../SetReadwriteSplittingStatusHandler.java | 36 +++---
.../ral/updatable/UnlabelInstanceHandler.java | 7 +-
.../rdl/rule/RuleDefinitionBackendHandler.java | 3 +-
.../distsql/rul/RULBackendHandlerFactory.java | 10 +-
.../handler/ProxyBackendHandlerFactoryTest.java | 3 +-
.../DatabaseOperateBackendHandlerFactoryTest.java | 3 +-
.../session/PreparedStatementRegistryTest.java | 7 +-
.../proxy/frontend/state/impl/LockProxyState.java | 3 +-
.../frontend/state/impl/LockProxyStateTest.java | 3 +-
.../extended/close/PostgreSQLComCloseExecutor.java | 9 +-
.../describe/PostgreSQLComDescribeExecutor.java | 7 +-
.../PostgreSQLComDescribeExecutorTest.java | 3 +-
.../facade/OpenGaussFormatSQLVisitorFacade.java | 13 ++-
.../facade/OracleFormatSQLVisitorFacade.java | 15 +--
.../facade/PostgreSQLFormatSQLVisitorFacade.java | 15 +--
.../format/facade/SQL92FormatSQLVisitorFacade.java | 15 +--
.../facade/SQLServerFormatSQLVisitorFacade.java | 15 +--
.../sql/parser/sql/common/util/SQLUtil.java | 5 +-
.../core/importer/DataRecordMergerTest.java | 3 +-
93 files changed, 399 insertions(+), 348 deletions(-)
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index a7ac7840620..e906cd79ac5 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -94,3 +94,4 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY004 | 28000 | Shadow column \`%s\` of table \`%s\` does not support \`%s\` type |
| 42000 | 28003 | Insert value of index \`%s\` can not support for shadow |
| HY004 | 30000 | Unknown exception: %s |
+| 0A000 | 30001 | Unsupported operation: %s |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 51a760c69c0..d2ba26b3076 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -94,3 +94,4 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| HY004 | 28000 | Shadow column \`%s\` of table \`%s\` does not support \`%s\` type |
| 42000 | 28003 | Insert value of index \`%s\` can not support for shadow |
| HY004 | 30000 | Unknown exception: %s |
+| 0A000 | 30001 | Unsupported operation: %s |
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValue.java
index a05995af2da..66f288b4d6d 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValue.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.val
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.MySQLBinlogProtocolValue;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.io.Serializable;
@@ -44,7 +45,7 @@ public final class MySQLBlobBinlogProtocolValue implements MySQLBinlogProtocolVa
case 4:
return payload.readInt4();
default:
- throw new UnsupportedOperationException("MySQL BLOB type meta in binlog should be range 1 to 4, but actual value is: " + columnMeta);
+ throw new UnsupportedSQLOperationException(String.format("MySQL BLOB type meta in binlog should be range 1 to 4, but actual value is: %s", columnMeta));
}
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
index 6ce0076aefb..be26dd41a6b 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValue.java
@@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.MySQLBinlogProtocolValue;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.io.Serializable;
@@ -59,7 +60,7 @@ public final class MySQLJsonBinlogProtocolValue implements MySQLBinlogProtocolVa
case 4:
return payload.readInt4();
default:
- throw new UnsupportedOperationException("MySQL JSON type meta in binlog should be range 1 to 4, but actual value is: " + columnMeta);
+ throw new UnsupportedSQLOperationException(String.format("MySQL JSON type meta in binlog should be range 1 to 4, but actual value is: %s", columnMeta));
}
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
index 5dd0ad7610e..12d5d54843d 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.val
import io.netty.buffer.ByteBuf;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.io.Serializable;
import java.math.BigInteger;
@@ -89,7 +90,7 @@ public final class MySQLJsonValueDecoder {
outputString(decodeString(byteBuf.slice()), result);
break;
default:
- throw new UnsupportedOperationException(String.valueOf(type));
+ throw new UnsupportedSQLOperationException(String.valueOf(type));
}
} finally {
byteBuf.readerIndex(oldOffset);
@@ -180,7 +181,7 @@ public final class MySQLJsonValueDecoder {
outputLiteral(getIntBasedObjectSize(byteBuf, isSmall), stringBuilder);
break;
default:
- throw new UnsupportedOperationException(String.valueOf(type));
+ throw new UnsupportedSQLOperationException(String.valueOf(type));
}
}
@@ -200,7 +201,7 @@ public final class MySQLJsonValueDecoder {
out.append("false");
break;
default:
- throw new UnsupportedOperationException(String.valueOf(inlineValue));
+ throw new UnsupportedSQLOperationException(String.valueOf(inlineValue));
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
index 25d6bf4a73e..4dcfcb10841 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValue.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnTyp
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.MySQLBinlogProtocolValue;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.io.Serializable;
@@ -46,15 +47,12 @@ public final class MySQLStringBinlogProtocolValue implements MySQLBinlogProtocol
case MYSQL_TYPE_STRING:
return payload.readStringFix(readActualLength(length, payload));
default:
- throw new UnsupportedOperationException("");
+ throw new UnsupportedSQLOperationException(MySQLBinaryColumnType.valueOf(type).toString());
}
}
private int readActualLength(final int length, final MySQLPacketPayload payload) {
- if (length < 256) {
- return payload.getByteBuf().readUnsignedByte();
- }
- return payload.getByteBuf().readUnsignedShortLE();
+ return length < 256 ? payload.getByteBuf().readUnsignedByte() : payload.getByteBuf().readUnsignedShortLE();
}
private Serializable readEnumValue(final int meta, final MySQLPacketPayload payload) {
@@ -64,7 +62,7 @@ public final class MySQLStringBinlogProtocolValue implements MySQLBinlogProtocol
case 2:
return payload.readInt2();
default:
- throw new UnsupportedOperationException("MySQL Enum meta in binlog only include value 1 or 2, but actual is " + meta);
+ throw new UnsupportedSQLOperationException(String.format("MySQL Enum meta in binlog only include value 1 or 2, but actual is %s", meta));
}
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthMoreDataPacket.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthMoreDataPacket.java
index 005e8859cc0..88ceafb324c 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthMoreDataPacket.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/handshake/MySQLAuthMoreDataPacket.java
@@ -22,6 +22,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* MySQL authentication switch request packet.
@@ -50,6 +51,6 @@ public final class MySQLAuthMoreDataPacket implements MySQLPacket {
@Override
public void write(final MySQLPacketPayload payload) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("MySQLAuthMoreDataPacket.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
index 1976a2c4eb2..03770ced026 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/blob/MySQLBlobBinlogProtocolValueTest.java
@@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -82,7 +83,7 @@ public final class MySQLBlobBinlogProtocolValueTest {
assertThat(new MySQLBlobBinlogProtocolValue().read(columnDef, payload), is(new byte[255]));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertReadWithUnknownMetaValue() {
columnDef.setColumnMeta(5);
new MySQLBlobBinlogProtocolValue().read(columnDef, payload);
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
index 71ac82b11d1..30c5ba03344 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonBinlogProtocolValueTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnTyp
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string.MySQLJsonValueDecoder.JsonValueTypes;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -100,7 +101,7 @@ public final class MySQLJsonBinlogProtocolValueTest {
assertThat(new MySQLJsonBinlogProtocolValue().read(columnDef, payload), is(EXPECTED_JSON));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertReadJsonValueWithIllegalMeta() {
columnDef.setColumnMeta(5);
new MySQLJsonBinlogProtocolValue().read(columnDef, payload);
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
index eba693a953e..1bc43616a45 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
@@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLBinaryColumnType;
import org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.MySQLBinlogColumnDef;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,7 +62,7 @@ public final class MySQLStringBinlogProtocolValueTest {
assertThat(new MySQLStringBinlogProtocolValue().read(columnDef, payload), is(32767));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertReadEnumValueWithMetaFailure() {
columnDef.setColumnMeta((MySQLBinaryColumnType.MYSQL_TYPE_ENUM.getValue() << 8) + 3);
new MySQLStringBinlogProtocolValue().read(columnDef, payload);
@@ -95,7 +96,7 @@ public final class MySQLStringBinlogProtocolValueTest {
assertThat(new MySQLStringBinlogProtocolValue().read(columnDef, payload), is(expected));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertReadValueWithUnknownType() {
columnDef.setColumnMeta(MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING.getValue() << 8);
new MySQLStringBinlogProtocolValue().read(columnDef, payload);
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLValueFormat.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLValueFormat.java
index f44ab873bec..7897e1e0f05 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLValueFormat.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/constant/PostgreSQLValueFormat.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.constant;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* PostgreSQL value format.
@@ -46,7 +47,7 @@ public enum PostgreSQLValueFormat {
case 1:
return BINARY;
default:
- throw new UnsupportedOperationException("Unsupported PostgreSQL format code " + code);
+ throw new UnsupportedSQLOperationException(String.format("Unsupported PostgreSQL format code `%s`", code));
}
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
index ceb6973579f..bf75f57abac 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLArrayParameterDecoder.java
@@ -17,6 +17,9 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
+
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,17 +41,15 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public short[] decodeInt2Array(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- short[] result = new short[parameterElements.size()];
- int index = 0;
- for (String element : parameterElements) {
- result[index++] = Short.parseShort(element);
- }
- return result;
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ short[] result = new short[parameterElements.size()];
+ int index = 0;
+ for (String element : parameterElements) {
+ result[index++] = Short.parseShort(element);
}
- throw new UnsupportedOperationException("binary mode");
+ return result;
}
/**
@@ -59,17 +60,15 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public int[] decodeInt4Array(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- int[] result = new int[parameterElements.size()];
- int index = 0;
- for (String element : parameterElements) {
- result[index++] = Integer.parseInt(element);
- }
- return result;
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ int[] result = new int[parameterElements.size()];
+ int index = 0;
+ for (String element : parameterElements) {
+ result[index++] = Integer.parseInt(element);
}
- throw new UnsupportedOperationException("binary mode");
+ return result;
}
/**
@@ -80,17 +79,15 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public long[] decodeInt8Array(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- long[] result = new long[parameterElements.size()];
- int index = 0;
- for (String element : parameterElements) {
- result[index++] = Long.parseLong(element);
- }
- return result;
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ long[] result = new long[parameterElements.size()];
+ int index = 0;
+ for (String element : parameterElements) {
+ result[index++] = Long.parseLong(element);
}
- throw new UnsupportedOperationException("binary mode");
+ return result;
}
/**
@@ -101,17 +98,15 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public float[] decodeFloat4Array(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- float[] result = new float[parameterElements.size()];
- int index = 0;
- for (String element : parameterElements) {
- result[index++] = Float.parseFloat(element);
- }
- return result;
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ float[] result = new float[parameterElements.size()];
+ int index = 0;
+ for (String element : parameterElements) {
+ result[index++] = Float.parseFloat(element);
}
- throw new UnsupportedOperationException("binary mode");
+ return result;
}
/**
@@ -122,17 +117,15 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public double[] decodeFloat8Array(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- double[] result = new double[parameterElements.size()];
- int index = 0;
- for (String element : parameterElements) {
- result[index++] = Double.parseDouble(element);
- }
- return result;
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ double[] result = new double[parameterElements.size()];
+ int index = 0;
+ for (String element : parameterElements) {
+ result[index++] = Double.parseDouble(element);
}
- throw new UnsupportedOperationException("binary mode");
+ return result;
}
/**
@@ -143,17 +136,15 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public boolean[] decodeBoolArray(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- boolean[] result = new boolean[parameterElements.size()];
- int index = 0;
- for (String element : parameterElements) {
- result[index++] = Boolean.parseBoolean(element);
- }
- return result;
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ boolean[] result = new boolean[parameterElements.size()];
+ int index = 0;
+ for (String element : parameterElements) {
+ result[index++] = Boolean.parseBoolean(element);
}
- throw new UnsupportedOperationException("binary mode");
+ return result;
}
/**
@@ -164,12 +155,10 @@ public final class PostgreSQLArrayParameterDecoder {
* @return int array
*/
public String[] decodeStringArray(final byte[] parameterBytes, final boolean isBinary) {
- if (!isBinary) {
- String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
- Collection<String> parameterElements = decodeText(parameterValue);
- return parameterElements.toArray(EMPTY_STRING_ARRAY);
- }
- throw new UnsupportedOperationException("binary mode");
+ ShardingSpherePreconditions.checkState(!isBinary, new UnsupportedSQLOperationException("binary mode"));
+ String parameterValue = new String(parameterBytes, StandardCharsets.UTF_8);
+ Collection<String> parameterElements = decodeText(parameterValue);
+ return parameterElements.toArray(EMPTY_STRING_ARRAY);
}
/**
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java
index e95bc66cbf8..52103e56c18 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for boolean array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLBoolArrayBinaryProtocolValue implements PostgreSQLB
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLBoolArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLBoolArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLBoolArrayBinaryProtocolValue implements PostgreSQLB
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLBoolArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLBoolArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java
index bcbe2bf0942..fbdc8159b64 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for float4 array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLFloat4ArrayBinaryProtocolValue implements PostgreSQ
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLFloat4ArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLFloat4ArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLFloat4ArrayBinaryProtocolValue implements PostgreSQ
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLFloat4ArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLFloat4ArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java
index 3c1610066f5..a4dd6b7c473 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for float8 array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLFloat8ArrayBinaryProtocolValue implements PostgreSQ
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLFloat8ArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLFloat8ArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLFloat8ArrayBinaryProtocolValue implements PostgreSQ
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLFloat8ArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLFloat8ArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java
index 11a9e5c634a..aecd79654a6 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for int2 array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLInt2ArrayBinaryProtocolValue implements PostgreSQLB
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLInt2ArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLInt2ArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLInt2ArrayBinaryProtocolValue implements PostgreSQLB
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLInt2ArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLInt2ArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java
index 2a9f7974d4d..c4771946d8f 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for int4 array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLInt4ArrayBinaryProtocolValue implements PostgreSQLB
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLInt4ArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLInt4ArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLInt4ArrayBinaryProtocolValue implements PostgreSQLB
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLInt4ArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLInt4ArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java
index df6c994704a..9c6f0f81592 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for int8 array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLInt8ArrayBinaryProtocolValue implements PostgreSQLB
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLInt8ArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLInt8ArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLInt8ArrayBinaryProtocolValue implements PostgreSQLB
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLInt8ArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLInt8ArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java
index a38b1ab4334..bad3155d84a 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValue.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.protocol;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for string array for PostgreSQL.
@@ -28,7 +29,7 @@ public final class PostgreSQLStringArrayBinaryProtocolValue implements PostgreSQ
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("PostgreSQLStringArrayBinaryProtocolValue.getColumnLength()");
+ throw new UnsupportedSQLOperationException("PostgreSQLStringArrayBinaryProtocolValue.getColumnLength()");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLStringArrayBinaryProtocolValue implements PostgreSQ
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("PostgreSQLStringArrayBinaryProtocolValue.write()");
+ throw new UnsupportedSQLOperationException("PostgreSQLStringArrayBinaryProtocolValue.write()");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java
index e60a02f47da..3d0214d55d5 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValue.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLTypeUnspecifiedSQLParameter;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Binary protocol value for unspecified for PostgreSQL.
@@ -27,7 +28,7 @@ public final class PostgreSQLUnspecifiedBinaryProtocolValue implements PostgreSQ
@Override
public int getColumnLength(final Object value) {
- throw new UnsupportedOperationException("getColumnLength");
+ throw new UnsupportedSQLOperationException("getColumnLength");
}
@Override
@@ -40,6 +41,6 @@ public final class PostgreSQLUnspecifiedBinaryProtocolValue implements PostgreSQ
@Override
public void write(final PostgreSQLPacketPayload payload, final Object value) {
- throw new UnsupportedOperationException("write");
+ throw new UnsupportedSQLOperationException("write");
}
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java
index e39ca528e10..827886ef223 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBoolArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLBoolArrayBinaryProtocolValueTest {
return new PostgreSQLBoolArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLBoolArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java
index dbb1250dbee..80d0a5047dd 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat4ArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLFloat4ArrayBinaryProtocolValueTest {
return new PostgreSQLFloat4ArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLFloat4ArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java
index a911c94bf6f..44ce01b00fa 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLFloat8ArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLFloat8ArrayBinaryProtocolValueTest {
return new PostgreSQLFloat8ArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,9 +53,8 @@ public final class PostgreSQLFloat8ArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
-
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java
index 4b62d6e6c3a..81c7aea85a1 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2ArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLInt2ArrayBinaryProtocolValueTest {
return new PostgreSQLInt2ArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLInt2ArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java
index 38d46742383..b8783bb1613 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt4ArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLInt4ArrayBinaryProtocolValueTest {
return new PostgreSQLInt4ArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLInt4ArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java
index 76f882bed4c..d1f3058d77e 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt8ArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLInt8ArrayBinaryProtocolValueTest {
return new PostgreSQLInt8ArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLInt8ArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java
index 9aedc93affc..1fc007cd103 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLStringArrayBinaryProtocolValueTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.ex
import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -33,7 +34,7 @@ public final class PostgreSQLStringArrayBinaryProtocolValueTest {
return new PostgreSQLStringArrayBinaryProtocolValue();
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
newInstance().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLStringArrayBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
newInstance().write(new PostgreSQLPacketPayload(null, StandardCharsets.UTF_8), "val");
}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
index 87a7f9aa4c3..90047c30ae3 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
@@ -21,6 +21,7 @@ import io.netty.buffer.ByteBuf;
import org.apache.shardingsphere.db.protocol.postgresql.packet.ByteBufTestUtils;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.bind.PostgreSQLTypeUnspecifiedSQLParameter;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -32,7 +33,7 @@ import static org.mockito.Mockito.mock;
public final class PostgreSQLUnspecifiedBinaryProtocolValueTest {
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertGetColumnLength() {
new PostgreSQLUnspecifiedBinaryProtocolValue().getColumnLength("val");
}
@@ -52,7 +53,7 @@ public final class PostgreSQLUnspecifiedBinaryProtocolValueTest {
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertWrite() {
new PostgreSQLUnspecifiedBinaryProtocolValue().write(mock(PostgreSQLPacketPayload.class), "val");
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
index 7ef76bbfc6b..bd86d1d41b4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/complex/ComplexInlineShardingAlgorithm.java
@@ -21,6 +21,8 @@ import com.google.common.base.Preconditions;
import groovy.lang.Closure;
import groovy.util.Expando;
import lombok.Getter;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
@@ -81,10 +83,9 @@ public final class ComplexInlineShardingAlgorithm implements ComplexKeysSharding
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final ComplexKeysShardingValue<Comparable<?>> shardingValue) {
if (!shardingValue.getColumnNameAndRangeValuesMap().isEmpty()) {
- if (allowRangeQuery) {
- return availableTargetNames;
- }
- throw new UnsupportedOperationException("Since the property of `" + ALLOW_RANGE_QUERY_KEY + "` is false, inline sharding algorithm can not tackle with range query.");
+ ShardingSpherePreconditions.checkState(allowRangeQuery,
+ new UnsupportedSQLOperationException(String.format("Since the property of `%s` is false, inline sharding algorithm can not tackle with range query", ALLOW_RANGE_QUERY_KEY)));
+ return availableTargetNames;
}
Map<String, Collection<Comparable<?>>> columnNameAndShardingValuesMap = shardingValue.getColumnNameAndShardingValuesMap();
if (!shardingColumns.isEmpty() && shardingColumns.size() != columnNameAndShardingValuesMap.size()) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
index 0db93971402..44d7c6a69da 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/IntervalShardingAlgorithm.java
@@ -21,6 +21,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.BoundType;
import com.google.common.collect.Range;
import lombok.Getter;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
@@ -127,7 +128,7 @@ public final class IntervalShardingAlgorithm implements StandardShardingAlgorith
return each;
}
}
- throw new UnsupportedOperationException(String.format("Cannot find step unit for specified %s property: `%s`", INTERVAL_UNIT_KEY, stepUnit));
+ throw new UnsupportedSQLOperationException(String.format("Cannot find step unit for specified %s property: `%s`", INTERVAL_UNIT_KEY, stepUnit));
}
@Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
index 2d0cb4929ea..8f360410a0c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithm.java
@@ -22,6 +22,8 @@ import groovy.lang.Closure;
import groovy.lang.MissingMethodException;
import groovy.util.Expando;
import lombok.Getter;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -77,10 +79,9 @@ public final class InlineShardingAlgorithm implements StandardShardingAlgorithm<
@Override
public Collection<String> doSharding(final Collection<String> availableTargetNames, final RangeShardingValue<Comparable<?>> shardingValue) {
- if (allowRangeQuery) {
- return availableTargetNames;
- }
- throw new UnsupportedOperationException("Since the property of `" + ALLOW_RANGE_QUERY_KEY + "` is false, inline sharding algorithm can not tackle with range query.");
+ ShardingSpherePreconditions.checkState(allowRangeQuery,
+ new UnsupportedSQLOperationException(String.format("Since the property of `%s` is false, inline sharding algorithm can not tackle with range query", ALLOW_RANGE_QUERY_KEY)));
+ return availableTargetNames;
}
private Closure<?> createClosure() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
index 0a553195f85..d1732c92148 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/AbstractRangeShardingAlgorithm.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.collect.Range;
import lombok.Getter;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
@@ -80,7 +81,7 @@ public abstract class AbstractRangeShardingAlgorithm implements StandardSharding
return entry.getKey();
}
}
- throw new UnsupportedOperationException("");
+ throw new UnsupportedSQLOperationException("");
}
private Long getLongValue(final Comparable<?> value) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactory.java
index 2c50915fe0c..ec7a5bfe14e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactory.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sharding.merge.dql.groupby.aggregation;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.constant.AggregationType;
/**
@@ -49,7 +50,7 @@ public final class AggregationUnitFactory {
case BIT_XOR:
return new BitXorAggregationUnit();
default:
- throw new UnsupportedOperationException(type.name());
+ throw new UnsupportedSQLOperationException(type.name());
}
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/update/AddMigrationSourceResourceUpdater.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/update/AddMigrationSourceResourceUpdater.java
index 26028d11fa8..9684c0fed81 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/update/AddMigrationSourceResourceUpdater.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/update/AddMigrationSourceResourceUpdater.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.migration.distsql.handler.update;
-import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.data.pipeline.api.MigrationJobPublicAPI;
import org.apache.shardingsphere.data.pipeline.api.PipelineJobPublicAPIFactory;
import org.apache.shardingsphere.data.pipeline.core.exception.AddMigrationSourceResourceException;
@@ -30,6 +29,8 @@ import org.apache.shardingsphere.infra.datasource.props.DataSourceProperties;
import org.apache.shardingsphere.infra.datasource.props.DataSourcePropertiesValidator;
import org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
import org.apache.shardingsphere.infra.distsql.update.RALUpdater;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.migration.distsql.statement.AddMigrationSourceResourceStatement;
import org.apache.shardingsphere.sharding.distsql.handler.converter.ResourceSegmentsConverter;
@@ -40,7 +41,6 @@ import java.util.Map;
/**
* Add migration source resource updater.
*/
-@Slf4j
public final class AddMigrationSourceResourceUpdater implements RALUpdater<AddMigrationSourceResourceStatement> {
private static final MigrationJobPublicAPI JOB_API = PipelineJobPublicAPIFactory.getMigrationJobPublicAPI();
@@ -48,9 +48,8 @@ public final class AddMigrationSourceResourceUpdater implements RALUpdater<AddMi
@Override
public void executeUpdate(final String databaseName, final AddMigrationSourceResourceStatement sqlStatement) {
List<DataSourceSegment> dataSources = new ArrayList<>(sqlStatement.getDataSources());
- if (dataSources.stream().anyMatch(each -> each instanceof HostnameAndPortBasedDataSourceSegment)) {
- throw new UnsupportedOperationException("Not currently support add hostname and port, please use url");
- }
+ ShardingSpherePreconditions.checkState(dataSources.stream().noneMatch(each -> each instanceof HostnameAndPortBasedDataSourceSegment),
+ new UnsupportedSQLOperationException("Not currently support add hostname and port, please use url"));
URLBasedDataSourceSegment urlBasedDataSourceSegment = (URLBasedDataSourceSegment) dataSources.get(0);
DatabaseType databaseType = DatabaseTypeEngine.getDatabaseType(urlBasedDataSourceSegment.getUrl());
Map<String, DataSourceProperties> sourcePropertiesMap = ResourceSegmentsConverter.convert(databaseType, dataSources);
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java
index 3f168812e04..9deca574708 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/enums/ShardingStrategyType.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.sharding.distsql.handler.enums;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
@@ -162,15 +163,15 @@ public enum ShardingStrategyType {
public static ShardingStrategyType getValueOf(final String name) {
try {
return valueOf(name.toUpperCase());
- } catch (IllegalArgumentException e) {
- throw new UnsupportedOperationException(String.format("unsupported strategy type %s", name));
+ } catch (final IllegalArgumentException ex) {
+ throw new UnsupportedSQLOperationException(String.format("unsupported strategy type %s", name));
}
}
/**
* Returns the sharding strategy type.
*
- * @param shardingStrategyConfig Implementation class of sharding strategy configuration
+ * @param shardingStrategyConfig implementation class of sharding strategy configuration
* @return sharding strategy type
*/
public static ShardingStrategyType getValueOf(final ShardingStrategyConfiguration shardingStrategyConfig) {
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
index 1e06e57ed5d..64783c031eb 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
@@ -21,16 +21,16 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dal.AnalyzeTableStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dal.ExplainStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dal.FlushStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dal.KillStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dal.OptimizeTableStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dal.ShowColumnsStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dal.ShowCreateTableStatementContext;
-import org.apache.shardingsphere.infra.binder.statement.dal.ShowTablesStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dal.ShowIndexStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dal.ShowTableStatusStatementContext;
-import org.apache.shardingsphere.infra.binder.statement.dal.AnalyzeTableStatementContext;
-import org.apache.shardingsphere.infra.binder.statement.dal.FlushStatementContext;
-import org.apache.shardingsphere.infra.binder.statement.dal.OptimizeTableStatementContext;
-import org.apache.shardingsphere.infra.binder.statement.dal.KillStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dal.ShowTablesStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dcl.DenyUserStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dcl.GrantStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dcl.RevokeStatementContext;
@@ -62,6 +62,7 @@ import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementConte
import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.binder.statement.dml.UpdateStatementContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.AnalyzeTableStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
@@ -98,13 +99,13 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DoStatement
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLKillStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLOptimizeTableStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowColumnsStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowCreateTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTableStatusStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowTablesStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowIndexStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLOptimizeTableStatement;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLKillStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCursorStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dcl.SQLServerDenyUserStatement;
@@ -179,7 +180,7 @@ public final class SQLStatementContextFactory {
if (sqlStatement instanceof DoStatement) {
return new DoStatementContext((DoStatement) sqlStatement);
}
- throw new UnsupportedOperationException(String.format("Unsupported SQL statement `%s`", sqlStatement.getClass().getSimpleName()));
+ throw new UnsupportedSQLOperationException(String.format("Unsupported SQL statement `%s`", sqlStatement.getClass().getSimpleName()));
}
private static SQLStatementContext<?> getDDLStatementContext(final Map<String, ShardingSphereDatabase> databases, final List<Object> parameters,
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/CommonSQLStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/CommonSQLStatementContext.java
index 199bf3ae846..11d1929bb37 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/CommonSQLStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/CommonSQLStatementContext.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.hint.SQLHintExtractor;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
@@ -74,7 +75,7 @@ public class CommonSQLStatementContext<T extends SQLStatement> implements SQLSta
if (sqlStatement instanceof OpenGaussStatement) {
return DatabaseTypeFactory.getInstance("openGauss");
}
- throw new UnsupportedOperationException(sqlStatement.getClass().getName());
+ throw new UnsupportedSQLOperationException(sqlStatement.getClass().getName());
}
/**
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesValidator.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesValidator.java
index 8636463ccc9..dde479671ed 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesValidator.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesValidator.java
@@ -79,8 +79,8 @@ public final class DataSourcePropertiesValidator {
private void checkFailFast(final DataSource dataSource, final DatabaseType databaseType) throws SQLException, ShardingSphereInternalException {
try (Connection connection = dataSource.getConnection()) {
- ShardingSpherePreconditions.checkState(null == databaseType
- || DatabaseTypeEngine.getDatabaseType(connection.getMetaData().getURL()).getType().equals(databaseType.getType()), new MismatchedProtocolAndDataSourceException());
+ ShardingSpherePreconditions.checkState(null == databaseType || DatabaseTypeEngine.getDatabaseType(connection.getMetaData().getURL()).getType().equals(databaseType.getType()),
+ new MismatchedProtocolAndDataSourceException());
}
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java
index 98309a930ff..01cdbf99732 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/vertx/VertxQueryResult.java
@@ -21,6 +21,7 @@ import io.vertx.sqlclient.Row;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.io.InputStream;
import java.sql.SQLException;
@@ -55,12 +56,12 @@ public final class VertxQueryResult implements QueryResult {
@Override
public Object getCalendarValue(final int columnIndex, final Class<?> type, final Calendar calendar) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("");
}
@Override
public InputStream getInputStream(final int columnIndex, final String type) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getInputStream");
}
@Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/UnsupportedSQLOperationException.java
similarity index 60%
copy from shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java
copy to shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/UnsupportedSQLOperationException.java
index 73be17fa2ae..4200dd016d4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/UnsupportedSQLOperationException.java
@@ -15,14 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.frontend.state.impl;
+package org.apache.shardingsphere.infra.util.exception.external.sql;
-import org.junit.Test;
+import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
-public final class LockProxyStateTest {
+/**
+ * Unsupported SQL operation exception.
+ */
+public final class UnsupportedSQLOperationException extends ShardingSphereSQLException {
+
+ private static final long serialVersionUID = -4387122733989386705L;
- @Test(expected = UnsupportedOperationException.class)
- public void assertExecute() {
- new LockProxyState().execute(null, null, null, null);
+ public UnsupportedSQLOperationException(final String reason) {
+ super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 30001, "Unsupported SQL operation: %s", reason);
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java
index 569fe7e9ea1..1e8f52f8a24 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.driver.jdbc.unsupported;
import org.apache.shardingsphere.driver.jdbc.adapter.WrapperAdapter;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.sql.Blob;
import java.sql.CallableStatement;
@@ -119,11 +120,11 @@ public abstract class AbstractUnsupportedOperationConnection extends WrapperAdap
@Override
public final void setClientInfo(final String name, final String value) {
- throw new UnsupportedOperationException("setClientInfo name value");
+ throw new UnsupportedSQLOperationException("setClientInfo name value");
}
@Override
public final void setClientInfo(final Properties props) {
- throw new UnsupportedOperationException("setClientInfo properties");
+ throw new UnsupportedSQLOperationException("setClientInfo properties");
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/lock/LockDriverState.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/lock/LockDriverState.java
index 62e8629bd68..c269449ee64 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/lock/LockDriverState.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/lock/LockDriverState.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.driver.state.lock;
import org.apache.shardingsphere.driver.jdbc.context.JDBCContext;
import org.apache.shardingsphere.driver.state.DriverState;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import java.sql.Connection;
@@ -31,7 +32,7 @@ public final class LockDriverState implements DriverState {
@Override
public Connection getConnection(final String databaseName, final ContextManager contextManager, final JDBCContext jdbcContext) {
// TODO
- throw new UnsupportedOperationException("LockDriverState");
+ throw new UnsupportedSQLOperationException("LockDriverState");
}
@Override
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
index f9752d42ca2..979a4c0719a 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.driver.jdbc.context.JDBCContext;
import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import org.apache.shardingsphere.infra.database.DefaultDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.traffic.rule.TrafficRule;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
@@ -129,12 +130,12 @@ public final class UnsupportedOperationConnectionTest {
shardingSphereConnection.getClientInfo("");
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertSetClientInfo() {
shardingSphereConnection.setClientInfo("", "");
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertSetClientInfoWithProperties() {
shardingSphereConnection.setClientInfo(new Properties());
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/datasource/config/PipelineDataSourceConfigurationFactory.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/datasource/config/PipelineDataSourceConfigurationFactory.java
index d3ad46f2f4f..07e1d06e21c 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/datasource/config/PipelineDataSourceConfigurationFactory.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/datasource/config/PipelineDataSourceConfigurationFactory.java
@@ -21,6 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.ShardingSpherePipelineDataSourceConfiguration;
import org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.StandardPipelineDataSourceConfiguration;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Pipeline data source configuration factory.
@@ -42,7 +43,7 @@ public final class PipelineDataSourceConfigurationFactory {
case ShardingSpherePipelineDataSourceConfiguration.TYPE:
return new ShardingSpherePipelineDataSourceConfiguration(parameter);
default:
- throw new UnsupportedOperationException(String.format("Unsupported data source type '%s'", type));
+ throw new UnsupportedSQLOperationException(String.format("Unsupported data source type `%s`", type));
}
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java
index 9f13819ca95..248457586cb 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/sqlbuilder/PipelineSQLBuilder.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.data.pipeline.spi.sqlbuilder;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.Column;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.util.spi.type.required.RequiredSPI;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPI;
@@ -41,7 +42,7 @@ public interface PipelineSQLBuilder extends TypedSPI, RequiredSPI {
* @return create schema SQL
*/
default String buildCreateSchemaSQL(String schemaName) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("buildCreateSchemaSQL");
}
/**
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMerger.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMerger.java
index 632a482fe5b..096678ab9a7 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMerger.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMerger.java
@@ -23,6 +23,8 @@ import org.apache.shardingsphere.data.pipeline.api.ingest.record.GroupedDataReco
import org.apache.shardingsphere.data.pipeline.core.exception.PipelineUnexpectedDataRecordOrderException;
import org.apache.shardingsphere.data.pipeline.core.ingest.IngestDataChangeType;
import org.apache.shardingsphere.data.pipeline.core.record.RecordUtil;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -98,9 +100,7 @@ public final class DataRecordMerger {
dataRecords.put(dataRecord.getKey(), dataRecord);
return;
}
- if (IngestDataChangeType.DELETE.equals(beforeDataRecord.getType())) {
- throw new UnsupportedOperationException();
- }
+ ShardingSpherePreconditions.checkState(!IngestDataChangeType.DELETE.equals(beforeDataRecord.getType()), new UnsupportedSQLOperationException("Not Delete"));
if (checkUpdatedPrimaryKey(dataRecord)) {
dataRecords.remove(dataRecord.getOldKey());
}
@@ -129,9 +129,7 @@ public final class DataRecordMerger {
for (int i = 0; i < dataRecord.getColumnCount(); i++) {
mergedDataRecord.addColumn(new Column(
dataRecord.getColumn(i).getName(),
- dataRecord.getColumn(i).isUniqueKey()
- ? beforeDataRecord.getColumn(i).getOldValue()
- : beforeDataRecord.getColumn(i).getValue(),
+ dataRecord.getColumn(i).isUniqueKey() ? beforeDataRecord.getColumn(i).getOldValue() : beforeDataRecord.getColumn(i).getValue(),
true,
dataRecord.getColumn(i).isUniqueKey()));
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
index 78de64e85dd..aae4e5248e1 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
@@ -48,6 +48,7 @@ import org.apache.shardingsphere.data.pipeline.core.util.PipelineJdbcUtils;
import org.apache.shardingsphere.data.pipeline.spi.ingest.dumper.ColumnValueReader;
import org.apache.shardingsphere.data.pipeline.spi.ratelimit.JobRateLimitAlgorithm;
import org.apache.shardingsphere.data.pipeline.spi.sqlbuilder.PipelineSQLBuilder;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -83,7 +84,7 @@ public abstract class AbstractInventoryDumper extends AbstractLifecycleExecutor
protected AbstractInventoryDumper(final InventoryDumperConfiguration inventoryDumperConfig, final PipelineChannel channel,
final DataSource dataSource, final PipelineTableMetaDataLoader metaDataLoader) {
if (!StandardPipelineDataSourceConfiguration.class.equals(inventoryDumperConfig.getDataSourceConfig().getClass())) {
- throw new UnsupportedOperationException("AbstractInventoryDumper only support StandardPipelineDataSourceConfiguration");
+ throw new UnsupportedSQLOperationException("AbstractInventoryDumper only support StandardPipelineDataSourceConfiguration");
}
this.dumperConfig = inventoryDumperConfig;
this.channel = channel;
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
index 7edaba281d0..2741926d2e7 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/OraclePipelineSQLBuilder.java
@@ -21,6 +21,7 @@ import lombok.NonNull;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
import org.apache.shardingsphere.data.pipeline.api.metadata.LogicTableName;
import org.apache.shardingsphere.data.pipeline.core.util.PipelineJdbcUtils;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.util.Map;
import java.util.Set;
@@ -32,7 +33,7 @@ public final class OraclePipelineSQLBuilder extends AbstractPipelineSQLBuilder {
@Override
public String buildCreateSchemaSQL(final String schemaName) {
- throw new UnsupportedOperationException("Not supported for now");
+ throw new UnsupportedSQLOperationException("buildCreateSchemaSQL");
}
@Override
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
index 62c7dc018f9..2a0c51ca20b 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
@@ -46,6 +46,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.que
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.netty.ChannelAttrInitializer;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.net.InetSocketAddress;
import java.util.Objects;
@@ -185,7 +186,7 @@ public final class MySQLClient {
case "CRC32":
return 4;
default:
- throw new UnsupportedOperationException(checksumType);
+ throw new UnsupportedSQLOperationException(checksumType);
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiatePackageDecoder.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiatePackageDecoder.java
index 361abe53699..c108d8629eb 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiatePackageDecoder.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiatePackageDecoder.java
@@ -28,6 +28,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLAuthMor
import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLAuthSwitchRequestPacket;
import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakePacket;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.util.List;
@@ -54,8 +55,7 @@ public final class MySQLNegotiatePackageDecoder extends ByteToMessageDecoder {
}
private MySQLHandshakePacket decodeHandshakePacket(final MySQLPacketPayload payload) {
- MySQLHandshakePacket result = new MySQLHandshakePacket(payload);
- return result;
+ return new MySQLHandshakePacket(payload);
}
private MySQLPacket decodeResponsePacket(final MySQLPacketPayload payload, final List<Object> out) {
@@ -70,7 +70,7 @@ public final class MySQLNegotiatePackageDecoder extends ByteToMessageDecoder {
case MySQLAuthMoreDataPacket.HEADER:
return new MySQLAuthMoreDataPacket(payload);
default:
- throw new UnsupportedOperationException(String.format("Unsupported negotiate response header: %X", header));
+ throw new UnsupportedSQLOperationException(String.format("Unsupported negotiate response header: %X", header));
}
}
}
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWalDumper.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWalDumper.java
index 84123622fb8..7a4c3307db7 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWalDumper.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-opengauss/src/main/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/OpenGaussWalDumper.java
@@ -35,6 +35,7 @@ import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.WalEventCon
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.WalPosition;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.decode.DecodingPlugin;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.AbstractWalEvent;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.opengauss.jdbc.PgConnection;
import org.opengauss.replication.PGReplicationStream;
@@ -62,7 +63,7 @@ public final class OpenGaussWalDumper extends AbstractIncrementalDumper<WalPosit
super(dumperConfig, position, channel, metaDataLoader);
walPosition = (WalPosition) position;
if (!StandardPipelineDataSourceConfiguration.class.equals(dumperConfig.getDataSourceConfig().getClass())) {
- throw new UnsupportedOperationException("PostgreSQLWalDumper only support PipelineDataSourceConfiguration");
+ throw new UnsupportedSQLOperationException("PostgreSQLWalDumper only support PipelineDataSourceConfiguration");
}
this.dumperConfig = dumperConfig;
this.channel = channel;
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java
index c304037e96d..0fe83667bec 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLWalDumper.java
@@ -35,6 +35,7 @@ import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.decode.Post
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.decode.PostgreSQLTimestampUtils;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.decode.TestDecodingPlugin;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.AbstractWalEvent;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.postgresql.jdbc.PgConnection;
import org.postgresql.replication.PGReplicationStream;
@@ -63,7 +64,7 @@ public final class PostgreSQLWalDumper extends AbstractIncrementalDumper<WalPosi
super(dumperConfig, position, channel, metaDataLoader);
walPosition = (WalPosition) position;
if (!StandardPipelineDataSourceConfiguration.class.equals(dumperConfig.getDataSourceConfig().getClass())) {
- throw new UnsupportedOperationException("PostgreSQLWalDumper only support PipelineDataSourceConfiguration");
+ throw new UnsupportedSQLOperationException("PostgreSQLWalDumper only support PipelineDataSourceConfiguration");
}
this.dumperConfig = dumperConfig;
this.channel = channel;
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverter.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverter.java
index 4ffeabcc458..8e61ff0d881 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverter.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverter.java
@@ -32,6 +32,7 @@ import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.Delet
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.PlaceholderEvent;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.UpdateRowEvent;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.WriteRowEvent;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import java.util.List;
@@ -67,7 +68,7 @@ public final class WalEventConverter {
} else if (event instanceof PlaceholderEvent) {
return createPlaceholderRecord(event);
}
- throw new UnsupportedOperationException("");
+ throw new UnsupportedSQLOperationException("");
}
private boolean filter(final AbstractWalEvent event) {
@@ -79,9 +80,7 @@ public final class WalEventConverter {
}
private boolean isRowEvent(final AbstractWalEvent event) {
- return event instanceof WriteRowEvent
- || event instanceof UpdateRowEvent
- || event instanceof DeleteRowEvent;
+ return event instanceof WriteRowEvent || event instanceof UpdateRowEvent || event instanceof DeleteRowEvent;
}
private PlaceholderRecord createPlaceholderRecord(final AbstractWalEvent event) {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java
index dd93c267854..506a4c4dcb8 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalEventConverterTest.java
@@ -35,6 +35,7 @@ import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.Delet
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.PlaceholderEvent;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.UpdateRowEvent;
import org.apache.shardingsphere.data.pipeline.postgresql.ingest.wal.event.WriteRowEvent;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -121,7 +122,7 @@ public final class WalEventConverterTest {
assertThat(record, instanceOf(PlaceholderRecord.class));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertConvertFailure() {
walEventConverter.convert(new AbstractRowEvent() {
});
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java
index 4eb7e04a91a..121a3741420 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/ExpressionConverter.java
@@ -18,18 +18,7 @@
package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression;
import org.apache.calcite.sql.SqlNode;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.BetweenExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.BinaryOperationExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ColumnConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ExistsSubqueryExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.FunctionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.InExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ListExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.LiteralExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ParameterMarkerExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.SubqueryExpressionConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.AggregationProjectionConverter;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenExpression;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
@@ -43,6 +32,18 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.L
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.ParameterMarkerExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.subquery.SubqueryExpressionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.AggregationProjectionSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.BetweenExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.BinaryOperationExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ColumnConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ExistsSubqueryExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.FunctionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.InExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ListExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.LiteralExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.ParameterMarkerExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.expression.impl.SubqueryExpressionConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.projection.impl.AggregationProjectionConverter;
import java.util.Optional;
@@ -60,9 +61,9 @@ public final class ExpressionConverter implements SQLSegmentConverter<Expression
return new LiteralExpressionConverter().convert((LiteralExpressionSegment) segment);
} else if (segment instanceof CommonExpressionSegment) {
// TODO
- throw new UnsupportedOperationException("unsupported CommonExpressionSegment");
+ throw new UnsupportedSQLOperationException("unsupported CommonExpressionSegment");
} else if (segment instanceof ListExpression) {
- return new ListExpressionConverter().convert((ListExpression) segment).map(optional -> optional);
+ return new ListExpressionConverter().convert((ListExpression) segment);
} else if (segment instanceof BinaryOperationExpression) {
return new BinaryOperationExpressionConverter().convert((BinaryOperationExpression) segment).map(optional -> optional);
} else if (segment instanceof ColumnSegment) {
@@ -76,12 +77,12 @@ public final class ExpressionConverter implements SQLSegmentConverter<Expression
} else if (segment instanceof BetweenExpression) {
return new BetweenExpressionConverter().convert((BetweenExpression) segment).map(optional -> optional);
} else if (segment instanceof ParameterMarkerExpressionSegment) {
- return new ParameterMarkerExpressionConverter().convert((ParameterMarkerExpressionSegment) segment).map(optional -> optional);
+ return new ParameterMarkerExpressionConverter().convert((ParameterMarkerExpressionSegment) segment);
} else if (segment instanceof FunctionSegment) {
- return new FunctionConverter().convert((FunctionSegment) segment).map(optional -> optional);
+ return new FunctionConverter().convert((FunctionSegment) segment);
} else if (segment instanceof AggregationProjectionSegment) {
return new AggregationProjectionConverter().convert((AggregationProjectionSegment) segment).map(optional -> optional);
}
- throw new UnsupportedOperationException("unsupported TableSegment type: " + segment.getClass());
+ throw new UnsupportedSQLOperationException("unsupported TableSegment type: " + segment.getClass());
}
}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java
index cce31b299aa..78e52455375 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/from/TableConverter.java
@@ -18,14 +18,15 @@
package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from;
import org.apache.calcite.sql.SqlNode;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.impl.JoinTableConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.impl.SimpleTableConverter;
-import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.impl.SubqueryTableConverter;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.JoinTableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SubqueryTableSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.SQLSegmentConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.impl.JoinTableConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.impl.SimpleTableConverter;
+import org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.from.impl.SubqueryTableConverter;
import java.util.Optional;
@@ -46,6 +47,6 @@ public final class TableConverter implements SQLSegmentConverter<TableSegment, S
} else if (segment instanceof SubqueryTableSegment) {
return new SubqueryTableConverter().convert((SubqueryTableSegment) segment).map(optional -> optional);
}
- throw new UnsupportedOperationException("Unsupported segment type: " + segment.getClass());
+ throw new UnsupportedSQLOperationException("Unsupported segment type: " + segment.getClass());
}
}
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/OrderByItemConverterUtil.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/OrderByItemConverterUtil.java
index 36d0c64af81..32332ee6d9d 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/OrderByItemConverterUtil.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/orderby/item/OrderByItemConverterUtil.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sqlfederation.optimizer.converter.segment.orde
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.calcite.sql.SqlNode;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ColumnOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ExpressionOrderByItemSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.IndexOrderByItemSegment;
@@ -38,7 +39,7 @@ public final class OrderByItemConverterUtil {
/**
* Convert order by items to sql node.
*
- * @param orderByItems order by item list
+ * @param orderByItems order by items
* @return SQL nodes converted by order by item
*/
public static Collection<SqlNode> convert(final Collection<OrderByItemSegment> orderByItems) {
@@ -51,7 +52,7 @@ public final class OrderByItemConverterUtil {
} else if (each instanceof IndexOrderByItemSegment) {
new IndexOrderByItemConverter().convert((IndexOrderByItemSegment) each).ifPresent(result::add);
} else if (each instanceof TextOrderByItemSegment) {
- throw new UnsupportedOperationException("unsupported TextOrderByItemSegment");
+ throw new UnsupportedSQLOperationException("unsupported TextOrderByItemSegment");
}
}
return result;
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/translatable/FederationTranslatableTable.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/translatable/FederationTranslatableTable.java
index 938cce54688..5484e6f452a 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/translatable/FederationTranslatableTable.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/translatable/FederationTranslatableTable.java
@@ -36,11 +36,12 @@ import org.apache.calcite.schema.Schemas;
import org.apache.calcite.schema.Statistic;
import org.apache.calcite.schema.TranslatableTable;
import org.apache.calcite.schema.impl.AbstractTable;
+import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
+import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sqlfederation.optimizer.executor.TableScanExecutor;
import org.apache.shardingsphere.sqlfederation.optimizer.executor.TranslatableScanNodeExecutorContext;
import org.apache.shardingsphere.sqlfederation.optimizer.metadata.statistic.FederationStatistic;
-import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
-import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
import java.lang.reflect.Type;
@@ -96,7 +97,7 @@ public final class FederationTranslatableTable extends AbstractTable implements
@Override
public <T> Queryable<T> asQueryable(final QueryProvider queryProvider, final SchemaPlus schema, final String tableName) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("asQueryable");
}
@Override
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
index d613ffff9ed..8be0924a5f2 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
@@ -22,6 +22,7 @@ import com.zaxxer.hikari.HikariDataSource;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.transaction.xa.jta.datasource.XADataSourceFactory;
import javax.sql.DataSource;
@@ -47,7 +48,7 @@ public final class DataSourceUtils {
if (AtomikosDataSourceBean.class == dataSourceClass) {
return createAtomikosDataSourceBean(databaseType, createHikariDataSource(databaseType, databaseName), databaseName);
}
- throw new UnsupportedOperationException(dataSourceClass.getName());
+ throw new UnsupportedSQLOperationException(dataSourceClass.getName());
}
private static HikariDataSource createHikariDataSource(final DatabaseType databaseType, final String databaseName) {
@@ -86,7 +87,7 @@ public final class DataSourceUtils {
case "H2":
return String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL", databaseName);
default:
- throw new UnsupportedOperationException(databaseType.getType());
+ throw new UnsupportedSQLOperationException(databaseType.getType());
}
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContext.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContext.java
index 5f5753e1ac1..405ac8e1851 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContext.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContext.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.mode.lock;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.lock.LockContext;
import org.apache.shardingsphere.infra.lock.LockDefinition;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Lock context of ShardingSphere.
@@ -48,6 +49,6 @@ public final class ShardingSphereLockContext implements LockContext {
@Override
public boolean isLocked(final LockDefinition lockDefinition) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("isLocked");
}
}
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContextTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContextTest.java
index bd26cbdeb6b..39289603669 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContextTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/lock/ShardingSphereLockContextTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.mode.lock;
import org.apache.shardingsphere.infra.lock.LockDefinition;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Before;
import org.junit.Test;
@@ -63,7 +64,7 @@ public final class ShardingSphereLockContextTest {
verify(lockPersistService).unlock(lockDefinition);
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertIsLocked() {
assertTrue(lockContext.isLocked(lockDefinition));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java
index bc60a2cee88..bc6dc6dedf8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/executor/callback/ProxyJDBCExecutorCallbackFactory.java
@@ -21,6 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl.ProxyPreparedStatementExecutorCallback;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl.ProxyStatementExecutorCallback;
@@ -54,6 +55,6 @@ public final class ProxyJDBCExecutorCallbackFactory {
if (JDBCDriverType.PREPARED_STATEMENT.equals(type)) {
return new ProxyPreparedStatementExecutorCallback(protocolType, databaseType, sqlStatement, databaseCommunicationEngine, isReturnGeneratedKeys, isExceptionThrown, isFetchMetaData);
}
- throw new UnsupportedOperationException(String.format("Unsupported driver type: `%s`", type));
+ throw new UnsupportedSQLOperationException(String.format("Unsupported driver type: `%s`", type));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java
index d8d823ddb5b..811beff82ca 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendConnection.java
@@ -24,10 +24,11 @@ import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;
import io.vertx.sqlclient.SqlClient;
import io.vertx.sqlclient.SqlConnection;
-import java.util.concurrent.atomic.AtomicBoolean;
import lombok.Getter;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.vertx.ExecutorVertxConnectionManager;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.communication.BackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ConnectionPostProcessor;
import org.apache.shardingsphere.proxy.backend.communication.vertx.transaction.VertxLocalTransactionManager;
@@ -40,6 +41,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* Vert.x backend connection.
@@ -56,18 +58,15 @@ public final class VertxBackendConnection implements BackendConnection<Future<Vo
private final AtomicBoolean closed;
public VertxBackendConnection(final ConnectionSession connectionSession) {
- if (TransactionType.LOCAL != connectionSession.getTransactionStatus().getTransactionType()) {
- throw new UnsupportedOperationException("Vert.x backend supports LOCAL transaction only for now.");
- }
+ ShardingSpherePreconditions.checkState(TransactionType.LOCAL == connectionSession.getTransactionStatus().getTransactionType(),
+ new UnsupportedSQLOperationException("Vert.x backend supports LOCAL transaction only for now"));
closed = new AtomicBoolean(false);
this.connectionSession = connectionSession;
}
@Override
public List<Future<? extends SqlClient>> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) {
- return connectionSession.getTransactionStatus().isInTransaction()
- ? getConnectionsWithTransaction(dataSourceName, connectionSize)
- : getConnectionsWithoutTransaction(dataSourceName);
+ return connectionSession.getTransactionStatus().isInTransaction() ? getConnectionsWithTransaction(dataSourceName, connectionSize) : getConnectionsWithoutTransaction(dataSourceName);
}
private List<Future<? extends SqlClient>> getConnectionsWithTransaction(final String dataSourceName, final int connectionSize) {
@@ -135,7 +134,8 @@ public final class VertxBackendConnection implements BackendConnection<Future<Vo
public Future<Void> closeExecutionResources() {
if (!connectionSession.getTransactionStatus().isInTransaction()) {
return closeAllConnections(false);
- } else if (closed.get()) {
+ }
+ if (closed.get()) {
return closeAllConnections(true);
}
return Future.succeededFuture();
@@ -163,7 +163,7 @@ public final class VertxBackendConnection implements BackendConnection<Future<Vo
/**
* Execute in all cached connections.
*
- * @param sql sql to be executed
+ * @param sql SQL to be executed
* @return join future
*/
@SuppressWarnings("rawtypes")
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
index c3d892c0c35..cb3879e44d7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
@@ -32,6 +32,7 @@ import io.vertx.sqlclient.PoolOptions;
import io.vertx.sqlclient.SqlConnection;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.communication.BackendDataSource;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -135,11 +136,11 @@ public final class VertxBackendDataSource implements BackendDataSource {
case "mysql":
return createMySQLPool(value, uri);
case "postgresql":
- throw new UnsupportedOperationException("For now");
+ throw new UnsupportedSQLOperationException("For now");
case "opengauss":
- throw new UnsupportedOperationException("For now");
+ throw new UnsupportedSQLOperationException("For now");
default:
- throw new UnsupportedOperationException("Database " + uri.getScheme() + " unsupported");
+ throw new UnsupportedSQLOperationException("Database " + uri.getScheme() + " unsupported");
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java
index d803da60f11..8be6dea53d4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxDatabaseCommunicationEngine.java
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine;
import org.apache.shardingsphere.proxy.backend.communication.ReactiveProxySQLExecutor;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -93,6 +94,6 @@ public final class VertxDatabaseCommunicationEngine extends DatabaseCommunicatio
@Override
public ResponseHeader execute() throws SQLException {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("VertxDatabaseCommunicationEngine.execute()");
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
index 8118147d0f8..7ae5a84d832 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
@@ -30,6 +30,8 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
@@ -157,9 +159,8 @@ public final class ProxyBackendHandlerFactory {
}
private static void checkUnsupportedDistSQLStatementInTransaction(final SQLStatement sqlStatement, final ConnectionSession connectionSession) {
- if (connectionSession.getTransactionStatus().isInTransaction() && !isSupportedDistSQLStatementInTransaction(sqlStatement)) {
- throw new UnsupportedOperationException("Non-query dist sql is not supported within a transaction");
- }
+ ShardingSpherePreconditions.checkState(!connectionSession.getTransactionStatus().isInTransaction() || isSupportedDistSQLStatementInTransaction(sqlStatement),
+ new UnsupportedSQLOperationException("Non-query dist sql is not supported within a transaction"));
}
private static boolean isSupportedDistSQLStatementInTransaction(final SQLStatement sqlStatement) {
@@ -208,7 +209,7 @@ public final class ProxyBackendHandlerFactory {
private static void checkUnsupportedSQLStatement(final SQLStatement sqlStatement) {
if (sqlStatement instanceof DCLStatement || sqlStatement instanceof FlushStatement || sqlStatement instanceof MySQLShowCreateUserStatement) {
- throw new UnsupportedOperationException("Unsupported operation");
+ throw new UnsupportedSQLOperationException("Unsupported operation");
}
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactory.java
index 4032db3d2f6..8ea283f9b1d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactory.java
@@ -19,8 +19,9 @@ package org.apache.shardingsphere.proxy.backend.handler.database;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
@@ -52,6 +53,6 @@ public final class DatabaseOperateBackendHandlerFactory {
if (sqlStatement instanceof DropDatabaseStatement) {
return new DropDatabaseBackendHandler((DropDatabaseStatement) sqlStatement, connectionSession);
}
- throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
+ throw new UnsupportedSQLOperationException(sqlStatement.getClass().getCanonicalName());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
index 0d910a543bc..0c433759066 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactory.java
@@ -24,12 +24,13 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.RDLStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
import org.apache.shardingsphere.distsql.parser.statement.rul.RULStatement;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.RALBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.RDLBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.RQLBackendHandlerFactory;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rul.RULBackendHandlerFactory;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import java.sql.SQLException;
@@ -60,6 +61,6 @@ public final class DistSQLBackendHandlerFactory {
if (sqlStatement instanceof RULStatement) {
return RULBackendHandlerFactory.newInstance((RULStatement) sqlStatement, connectionSession);
}
- throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
+ throw new UnsupportedSQLOperationException(sqlStatement.getClass().getCanonicalName());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
index 161cacebad7..96088cc3cd8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
@@ -45,6 +45,8 @@ import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.SetVaria
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.UnlabelInstanceStatement;
import org.apache.shardingsphere.infra.distsql.query.DatabaseDistSQLResultSet;
import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.HintRALBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.migration.query.QueryableScalingRALBackendHandler;
@@ -141,15 +143,13 @@ public final class RALBackendHandlerFactory {
try {
return clazz.getDeclaredConstructor().newInstance();
} catch (final ReflectiveOperationException ex) {
- throw new UnsupportedOperationException(String.format("Can not find public constructor for class `%s`", clazz.getName()));
+ throw new UnsupportedSQLOperationException(String.format("Can not find public constructor for class `%s`", clazz.getName()));
}
}
private static RALBackendHandler<?> createRALBackendHandler(final RALStatement sqlStatement, final ConnectionSession connectionSession) {
Class<? extends RALBackendHandler<?>> clazz = HANDLERS.get(sqlStatement.getClass());
- if (null == clazz) {
- throw new UnsupportedOperationException(String.format("Unsupported SQL statement : %s", sqlStatement.getClass().getCanonicalName()));
- }
+ ShardingSpherePreconditions.checkState(null != clazz, new UnsupportedSQLOperationException(String.format("Unsupported SQL statement : %s", sqlStatement.getClass().getCanonicalName())));
RALBackendHandler<?> result = newInstance(clazz);
result.init(sqlStatement, connectionSession);
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALBackendHandler.java
index 8cc7aeb229f..3986e497c18 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALBackendHandler.java
@@ -21,11 +21,13 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.HintRALStatement;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.RALBackendHandler;
import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.RALBackendHandler;
import java.sql.SQLException;
@@ -44,9 +46,9 @@ public final class HintRALBackendHandler extends RALBackendHandler {
@Override
public ResponseHeader execute() throws SQLException {
- if (!ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)) {
- throw new UnsupportedOperationException(String.format("%s should be true, please check your config", ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey()));
- }
+ ShardingSpherePreconditions.checkState(
+ ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED),
+ new UnsupportedSQLOperationException(String.format("%s should be true, please check your config", ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey())));
hintRALStatementExecutor = HintRALStatementExecutorFactory.newInstance(sqlStatement, connectionSession);
return hintRALStatementExecutor.execute();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALStatementExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALStatementExecutorFactory.java
index 863e59da350..93e8f74194e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALStatementExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/HintRALStatementExecutorFactory.java
@@ -21,7 +21,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.HintRALStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.hint.ClearHintStatement;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor.AddShardingHintDatabaseValueExecutor;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor.AddShardingHintTableValueExecutor;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor.ClearHintExecutor;
@@ -31,6 +31,7 @@ import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor.SetShardingHintDatabaseValueExecutor;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor.ShowReadwriteSplittingHintStatusExecutor;
import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.executor.ShowShardingHintStatusExecutor;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.ClearReadwriteSplittingHintStatement;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.SetReadwriteSplittingHintStatement;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.ShowReadwriteSplittingHintStatusStatement;
@@ -84,6 +85,6 @@ public final class HintRALStatementExecutorFactory {
if (sqlStatement instanceof ClearShardingHintStatement) {
return new ClearShardingHintExecutor();
}
- throw new UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
+ throw new UnsupportedSQLOperationException(sqlStatement.getClass().getCanonicalName());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/enums/HintSourceType.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/enums/HintSourceType.java
index 6118921a284..234b585713f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/enums/HintSourceType.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/hint/enums/HintSourceType.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.hint.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
/**
* Hint source type.
@@ -45,6 +46,6 @@ public enum HintSourceType {
return each;
}
}
- throw new UnsupportedOperationException("unsupported hint source type: " + value);
+ throw new UnsupportedSQLOperationException(String.format("unsupported hint source type: %s", value));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LabelInstanceHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LabelInstanceHandler.java
index d3017e1cf77..ae078b56d2e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LabelInstanceHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LabelInstanceHandler.java
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LabelInstanceStatement;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsChangedEvent;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -39,9 +41,8 @@ public final class LabelInstanceHandler extends UpdatableRALBackendHandler<Label
@Override
public void update(final ContextManager contextManager) {
MetaDataPersistService persistService = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getPersistService();
- if (null == persistService || null == persistService.getRepository() || persistService.getRepository() instanceof StandalonePersistRepository) {
- throw new UnsupportedOperationException("Labels can only be added in cluster mode");
- }
+ ShardingSpherePreconditions.checkState(null != persistService && null != persistService.getRepository() && !(persistService.getRepository() instanceof StandalonePersistRepository),
+ new UnsupportedSQLOperationException("Labels can only be added in cluster mode"));
String instanceId = getSqlStatement().getInstanceId();
Optional<ComputeNodeInstance> computeNodeInstance = contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId);
if (computeNodeInstance.isPresent()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetInstanceStatusHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetInstanceStatusHandler.java
index 1a0252fb07f..555db422c5f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetInstanceStatusHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetInstanceStatusHandler.java
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.SetInstanceStatusStatement;
import org.apache.shardingsphere.infra.state.StateType;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.ComputeNodeStatus;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.ComputeNodeStatusChangedEvent;
@@ -31,9 +33,7 @@ public final class SetInstanceStatusHandler extends UpdatableRALBackendHandler<S
@Override
protected void update(final ContextManager contextManager) {
- if (!contextManager.getInstanceContext().isCluster()) {
- throw new UnsupportedOperationException("Only allowed in cluster mode");
- }
+ ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().isCluster(), new UnsupportedSQLOperationException("Only allowed in cluster mode"));
String instanceId = getSqlStatement().getInstanceId();
boolean isDisable = "DISABLE".equals(getSqlStatement().getStatus());
if (isDisable) {
@@ -45,20 +45,16 @@ public final class SetInstanceStatusHandler extends UpdatableRALBackendHandler<S
}
private void checkEnablingIsValid(final ContextManager contextManager, final String instanceId) {
- if (!contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId).isPresent()) {
- throw new UnsupportedOperationException(String.format("`%s` does not exist", instanceId));
- }
+ ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId).isPresent(),
+ new UnsupportedSQLOperationException(String.format("`%s` does not exist", instanceId)));
}
private void checkDisablingIsValid(final ContextManager contextManager, final String instanceId) {
- if (contextManager.getInstanceContext().getInstance().getCurrentInstanceId().equals(instanceId)) {
- throw new UnsupportedOperationException(String.format("`%s` is the currently in use instance and cannot be disabled", instanceId));
- }
- if (!contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId).isPresent()) {
- throw new UnsupportedOperationException(String.format("`%s` does not exist", instanceId));
- }
- if (contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId).get().getState().getCurrentState() == StateType.CIRCUIT_BREAK) {
- throw new UnsupportedOperationException(String.format("`%s` compute node has been disabled", instanceId));
- }
+ ShardingSpherePreconditions.checkState(!contextManager.getInstanceContext().getInstance().getCurrentInstanceId().equals(instanceId),
+ new UnsupportedSQLOperationException(String.format("`%s` is the currently in use instance and cannot be disabled", instanceId)));
+ ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId).isPresent(),
+ new UnsupportedSQLOperationException(String.format("`%s` does not exist", instanceId)));
+ ShardingSpherePreconditions.checkState(StateType.CIRCUIT_BREAK != contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId).get().getState().getCurrentState(),
+ new UnsupportedSQLOperationException(String.format("`%s` compute node has been disabled", instanceId)));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
index c6546f33f1a..0aeae07b54b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
@@ -19,14 +19,16 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
+import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSelectedException;
+import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
import org.apache.shardingsphere.infra.distsql.constant.ExportableItemConstants;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.distsql.exception.resource.RequiredResourceMissedException;
-import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSelectedException;
-import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDatabase;
import org.apache.shardingsphere.infra.rule.identifier.type.exportable.RuleExportEngine;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.storage.service.StorageNodeStatusService;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -78,15 +80,11 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
private void checkReadwriteSplittingRule(final ContextManager contextManager, final String databaseName) {
Optional<ReadwriteSplittingRule> rule = contextManager.getMetaDataContexts().getMetaData().getDatabase(databaseName).getRuleMetaData().findSingleRule(ReadwriteSplittingRule.class);
- if (!rule.isPresent()) {
- throw new UnsupportedOperationException("The current schema has no read_write splitting rules");
- }
+ ShardingSpherePreconditions.checkState(rule.isPresent(), new UnsupportedSQLOperationException("The current schema has no read_write splitting rules"));
}
private void checkModeAndPersistRepository(final ContextManager contextManager) {
- if (!contextManager.getInstanceContext().isCluster()) {
- throw new UnsupportedOperationException("Mode must be `Cluster`.");
- }
+ ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().isCluster(), new UnsupportedSQLOperationException("Mode must be `Cluster`"));
}
private void checkDatabaseName(final String databaseName) {
@@ -131,9 +129,7 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
}
private void checkIsNotDisabled(final Collection<String> disabledResources, final String toBeEnabledResource) {
- if (!disabledResources.contains(toBeEnabledResource)) {
- throw new UnsupportedOperationException(String.format("`%s` is not disabled", toBeEnabledResource));
- }
+ ShardingSpherePreconditions.checkState(disabledResources.contains(toBeEnabledResource), new UnsupportedSQLOperationException(String.format("`%s` is not disabled", toBeEnabledResource)));
}
private void checkDisable(final ContextManager contextManager, final String databaseName, final Collection<String> disabledResources, final String toBeDisabledResource,
@@ -146,24 +142,21 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
private void checkIsDisabled(final Map<String, String> replicaResources, final Collection<String> disabledResources, final String toBeDisabledResource) {
String toBeDisableResourceRuleNames = replicaResources.get(toBeDisabledResource);
- if (Strings.isNullOrEmpty(toBeDisableResourceRuleNames) && disabledResources.contains(toBeDisabledResource)) {
- throw new UnsupportedOperationException(String.format("`%s` has been disabled", toBeDisabledResource));
- }
+ ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(toBeDisableResourceRuleNames) || !disabledResources.contains(toBeDisabledResource),
+ new UnsupportedSQLOperationException(String.format("`%s` has been disabled", toBeDisabledResource)));
}
private void checkIsReplicaResource(final Map<String, String> replicaResources, final String toBeDisabledResource) {
- if (!replicaResources.containsKey(toBeDisabledResource)) {
- throw new UnsupportedOperationException(String.format("`%s` is not used as a read resource by any read-write separation rules,cannot be disabled", toBeDisabledResource));
- }
+ ShardingSpherePreconditions.checkState(replicaResources.containsKey(toBeDisabledResource),
+ new UnsupportedSQLOperationException(String.format("`%s` is not used as a read resource by any read-write separation rules,cannot be disabled", toBeDisabledResource)));
}
private void checkIsLastResource(final Map<String, String> replicaResources, final String toBeDisabledResource) {
Collection<String> onlyOneResourceRules = getOnlyOneResourceRules(replicaResources);
Collection<String> toBeDisabledResourceRuleNames = Splitter.on(",").trimResults().splitToList(replicaResources.get(toBeDisabledResource));
onlyOneResourceRules = onlyOneResourceRules.stream().filter(toBeDisabledResourceRuleNames::contains).collect(Collectors.toSet());
- if (!onlyOneResourceRules.isEmpty()) {
- throw new UnsupportedOperationException(String.format("`%s` is the last read resource in `%s`, cannot be disabled", toBeDisabledResource, onlyOneResourceRules));
- }
+ ShardingSpherePreconditions.checkState(onlyOneResourceRules.isEmpty(),
+ new UnsupportedSQLOperationException(String.format("`%s` is the last read resource in `%s`, cannot be disabled", toBeDisabledResource, onlyOneResourceRules)));
}
private Collection<String> getGroupNames(final String toBeDisableResource, final Map<String, String> replicaResources,
@@ -182,8 +175,7 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
private Collection<QualifiedDatabase> getDisabledStorageNodes(final String databaseName, final MetaDataPersistService persistService) {
Map<String, StorageNodeDataSource> storageNodes = new StorageNodeStatusService((ClusterPersistRepository) persistService.getRepository()).loadStorageNodes();
return storageNodes.entrySet().stream().filter(each -> StorageNodeStatus.DISABLED.name().equalsIgnoreCase(each.getValue().getStatus()))
- .map(each -> new QualifiedDatabase(each.getKey())).filter(each -> databaseName.equalsIgnoreCase(each.getDatabaseName()))
- .collect(Collectors.toList());
+ .map(each -> new QualifiedDatabase(each.getKey())).filter(each -> databaseName.equalsIgnoreCase(each.getDatabaseName())).collect(Collectors.toList());
}
private Map<String, Map<String, String>> getExportedReadwriteSplittingRules(final ContextManager contextManager, final String databaseName) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlabelInstanceHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlabelInstanceHandler.java
index 8f2d9cd18bc..103b4d70ec8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlabelInstanceHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlabelInstanceHandler.java
@@ -20,6 +20,8 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.UnlabelInstanceStatement;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.LabelsChangedEvent;
import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
@@ -41,9 +43,8 @@ public final class UnlabelInstanceHandler extends UpdatableRALBackendHandler<Unl
@Override
protected void update(final ContextManager contextManager) throws DistSQLException {
MetaDataPersistService persistService = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getPersistService();
- if (null == persistService.getRepository() || persistService.getRepository() instanceof StandalonePersistRepository) {
- throw new UnsupportedOperationException("Labels can only be removed in cluster mode");
- }
+ ShardingSpherePreconditions.checkState(null != persistService.getRepository() && !(persistService.getRepository() instanceof StandalonePersistRepository),
+ new UnsupportedSQLOperationException("Labels can only be removed in cluster mode"));
String instanceId = getSqlStatement().getInstanceId();
Optional<ComputeNodeInstance> computeNodeInstance = contextManager.getInstanceContext().getComputeNodeInstanceById(instanceId);
if (computeNodeInstance.isPresent()) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
index 8f1f3e7dbd8..a4549ee2591 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionDropUpdater;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater;
import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdaterFactory;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.DatabaseRequiredBackendHandler;
@@ -90,7 +91,7 @@ public final class RuleDefinitionBackendHandler<T extends RuleDefinitionStatemen
} else if (updater instanceof RuleDefinitionDropUpdater) {
processDrop(result, sqlStatement, (RuleDefinitionDropUpdater) updater, currentRuleConfig);
} else {
- throw new UnsupportedOperationException(String.format("Cannot support RDL updater type `%s`", updater.getClass().getCanonicalName()));
+ throw new UnsupportedSQLOperationException(String.format("Cannot support RDL updater type `%s`", updater.getClass().getCanonicalName()));
}
ProxyContext.getInstance().getContextManager().alterRuleConfiguration(database.getName(), result);
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandlerFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandlerFactory.java
index 8f5cd3161fe..14456a1fd65 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandlerFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rul/RULBackendHandlerFactory.java
@@ -23,11 +23,13 @@ import org.apache.shardingsphere.distsql.parser.statement.rul.RULStatement;
import org.apache.shardingsphere.distsql.parser.statement.rul.sql.FormatStatement;
import org.apache.shardingsphere.distsql.parser.statement.rul.sql.ParseStatement;
import org.apache.shardingsphere.distsql.parser.statement.rul.sql.PreviewStatement;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rul.sql.FormatSQLHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rul.sql.ParseDistSQLHandler;
import org.apache.shardingsphere.proxy.backend.handler.distsql.rul.sql.PreviewHandler;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import java.sql.SQLException;
import java.util.HashMap;
@@ -63,15 +65,13 @@ public final class RULBackendHandlerFactory {
try {
return clazz.getDeclaredConstructor().newInstance();
} catch (final ReflectiveOperationException ex) {
- throw new UnsupportedOperationException(String.format("Can not find public constructor for class `%s`", clazz.getName()));
+ throw new UnsupportedSQLOperationException(String.format("Can not find public constructor for class `%s`", clazz.getName()));
}
}
private static RULBackendHandler<?> createRULBackendHandler(final RULStatement sqlStatement, final ConnectionSession connectionSession) {
Class<? extends RULBackendHandler<?>> clazz = HANDLERS.get(sqlStatement.getClass());
- if (null == clazz) {
- throw new UnsupportedOperationException(String.format("Unsupported SQL statement : %s", sqlStatement.getClass().getCanonicalName()));
- }
+ ShardingSpherePreconditions.checkState(null != clazz, new UnsupportedSQLOperationException(String.format("Unsupported SQL statement : %s", sqlStatement.getClass().getCanonicalName())));
RULBackendHandler<?> result = newInstance(clazz);
result.init(sqlStatement, connectionSession);
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
index 4a88ae2c324..5c11c312e52 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
@@ -240,7 +241,7 @@ public final class ProxyBackendHandlerFactoryTest extends ProxyContextRestorer {
ProxyBackendHandlerFactory.newInstance(databaseType, sql, connectionSession);
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertUnsupportedNonQueryDistSQLInTransaction() throws SQLException {
when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(true);
String sql = "CREATE SHARDING KEY GENERATOR snowflake_key_generator (TYPE(NAME='SNOWFLAKE', PROPERTIES('max-vibration-offset'='3')));";
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java
index c5ef06835d0..40074a4ea4b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.proxy.backend.handler.database;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
@@ -39,7 +40,7 @@ public final class DatabaseOperateBackendHandlerFactoryTest {
assertThat(DatabaseOperateBackendHandlerFactory.newInstance(mock(DropDatabaseStatement.class), mock(ConnectionSession.class)), instanceOf(DropDatabaseBackendHandler.class));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertDatabaseOperateBackendHandlerFactoryThrowUnsupportedOperationException() throws SQLException {
DatabaseOperateBackendHandlerFactory.newInstance(mock(AlterDatabaseStatement.class), mock(ConnectionSession.class));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/PreparedStatementRegistryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/PreparedStatementRegistryTest.java
index 35d440310d5..3cbff4ea0ad 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/PreparedStatementRegistryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/PreparedStatementRegistryTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.backend.session;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.junit.Test;
@@ -43,17 +44,17 @@ public final class PreparedStatementRegistryTest {
@Override
public String getSql() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("");
}
@Override
public SQLStatement getSqlStatement() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("");
}
@Override
public Optional<SQLStatementContext<?>> getSqlStatementContext() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("");
}
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
index 39e6aa7638c..4ed10956953 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyState.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.state.impl;
import io.netty.channel.ChannelHandlerContext;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
@@ -29,6 +30,6 @@ public final class LockProxyState implements ProxyState {
@Override
public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) {
- throw new UnsupportedOperationException("LockProxyState");
+ throw new UnsupportedSQLOperationException("LockProxyState");
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java
index 73be17fa2ae..12828d59288 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/LockProxyStateTest.java
@@ -17,11 +17,12 @@
package org.apache.shardingsphere.proxy.frontend.state.impl;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
public final class LockProxyStateTest {
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertExecute() {
new LockProxyState().execute(null, null, null, null);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
index e01fe9ab657..60e445981fb 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutor.java
@@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.close.PostgreSQLCloseCompletePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.close.PostgreSQLComClosePacket;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLConnectionContext;
@@ -48,15 +49,11 @@ public final class PostgreSQLComCloseExecutor implements CommandExecutor {
connectionSession.getPreparedStatementRegistry().removePreparedStatement(packet.getName());
break;
case PORTAL:
- closePortal();
+ connectionContext.closePortal(packet.getName());
break;
default:
- throw new UnsupportedOperationException(packet.getType().name());
+ throw new UnsupportedSQLOperationException(packet.getType().name());
}
return Collections.singletonList(new PostgreSQLCloseCompletePacket());
}
-
- private void closePortal() throws SQLException {
- connectionContext.closePortal(packet.getName());
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
index 488e9ceb03b..2d565154955 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
@@ -38,6 +38,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -88,7 +89,7 @@ public final class PostgreSQLComDescribeExecutor implements CommandExecutor {
case 'P':
return Collections.singletonList(connectionContext.getPortal(packet.getName()).describe());
default:
- throw new UnsupportedOperationException("Unsupported describe type: " + packet.getType());
+ throw new UnsupportedSQLOperationException("Unsupported describe type: " + packet.getType());
}
}
@@ -109,9 +110,9 @@ public final class PostgreSQLComDescribeExecutor implements CommandExecutor {
private void tryDescribePreparedStatement(final PostgreSQLPreparedStatement preparedStatement) throws SQLException {
if (preparedStatement.getSqlStatement() instanceof InsertStatement) {
describeInsertStatementByDatabaseMetaData(preparedStatement);
- return;
+ } else {
+ tryDescribePreparedStatementByJDBC(preparedStatement);
}
- tryDescribePreparedStatementByJDBC(preparedStatement);
}
private void describeInsertStatementByDatabaseMetaData(final PostgreSQLPreparedStatement preparedStatement) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index 567df89a639..16f5972e37f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -35,6 +35,7 @@ import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRule
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -296,7 +297,7 @@ public final class PostgreSQLComDescribeExecutorTest extends ProxyContextRestore
return (List<PostgreSQLColumnDescription>) columnDescriptionsField.get(packet);
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertDescribeUnknownType() throws SQLException {
new PostgreSQLComDescribeExecutor(connectionContext, packet, connectionSession).execute();
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java
index f95658d33f3..ef160ae5272 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/format/facade/OpenGaussFormatSQLVisitorFacade.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.sql.parser.opengauss.visitor.format.facade;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
@@ -32,32 +33,32 @@ public final class OpenGaussFormatSQLVisitorFacade implements SQLVisitorFacade {
@Override
public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDMLVisitorClass");
}
@Override
public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDDLVisitorClass");
}
@Override
public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getTCLVisitorClass");
}
@Override
public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDCLVisitorClass");
}
@Override
public Class<? extends DALSQLVisitor> getDALVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDALVisitorClass");
}
@Override
public Class<? extends RLSQLVisitor> getRLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getRLVisitorClass");
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/facade/OracleFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/facade/OracleFormatSQLVisitorFacade.java
index 5783edb1d30..e63bb478f80 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/facade/OracleFormatSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/facade/OracleFormatSQLVisitorFacade.java
@@ -17,13 +17,14 @@
package org.apache.shardingsphere.sql.parser.oracle.visitor.format.facade;
-import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DMLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.RLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
/**
* Format SQL Visitor facade for Oracle.
@@ -32,32 +33,32 @@ public final class OracleFormatSQLVisitorFacade implements SQLVisitorFacade {
@Override
public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDMLVisitorClass");
}
@Override
public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDDLVisitorClass");
}
@Override
public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getTCLVisitorClass");
}
@Override
public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getTCLVisitorClass");
}
@Override
public Class<? extends DALSQLVisitor> getDALVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDALVisitorClass");
}
@Override
public Class<? extends RLSQLVisitor> getRLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getRLVisitorClass");
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/PostgreSQLFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/PostgreSQLFormatSQLVisitorFacade.java
index 74dc4c67b70..a213569ce14 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/PostgreSQLFormatSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/facade/PostgreSQLFormatSQLVisitorFacade.java
@@ -17,13 +17,14 @@
package org.apache.shardingsphere.sql.parser.postgresql.visitor.format.facade;
-import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DMLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.RLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
/**
* Format SQL Visitor facade for PostgreSQL.
@@ -32,32 +33,32 @@ public final class PostgreSQLFormatSQLVisitorFacade implements SQLVisitorFacade
@Override
public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDMLVisitorClass");
}
@Override
public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDDLVisitorClass");
}
@Override
public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getTCLVisitorClass");
}
@Override
public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDCLVisitorClass");
}
@Override
public Class<? extends DALSQLVisitor> getDALVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDALVisitorClass");
}
@Override
public Class<? extends RLSQLVisitor> getRLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getRLVisitorClass");
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/facade/SQL92FormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/facade/SQL92FormatSQLVisitorFacade.java
index a761656d033..99b38affef7 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/facade/SQL92FormatSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/facade/SQL92FormatSQLVisitorFacade.java
@@ -17,13 +17,14 @@
package org.apache.shardingsphere.sql.parser.sql92.visitor.format.facade;
-import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DMLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.RLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
/**
* Format SQL Visitor facade for SQL92.
@@ -32,32 +33,32 @@ public final class SQL92FormatSQLVisitorFacade implements SQLVisitorFacade {
@Override
public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDMLVisitorClass");
}
@Override
public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDDLVisitorClass");
}
@Override
public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getTCLVisitorClass");
}
@Override
public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDCLVisitorClass");
}
@Override
public Class<? extends DALSQLVisitor> getDALVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDALVisitorClass");
}
@Override
public Class<? extends RLSQLVisitor> getRLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getRLVisitorClass");
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/facade/SQLServerFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/facade/SQLServerFormatSQLVisitorFacade.java
index 3ccf4aa0e1a..83e0120eb93 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/facade/SQLServerFormatSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/facade/SQLServerFormatSQLVisitorFacade.java
@@ -17,13 +17,14 @@
package org.apache.shardingsphere.sql.parser.sqlserver.visitor.format.facade;
-import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DCLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DDLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.DMLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.RLSQLVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.type.TCLSQLVisitor;
+import org.apache.shardingsphere.sql.parser.spi.SQLVisitorFacade;
/**
* Format SQL Visitor facade for SQLServer.
@@ -32,32 +33,32 @@ public final class SQLServerFormatSQLVisitorFacade implements SQLVisitorFacade {
@Override
public Class<? extends DMLSQLVisitor> getDMLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDMLVisitorClass");
}
@Override
public Class<? extends DDLSQLVisitor> getDDLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDDLVisitorClass");
}
@Override
public Class<? extends TCLSQLVisitor> getTCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getTCLVisitorClass");
}
@Override
public Class<? extends DCLSQLVisitor> getDCLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDCLVisitorClass");
}
@Override
public Class<? extends DALSQLVisitor> getDALVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getDALVisitorClass");
}
@Override
public Class<? extends RLSQLVisitor> getRLVisitorClass() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedSQLOperationException("getRLVisitorClass");
}
@Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
index 81ce9e66cb5..d2d79cc3614 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
@@ -21,6 +21,7 @@ import com.google.common.base.CharMatcher;
import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
import org.apache.shardingsphere.sql.parser.sql.common.constant.Paren;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
@@ -223,7 +224,7 @@ public final class SQLUtil {
if (sqlStatement instanceof DCLStatement) {
return false;
}
- throw new UnsupportedOperationException(String.format("Unsupported SQL Type `%s`", sqlStatement.getClass().getSimpleName()));
+ throw new UnsupportedSQLOperationException(String.format("Unsupported SQL Type `%s`", sqlStatement.getClass().getSimpleName()));
}
private static boolean isReadOnly(final DMLStatement sqlStatement) {
@@ -233,7 +234,7 @@ public final class SQLUtil {
if (sqlStatement instanceof UpdateStatement || sqlStatement instanceof DeleteStatement || sqlStatement instanceof InsertStatement) {
return false;
}
- throw new UnsupportedOperationException(String.format("Unsupported SQL Type `%s`", sqlStatement.getClass().getSimpleName()));
+ throw new UnsupportedSQLOperationException(String.format("Unsupported SQL Type `%s`", sqlStatement.getClass().getSimpleName()));
}
private static boolean isReadOnly(final DALStatement sqlStatement) {
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMergerTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMergerTest.java
index 9430794d0f9..5074b38fbb1 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMergerTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/importer/DataRecordMergerTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.data.pipeline.api.ingest.record.DataRecord;
import org.apache.shardingsphere.data.pipeline.api.ingest.record.GroupedDataRecord;
import org.apache.shardingsphere.data.pipeline.core.exception.PipelineUnexpectedDataRecordOrderException;
import org.apache.shardingsphere.data.pipeline.core.ingest.IngestDataChangeType;
+import org.apache.shardingsphere.infra.util.exception.external.sql.UnsupportedSQLOperationException;
import org.junit.Test;
import java.util.Arrays;
@@ -157,7 +158,7 @@ public final class DataRecordMergerTest {
assertThat(dataRecord.getColumn(2).getValue(), is(2));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedSQLOperationException.class)
public void assertDeleteBeforeUpdate() {
beforeDataRecord = mockDeleteDataRecord(1, 1, 1);
afterDataRecord = mockUpdateDataRecord(1, 2, 2);