This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 49bd8394603 Refactor DistSQLErrorCode (#20146)
49bd8394603 is described below
commit 49bd83946030fab9f2a6c8f2f564ce120ad8d7ef
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Aug 13 18:10:51 2022 +0800
Refactor DistSQLErrorCode (#20146)
---
.../error/sqlstate/XOpenSQLState.java | 4 ++-
.../ral/common/exception/DistSQLErrorCode.java | 5 +--
.../distsql/ral/common/exception/DistSQLState.java | 36 ----------------------
.../mysql/err/MySQLErrPacketFactoryTest.java | 4 +--
4 files changed, 8 insertions(+), 41 deletions(-)
diff --git
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/sqlstate/XOpenSQLState.java
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/sqlstate/XOpenSQLState.java
index 74646354c57..0d983437492 100644
---
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/sqlstate/XOpenSQLState.java
+++
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/sqlstate/XOpenSQLState.java
@@ -49,7 +49,9 @@ public enum XOpenSQLState implements SQLState {
NOT_FOUND("42S02"),
- GENERAL_ERROR("HY000");
+ GENERAL_ERROR("HY000"),
+
+ INVALID_DATA_TYPE("HY004");
private final String value;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLErrorCode.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLErrorCode.java
index 029af54a79e..95f51c4e883 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLErrorCode.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLErrorCode.java
@@ -21,6 +21,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.error.code.SQLErrorCode;
import org.apache.shardingsphere.error.sqlstate.SQLState;
+import org.apache.shardingsphere.error.sqlstate.XOpenSQLState;
/**
* Dist SQL error code.
@@ -29,9 +30,9 @@ import org.apache.shardingsphere.error.sqlstate.SQLState;
@Getter
public enum DistSQLErrorCode implements SQLErrorCode {
- UNSUPPORTED_VARIABLE(DistSQLState.UNSUPPORTED_VARIABLE, 11001, "Could not
support variable `%s`."),
+ UNSUPPORTED_VARIABLE(XOpenSQLState.GENERAL_ERROR, 11001, "Could not
support variable `%s`"),
- INVALID_VALUE(DistSQLState.INVALID_VALUE, 11002, "Invalid value `%s`.");
+ INVALID_VALUE(XOpenSQLState.INVALID_DATA_TYPE, 11002, "Invalid value
`%s`");
private final SQLState sqlState;
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLState.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLState.java
deleted file mode 100644
index cd10fd9ef07..00000000000
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLState.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.error.sqlstate.SQLState;
-
-/**
- * Dist SQL state.
- */
-@RequiredArgsConstructor
-@Getter
-public enum DistSQLState implements SQLState {
-
- UNSUPPORTED_VARIABLE("11001"),
-
- INVALID_VALUE("11002");
-
- private final String value;
-}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
index 918d9a8cf18..b84f902c23a 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
@@ -77,8 +77,8 @@ public final class MySQLErrPacketFactoryTest {
MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new
UnsupportedVariableException("test"));
assertThat(actual.getSequenceId(), is(1));
assertThat(actual.getErrorCode(), is(11001));
- assertThat(actual.getSqlState(), is("11001"));
- assertThat(actual.getErrorMessage(), is("Could not support variable
`test`."));
+ assertThat(actual.getSqlState(), is("HY000"));
+ assertThat(actual.getErrorMessage(), is("Could not support variable
`test`"));
}
@Test