This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 103b1995381 Add invalid mode exception (#30451)
103b1995381 is described below
commit 103b19953817c2ef5d14db71962b76c2ccfd678d
Author: Raigor <[email protected]>
AuthorDate: Mon Mar 11 18:23:45 2024 +0800
Add invalid mode exception (#30451)
---
.../content/user-manual/error-code/sql-error-code.cn.md | 2 ++
.../content/user-manual/error-code/sql-error-code.en.md | 2 ++
.../metadata/DuplicateSharingActualDataNodeException.java | 2 +-
.../handler/exception/mode/InvalidModeException.java | 15 +++++++--------
.../handler/required/DistSQLExecutorRequiredChecker.java | 4 ++--
5 files changed, 14 insertions(+), 11 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 bf16c6b2db5..1c37d08bb84 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
@@ -161,6 +161,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| 44000 | 19151 | %s algorithm(s) \`%s\` do not exist in database
\`%s\`. |
| 44000 | 19152 | %s algorithms \`%s\` in database \`%s\` are still
in used. |
| 44000 | 19153 | Duplicate %s algorithms \`%s\` in database \`%s\`.
|
+| 44000 | 19154 | Invalid mode, error message is: \`%s\`.
|
+| 44000 | 19155 | Plugin class \`%s\` not found..
|
## 功能异常
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 67751bf492d..320ea5dae87 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
@@ -161,6 +161,8 @@ SQL error codes provide by standard `SQL State`, `Vendor
Code` and `Reason`, whi
| 44000 | 19151 | %s algorithm(s) \`%s\` do not exist in database
\`%s\`. |
| 44000 | 19152 | %s algorithms \`%s\` in database \`%s\` are still
in used. |
| 44000 | 19153 | Duplicate %s algorithms \`%s\` in database \`%s\`.
|
+| 44000 | 19154 | Invalid mode, error message is: \`%s\`.
|
+| 44000 | 19155 | Plugin class \`%s\` not found..
|
## Feature Exception
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
index 1ff901c646a..ccd6fb90a6d 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
@@ -28,7 +28,7 @@ public final class DuplicateSharingActualDataNodeException
extends ShardingSQLEx
private static final long serialVersionUID = 3503761639898230998L;
public DuplicateSharingActualDataNodeException(final String
logicalTableName, final String dataSourceName, final String tableName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 154, String.format(
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 14, String.format(
"Same actual data node cannot be configured in multiple logic
tables in same database, logical table:`%s`, actual data node: `%s`.`%s`.",
logicalTableName, dataSourceName, tableName));
}
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/mode/InvalidModeException.java
similarity index 54%
copy from
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
copy to
infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/mode/InvalidModeException.java
index 1ff901c646a..36edff65c95 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateSharingActualDataNodeException.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/exception/mode/InvalidModeException.java
@@ -15,20 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.exception.metadata;
+package org.apache.shardingsphere.distsql.handler.exception.mode;
import
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
/**
- * Duplicate sharding actual data node exception.
+ * Invalid mode exception.
*/
-public final class DuplicateSharingActualDataNodeException extends
ShardingSQLException {
+public final class InvalidModeException extends DistSQLException {
- private static final long serialVersionUID = 3503761639898230998L;
+ private static final long serialVersionUID = 7094702927472630479L;
- public DuplicateSharingActualDataNodeException(final String
logicalTableName, final String dataSourceName, final String tableName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 154, String.format(
- "Same actual data node cannot be configured in multiple logic
tables in same database, logical table:`%s`, actual data node: `%s`.`%s`.",
logicalTableName, dataSourceName, tableName));
+ public InvalidModeException(final String errorMessage) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 154, "Invalid mode, error
message is: %s", errorMessage);
}
}
diff --git
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
index 09948c94d42..4c4dda3a652 100644
---
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
+++
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/required/DistSQLExecutorRequiredChecker.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.distsql.handler.required;
import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.distsql.handler.exception.mode.InvalidModeException;
import
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
import
org.apache.shardingsphere.distsql.statement.rdl.rule.database.type.DropRuleStatement;
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -50,7 +50,7 @@ public final class DistSQLExecutorRequiredChecker {
}
private void checkClusterMode(final ContextManager contextManager) {
-
ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().isCluster(),
() -> new UnsupportedSQLOperationException("Mode must be `Cluster`"));
+
ShardingSpherePreconditions.checkState(contextManager.getInstanceContext().isCluster(),
() -> new InvalidModeException("Mode must be `Cluster`"));
}
private void checkCurrentRule(final SQLStatement sqlStatement, final
ContextManager contextManager, final ShardingSphereDatabase database,