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 f5748d78987 Rename VendorError (#20148)
f5748d78987 is described below
commit f5748d789870e095d17698e7b26ac8652ab4d9ee
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Aug 13 18:44:19 2022 +0800
Rename VendorError (#20148)
---
.../mysql/codec/MySQLPacketCodecEngine.java | 4 +--
.../mysql/packet/generic/MySQLErrPacket.java | 6 ++--
.../mysql/packet/generic/MySQLErrPacketTest.java | 24 ++++++++--------
.../codec/OpenGaussPacketCodecEngine.java | 5 ++--
.../generic/OpenGaussErrorResponsePacketTest.java | 4 +--
.../codec/PostgreSQLPacketCodecEngine.java | 4 +--
.../generic/PostgreSQLErrorResponsePacket.java | 8 +++---
.../generic/PostgreSQLErrorResponsePacketTest.java | 4 +--
.../shardingsphere/error/SQLExceptionHandler.java | 22 +++++++--------
.../StandardVendorError.java} | 6 ++--
.../SQLErrorCode.java => vendor/VendorError.java} | 6 ++--
.../StandardVendorErrorTest.java} | 22 +++++++--------
.../{MySQLErrorCode.java => MyVendorError.java} | 6 ++--
.../error/mysql/mapper/MySQLExceptionMapper.java | 32 +++++++++++-----------
...QLErrorCodeTest.java => MyVendorErrorTest.java} | 20 +++++++-------
...QLErrorCode.java => PostgreSQLVendorError.java} | 4 +--
.../mapper/PostgreSQLExceptionMapper.java | 6 ++--
.../client/netty/MySQLNegotiateHandlerTest.java | 4 +--
...{DistSQLErrorCode.java => DistVendorError.java} | 8 +++---
.../authentication/MySQLAuthenticationEngine.java | 14 +++++-----
.../authentication/MySQLAuthenticationHandler.java | 8 +++---
.../frontend/mysql/err/MySQLErrPacketFactory.java | 18 ++++++------
.../MySQLAuthenticationEngineTest.java | 4 +--
.../MySQLAuthenticationHandlerTest.java | 8 +++---
.../OpenGaussAuthenticationEngine.java | 6 ++--
.../OpenGaussAuthenticationHandler.java | 12 ++++----
.../opengauss/err/OpenGaussErrorPacketFactory.java | 12 ++++----
.../OpenGaussAuthenticationHandlerTest.java | 10 +++----
.../PostgreSQLAuthenticationEngine.java | 6 ++--
.../PostgreSQLAuthenticationHandler.java | 12 ++++----
.../authentication/PostgreSQLLoginResult.java | 4 +--
.../PostgreSQLAuthenticationException.java | 4 +--
.../PostgreSQLUnsupportedCommandExecutor.java | 6 ++--
.../describe/PostgreSQLComDescribeExecutor.java | 4 +--
.../postgresql/err/PostgreSQLErrPacketFactory.java | 12 ++++----
.../PostgreSQLAuthenticationHandlerTest.java | 12 ++++----
.../PostgreSQLComDescribeExecutorTest.java | 4 +--
37 files changed, 176 insertions(+), 175 deletions(-)
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
index 5ac6e4b6f6b..a1a3f78c824 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
import
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
-import org.apache.shardingsphere.error.code.StandardSQLErrorCode;
+import org.apache.shardingsphere.error.vendor.StandardVendorError;
import java.nio.charset.Charset;
import java.util.Iterator;
@@ -91,7 +91,7 @@ public final class MySQLPacketCodecEngine implements
DatabasePacketCodecEngine<M
} catch (final Exception ex) {
// CHECKSTYLE:ON
out.resetWriterIndex();
- new MySQLErrPacket(1, StandardSQLErrorCode.UNKNOWN_EXCEPTION,
ex.getMessage()).write(payload);
+ new MySQLErrPacket(1, StandardVendorError.UNKNOWN_EXCEPTION,
ex.getMessage()).write(payload);
} finally {
updateMessageHeader(out, message.getSequenceId());
}
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacket.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacket.java
index 545ebbbb3f8..8826e5a5096 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacket.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacket.java
@@ -22,7 +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.error.code.SQLErrorCode;
+import org.apache.shardingsphere.error.vendor.VendorError;
/**
* ERR packet protocol for MySQL.
@@ -48,8 +48,8 @@ public final class MySQLErrPacket implements MySQLPacket {
private final String errorMessage;
- public MySQLErrPacket(final int sequenceId, final SQLErrorCode
sqlErrorCode, final Object... errorMessageArguments) {
- this(sequenceId, sqlErrorCode.getVendorCode(),
sqlErrorCode.getSqlState().getValue(), String.format(sqlErrorCode.getReason(),
errorMessageArguments));
+ public MySQLErrPacket(final int sequenceId, final VendorError vendorError,
final Object... errorMessageArguments) {
+ this(sequenceId, vendorError.getVendorCode(),
vendorError.getSqlState().getValue(), String.format(vendorError.getReason(),
errorMessageArguments));
}
public MySQLErrPacket(final MySQLPacketPayload payload) {
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacketTest.java
index 4b56820662c..4f501940b60 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLErrPacketTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.db.protocol.mysql.packet.generic;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -37,30 +37,30 @@ public final class MySQLErrPacketTest {
@Test
public void assertNewErrPacketWithServerErrorCode() {
- MySQLErrPacket actual = new MySQLErrPacket(1,
MySQLErrorCode.ER_ACCESS_DENIED_ERROR, "root", "localhost", "root");
+ MySQLErrPacket actual = new MySQLErrPacket(1,
MyVendorError.ER_ACCESS_DENIED_ERROR, "root", "localhost", "root");
assertThat(actual.getSequenceId(), is(1));
- assertThat(actual.getErrorCode(),
is(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getVendorCode()));
- assertThat(actual.getSqlState(),
is(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getSqlState().getValue()));
- assertThat(actual.getErrorMessage(),
is(String.format(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getReason(), "root",
"localhost", "root")));
+ assertThat(actual.getErrorCode(),
is(MyVendorError.ER_ACCESS_DENIED_ERROR.getVendorCode()));
+ assertThat(actual.getSqlState(),
is(MyVendorError.ER_ACCESS_DENIED_ERROR.getSqlState().getValue()));
+ assertThat(actual.getErrorMessage(),
is(String.format(MyVendorError.ER_ACCESS_DENIED_ERROR.getReason(), "root",
"localhost", "root")));
}
@Test
public void assertNewErrPacketWithPayload() {
when(payload.readInt1()).thenReturn(1, MySQLErrPacket.HEADER);
-
when(payload.readInt2()).thenReturn(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getVendorCode());
+
when(payload.readInt2()).thenReturn(MyVendorError.ER_ACCESS_DENIED_ERROR.getVendorCode());
when(payload.readStringFix(1)).thenReturn("#");
-
when(payload.readStringFix(5)).thenReturn(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getSqlState().getValue());
-
when(payload.readStringEOF()).thenReturn(String.format(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getReason(),
"root", "localhost", "root"));
+
when(payload.readStringFix(5)).thenReturn(MyVendorError.ER_ACCESS_DENIED_ERROR.getSqlState().getValue());
+
when(payload.readStringEOF()).thenReturn(String.format(MyVendorError.ER_ACCESS_DENIED_ERROR.getReason(),
"root", "localhost", "root"));
MySQLErrPacket actual = new MySQLErrPacket(payload);
assertThat(actual.getSequenceId(), is(1));
- assertThat(actual.getErrorCode(),
is(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getVendorCode()));
- assertThat(actual.getSqlState(),
is(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getSqlState().getValue()));
- assertThat(actual.getErrorMessage(),
is(String.format(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getReason(), "root",
"localhost", "root")));
+ assertThat(actual.getErrorCode(),
is(MyVendorError.ER_ACCESS_DENIED_ERROR.getVendorCode()));
+ assertThat(actual.getSqlState(),
is(MyVendorError.ER_ACCESS_DENIED_ERROR.getSqlState().getValue()));
+ assertThat(actual.getErrorMessage(),
is(String.format(MyVendorError.ER_ACCESS_DENIED_ERROR.getReason(), "root",
"localhost", "root")));
}
@Test
public void assertWrite() {
- new MySQLErrPacket(1, MySQLErrorCode.ER_NO_DB_ERROR).write(payload);
+ new MySQLErrPacket(1, MyVendorError.ER_NO_DB_ERROR).write(payload);
verify(payload).writeInt1(MySQLErrPacket.HEADER);
verify(payload).writeInt2(1046);
verify(payload).writeStringFix("#");
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
index f79b29f0a28..ef08a319fe8 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
import
org.apache.shardingsphere.db.protocol.opengauss.packet.command.OpenGaussCommandPacketType;
import
org.apache.shardingsphere.db.protocol.opengauss.packet.command.generic.OpenGaussErrorResponsePacket;
import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
@@ -119,7 +119,8 @@ public final class OpenGaussPacketCodecEngine implements
DatabasePacketCodecEngi
// CHECKSTYLE:ON
payload.getByteBuf().resetWriterIndex();
// TODO consider what severity to use
- OpenGaussErrorResponsePacket errorResponsePacket = new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.SYSTEM_ERROR.getErrorCode(), ex.getMessage());
+ OpenGaussErrorResponsePacket errorResponsePacket = new
OpenGaussErrorResponsePacket(
+ PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLVendorError.SYSTEM_ERROR.getErrorCode(), ex.getMessage());
isPostgreSQLIdentifierPacket = true;
prepareMessageHeader(out,
errorResponsePacket.getIdentifier().getValue());
errorResponsePacket.write(payload);
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/generic/OpenGaussErrorResponsePacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/generic/OpenGaussErrorResponsePacketTest.java
index fafd725436b..dca2a8f22e0 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/generic/OpenGaussErrorResponsePacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-opengauss/src/test/java/org/apache/shardingsphere/db/protocol/opengauss/packet/command/generic/OpenGaussErrorResponsePacketTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.db.protocol.opengauss.packet.command.generic;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
@@ -84,7 +84,7 @@ public final class OpenGaussErrorResponsePacketTest {
private OpenGaussErrorResponsePacket createErrorResponsePacket() {
Map<Character, String> serverErrorMessages = new LinkedHashMap<>();
serverErrorMessages.put(OpenGaussErrorResponsePacket.FIELD_TYPE_SEVERITY,
PostgreSQLMessageSeverityLevel.FATAL);
- serverErrorMessages.put(OpenGaussErrorResponsePacket.FIELD_TYPE_CODE,
PostgreSQLErrorCode.INVALID_CATALOG_NAME.getErrorCode());
+ serverErrorMessages.put(OpenGaussErrorResponsePacket.FIELD_TYPE_CODE,
PostgreSQLVendorError.INVALID_CATALOG_NAME.getErrorCode());
serverErrorMessages.put(OpenGaussErrorResponsePacket.FIELD_TYPE_MESSAGE,
"database \"test\" does not exist");
serverErrorMessages.put(OpenGaussErrorResponsePacket.FIELD_TYPE_ERRORCODE,
"-1");
serverErrorMessages.put(OpenGaussErrorResponsePacket.FIELD_TYPE_DETAIL,
"detail");
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
index a8df939c0f2..59f031f2026 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
@@ -22,7 +22,7 @@ import io.netty.buffer.CompositeByteBuf;
import io.netty.channel.ChannelHandlerContext;
import org.apache.shardingsphere.db.protocol.CommonConstants;
import org.apache.shardingsphere.db.protocol.codec.DatabasePacketCodecEngine;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
@@ -117,7 +117,7 @@ public final class PostgreSQLPacketCodecEngine implements
DatabasePacketCodecEng
// CHECKSTYLE:ON
payload.getByteBuf().resetWriterIndex();
// TODO consider what severity to use
- PostgreSQLErrorResponsePacket errorResponsePacket =
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.SYSTEM_ERROR, ex.getMessage())
+ PostgreSQLErrorResponsePacket errorResponsePacket =
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLVendorError.SYSTEM_ERROR, ex.getMessage())
.build();
isPostgreSQLIdentifierPacket = true;
prepareMessageHeader(out,
errorResponsePacket.getIdentifier().getValue());
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacket.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacket.java
index 3ca3daa3f80..d89ea45870c 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacket.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacket.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.db.protocol.postgresql.packet.generic;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLIdentifierTag;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
@@ -106,13 +106,13 @@ public final class PostgreSQLErrorResponsePacket
implements PostgreSQLIdentifier
* Create PostgreSQL error response packet builder with required arguments.
*
* @param severity severity
- * @param postgreSQLErrorCode PostgreSQL error code
+ * @param postgreSQLvendorError PostgreSQL error code
* @param message message
* @return PostgreSQL error response packet builder
* @see <a
href="https://www.postgresql.org/docs/12/protocol-error-fields.html">52.8.
Error and Notice Message Fields</a>
*/
- public static Builder newBuilder(final String severity, final
PostgreSQLErrorCode postgreSQLErrorCode, final String message) {
- return newBuilder(severity, postgreSQLErrorCode.getErrorCode(),
message);
+ public static Builder newBuilder(final String severity, final
PostgreSQLVendorError postgreSQLvendorError, final String message) {
+ return newBuilder(severity, postgreSQLvendorError.getErrorCode(),
message);
}
/**
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacketTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacketTest.java
index 2f5616aad80..9a719a10277 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacketTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/generic/PostgreSQLErrorResponsePacketTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.db.protocol.postgresql.packet.generic;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.junit.Test;
@@ -87,7 +87,7 @@ public final class PostgreSQLErrorResponsePacketTest {
}
private PostgreSQLErrorResponsePacket createErrorResponsePacket() {
- return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLErrorCode.INVALID_CATALOG_NAME, "database \"test\" does not
exist").detail("detail")
+ return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLVendorError.INVALID_CATALOG_NAME, "database \"test\" does not
exist").detail("detail")
.hint("hint").position(1).internalQueryAndInternalPosition("internal query",
2).where("where").schemaName("test").tableName("table").columnName("column").dataTypeName("data
type")
.constraintName("constraint").file("file").line(3).routine("routine").build();
}
diff --git
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/SQLExceptionHandler.java
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/SQLExceptionHandler.java
index 36b6a7d021a..fe471c00d9f 100644
---
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/SQLExceptionHandler.java
+++
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/SQLExceptionHandler.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.error;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.error.code.SQLErrorCode;
-import org.apache.shardingsphere.error.code.StandardSQLErrorCode;
+import org.apache.shardingsphere.error.vendor.VendorError;
+import org.apache.shardingsphere.error.vendor.StandardVendorError;
import org.apache.shardingsphere.error.mapper.DialectSQLExceptionMapperFactory;
import
org.apache.shardingsphere.infra.config.exception.ShardingSphereConfigurationException;
import org.apache.shardingsphere.infra.exception.CircuitBreakException;
@@ -53,34 +53,34 @@ public final class SQLExceptionHandler {
if (insideException instanceof InsideDialectSQLException) {
return
DialectSQLExceptionMapperFactory.getInstance(databaseType).convert((InsideDialectSQLException)
insideException);
}
- return convert(insideException).orElseGet(() ->
toSQLException(StandardSQLErrorCode.UNKNOWN_EXCEPTION,
insideException.getMessage()));
+ return convert(insideException).orElseGet(() ->
toSQLException(StandardVendorError.UNKNOWN_EXCEPTION,
insideException.getMessage()));
}
private static Optional<SQLException> convert(final
ShardingSphereInsideException insideException) {
if (insideException instanceof CircuitBreakException) {
- return
Optional.of(toSQLException(StandardSQLErrorCode.CIRCUIT_BREAK_MODE));
+ return
Optional.of(toSQLException(StandardVendorError.CIRCUIT_BREAK_MODE));
}
if (insideException instanceof TableLockWaitTimeoutException) {
TableLockWaitTimeoutException exception =
(TableLockWaitTimeoutException) insideException;
- return
Optional.of(toSQLException(StandardSQLErrorCode.TABLE_LOCK_WAIT_TIMEOUT,
exception.getTableName(), exception.getSchemaName(),
exception.getTimeoutMilliseconds()));
+ return
Optional.of(toSQLException(StandardVendorError.TABLE_LOCK_WAIT_TIMEOUT,
exception.getTableName(), exception.getSchemaName(),
exception.getTimeoutMilliseconds()));
}
if (insideException instanceof TableLockedException) {
TableLockedException exception = (TableLockedException)
insideException;
- return
Optional.of(toSQLException(StandardSQLErrorCode.TABLE_LOCKED,
exception.getTableName(), exception.getSchemaName()));
+ return
Optional.of(toSQLException(StandardVendorError.TABLE_LOCKED,
exception.getTableName(), exception.getSchemaName()));
}
if (insideException instanceof RuleNotExistedException ||
insideException instanceof ResourceNotExistedException) {
- return
Optional.of(toSQLException(StandardSQLErrorCode.RESOURCE_OR_RULE_NOT_EXIST));
+ return
Optional.of(toSQLException(StandardVendorError.RESOURCE_OR_RULE_NOT_EXIST));
}
if (insideException instanceof ShardingSphereConfigurationException ||
insideException instanceof SQLParsingException) {
- return
Optional.of(toSQLException(StandardSQLErrorCode.UNSUPPORTED_SQL,
insideException.getMessage()));
+ return
Optional.of(toSQLException(StandardVendorError.UNSUPPORTED_SQL,
insideException.getMessage()));
}
if (insideException instanceof UnsupportedCommandException) {
- return
Optional.of(toSQLException(StandardSQLErrorCode.UNSUPPORTED_COMMAND,
((UnsupportedCommandException) insideException).getCommandType()));
+ return
Optional.of(toSQLException(StandardVendorError.UNSUPPORTED_COMMAND,
((UnsupportedCommandException) insideException).getCommandType()));
}
return Optional.empty();
}
- private static SQLException toSQLException(final SQLErrorCode errorCode,
final Object... messageArguments) {
- return new SQLException(String.format(errorCode.getReason(),
messageArguments), errorCode.getSqlState().getValue(),
errorCode.getVendorCode());
+ private static SQLException toSQLException(final VendorError vendorError,
final Object... messageArguments) {
+ return new SQLException(String.format(vendorError.getReason(),
messageArguments), vendorError.getSqlState().getValue(),
vendorError.getVendorCode());
}
}
diff --git
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/code/StandardSQLErrorCode.java
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/vendor/StandardVendorError.java
similarity index 93%
rename from
shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/code/StandardSQLErrorCode.java
rename to
shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/vendor/StandardVendorError.java
index 5972ba132e4..3e9fefc3f01 100644
---
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/code/StandardSQLErrorCode.java
+++
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/vendor/StandardVendorError.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.error.code;
+package org.apache.shardingsphere.error.vendor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -23,11 +23,11 @@ import org.apache.shardingsphere.error.sqlstate.SQLState;
import org.apache.shardingsphere.error.sqlstate.XOpenSQLState;
/**
- * Standard SQL error code.
+ * Standard vendor error.
*/
@RequiredArgsConstructor
@Getter
-public enum StandardSQLErrorCode implements SQLErrorCode {
+public enum StandardVendorError implements VendorError {
CIRCUIT_BREAK_MODE(XOpenSQLState.GENERAL_WARNING, 1000, "Circuit break
open, the request has been ignored"),
diff --git
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/code/SQLErrorCode.java
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/vendor/VendorError.java
similarity index 92%
rename from
shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/code/SQLErrorCode.java
rename to
shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/vendor/VendorError.java
index 21f43ff06f0..d5b40bc5f08 100644
---
a/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/code/SQLErrorCode.java
+++
b/shardingsphere-error/shardingsphere-common-error/src/main/java/org/apache/shardingsphere/error/vendor/VendorError.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.error.code;
+package org.apache.shardingsphere.error.vendor;
import org.apache.shardingsphere.error.sqlstate.SQLState;
/**
- * SQL error code.
+ * Vendor error.
*/
-public interface SQLErrorCode {
+public interface VendorError {
/**
* Get SQL state.
diff --git
a/shardingsphere-error/shardingsphere-common-error/src/test/java/org/apache/shardingsphere/error/code/StandardSQLErrorCodeTest.java
b/shardingsphere-error/shardingsphere-common-error/src/test/java/org/apache/shardingsphere/error/vendor/StandardVendorErrorTest.java
similarity index 53%
rename from
shardingsphere-error/shardingsphere-common-error/src/test/java/org/apache/shardingsphere/error/code/StandardSQLErrorCodeTest.java
rename to
shardingsphere-error/shardingsphere-common-error/src/test/java/org/apache/shardingsphere/error/vendor/StandardVendorErrorTest.java
index 5244c2a2759..8556927b0ce 100644
---
a/shardingsphere-error/shardingsphere-common-error/src/test/java/org/apache/shardingsphere/error/code/StandardSQLErrorCodeTest.java
+++
b/shardingsphere-error/shardingsphere-common-error/src/test/java/org/apache/shardingsphere/error/vendor/StandardVendorErrorTest.java
@@ -15,33 +15,33 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.error.code;
+package org.apache.shardingsphere.error.vendor;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class StandardSQLErrorCodeTest {
+public final class StandardVendorErrorTest {
@Test
public void assertCircuitBreakMode() {
-
assertThat(StandardSQLErrorCode.CIRCUIT_BREAK_MODE.getSqlState().getValue(),
is("01000"));
- assertThat(StandardSQLErrorCode.CIRCUIT_BREAK_MODE.getVendorCode(),
is(1000));
- assertThat(StandardSQLErrorCode.CIRCUIT_BREAK_MODE.getReason(),
is("Circuit break open, the request has been ignored"));
+
assertThat(StandardVendorError.CIRCUIT_BREAK_MODE.getSqlState().getValue(),
is("01000"));
+ assertThat(StandardVendorError.CIRCUIT_BREAK_MODE.getVendorCode(),
is(1000));
+ assertThat(StandardVendorError.CIRCUIT_BREAK_MODE.getReason(),
is("Circuit break open, the request has been ignored"));
}
@Test
public void assertUnsupportedCommand() {
-
assertThat(StandardSQLErrorCode.UNSUPPORTED_COMMAND.getSqlState().getValue(),
is("42000"));
- assertThat(StandardSQLErrorCode.UNSUPPORTED_COMMAND.getVendorCode(),
is(1998));
- assertThat(StandardSQLErrorCode.UNSUPPORTED_COMMAND.getReason(),
is("Unsupported command: %s"));
+
assertThat(StandardVendorError.UNSUPPORTED_COMMAND.getSqlState().getValue(),
is("42000"));
+ assertThat(StandardVendorError.UNSUPPORTED_COMMAND.getVendorCode(),
is(1998));
+ assertThat(StandardVendorError.UNSUPPORTED_COMMAND.getReason(),
is("Unsupported command: %s"));
}
@Test
public void assertUnknownException() {
-
assertThat(StandardSQLErrorCode.UNKNOWN_EXCEPTION.getSqlState().getValue(),
is("42000"));
- assertThat(StandardSQLErrorCode.UNKNOWN_EXCEPTION.getVendorCode(),
is(1999));
- assertThat(StandardSQLErrorCode.UNKNOWN_EXCEPTION.getReason(),
is("Unknown exception: %s"));
+
assertThat(StandardVendorError.UNKNOWN_EXCEPTION.getSqlState().getValue(),
is("42000"));
+ assertThat(StandardVendorError.UNKNOWN_EXCEPTION.getVendorCode(),
is(1999));
+ assertThat(StandardVendorError.UNKNOWN_EXCEPTION.getReason(),
is("Unknown exception: %s"));
}
}
diff --git
a/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/code/MySQLErrorCode.java
b/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/code/MyVendorError.java
similarity index 95%
rename from
shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/code/MySQLErrorCode.java
rename to
shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/code/MyVendorError.java
index 1f2d1624175..2b14b4309b5 100644
---
a/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/code/MySQLErrorCode.java
+++
b/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/code/MyVendorError.java
@@ -19,18 +19,18 @@ package org.apache.shardingsphere.error.mysql.code;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.error.code.SQLErrorCode;
+import org.apache.shardingsphere.error.vendor.VendorError;
import org.apache.shardingsphere.error.sqlstate.SQLState;
import org.apache.shardingsphere.error.sqlstate.XOpenSQLState;
/**
- * Server error code for MySQL.
+ * MySQL vendor error.
*
* @see <a
href="https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html">Server
Error Message Reference</a>
*/
@RequiredArgsConstructor
@Getter
-public enum MySQLErrorCode implements SQLErrorCode {
+public enum MyVendorError implements VendorError {
ER_DBACCESS_DENIED_ERROR(XOpenSQLState.SYNTAX_ERROR, 1044, "Access denied
for user '%s'@'%s' to database '%s'"),
diff --git
a/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/mapper/MySQLExceptionMapper.java
b/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/mapper/MySQLExceptionMapper.java
index 80a8c5ab713..3d642bf3a02 100644
---
a/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/mapper/MySQLExceptionMapper.java
+++
b/shardingsphere-error/shardingsphere-mysql-error/src/main/java/org/apache/shardingsphere/error/mysql/mapper/MySQLExceptionMapper.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.error.mysql.mapper;
-import org.apache.shardingsphere.error.code.SQLErrorCode;
-import org.apache.shardingsphere.error.code.StandardSQLErrorCode;
+import org.apache.shardingsphere.error.vendor.VendorError;
+import org.apache.shardingsphere.error.vendor.StandardVendorError;
import org.apache.shardingsphere.error.mapper.DialectSQLExceptionMapper;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
import
org.apache.shardingsphere.infra.exception.dialect.DBCreateExistsException;
import
org.apache.shardingsphere.infra.exception.dialect.DBDropNotExistsException;
import
org.apache.shardingsphere.infra.exception.dialect.InsertColumnsAndValuesMismatchedException;
@@ -42,39 +42,39 @@ public final class MySQLExceptionMapper implements
DialectSQLExceptionMapper {
@Override
public SQLException convert(final InsideDialectSQLException
dialectSQLException) {
if (dialectSQLException instanceof TableModifyInTransactionException) {
- return
toSQLException(MySQLErrorCode.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE,
((TableModifyInTransactionException) dialectSQLException).getTableName());
+ return
toSQLException(MyVendorError.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE,
((TableModifyInTransactionException) dialectSQLException).getTableName());
}
if (dialectSQLException instanceof
InsertColumnsAndValuesMismatchedException) {
- return toSQLException(MySQLErrorCode.ER_WRONG_VALUE_COUNT_ON_ROW,
((InsertColumnsAndValuesMismatchedException)
dialectSQLException).getMismatchedRowNumber());
+ return toSQLException(MyVendorError.ER_WRONG_VALUE_COUNT_ON_ROW,
((InsertColumnsAndValuesMismatchedException)
dialectSQLException).getMismatchedRowNumber());
}
if (dialectSQLException instanceof UnknownDatabaseException) {
return null != ((UnknownDatabaseException)
dialectSQLException).getDatabaseName()
- ? toSQLException(MySQLErrorCode.ER_BAD_DB_ERROR,
((UnknownDatabaseException) dialectSQLException).getDatabaseName())
- : toSQLException(MySQLErrorCode.ER_NO_DB_ERROR);
+ ? toSQLException(MyVendorError.ER_BAD_DB_ERROR,
((UnknownDatabaseException) dialectSQLException).getDatabaseName())
+ : toSQLException(MyVendorError.ER_NO_DB_ERROR);
}
if (dialectSQLException instanceof NoDatabaseSelectedException) {
- return toSQLException(MySQLErrorCode.ER_NO_DB_ERROR);
+ return toSQLException(MyVendorError.ER_NO_DB_ERROR);
}
if (dialectSQLException instanceof DBCreateExistsException) {
- return toSQLException(MySQLErrorCode.ER_DB_CREATE_EXISTS_ERROR,
((DBCreateExistsException) dialectSQLException).getDatabaseName());
+ return toSQLException(MyVendorError.ER_DB_CREATE_EXISTS_ERROR,
((DBCreateExistsException) dialectSQLException).getDatabaseName());
}
if (dialectSQLException instanceof DBDropNotExistsException) {
- return toSQLException(MySQLErrorCode.ER_DB_DROP_NOT_EXISTS_ERROR,
((DBDropNotExistsException) dialectSQLException).getDatabaseName());
+ return toSQLException(MyVendorError.ER_DB_DROP_NOT_EXISTS_ERROR,
((DBDropNotExistsException) dialectSQLException).getDatabaseName());
}
if (dialectSQLException instanceof TableExistsException) {
- return toSQLException(MySQLErrorCode.ER_TABLE_EXISTS_ERROR,
((TableExistsException) dialectSQLException).getTableName());
+ return toSQLException(MyVendorError.ER_TABLE_EXISTS_ERROR,
((TableExistsException) dialectSQLException).getTableName());
}
if (dialectSQLException instanceof NoSuchTableException) {
- return toSQLException(MySQLErrorCode.ER_NO_SUCH_TABLE,
((NoSuchTableException) dialectSQLException).getTableName());
+ return toSQLException(MyVendorError.ER_NO_SUCH_TABLE,
((NoSuchTableException) dialectSQLException).getTableName());
}
if (dialectSQLException instanceof TooManyConnectionsException) {
- return toSQLException(MySQLErrorCode.ER_CON_COUNT_ERROR);
+ return toSQLException(MyVendorError.ER_CON_COUNT_ERROR);
}
- return toSQLException(StandardSQLErrorCode.UNKNOWN_EXCEPTION,
dialectSQLException.getMessage());
+ return toSQLException(StandardVendorError.UNKNOWN_EXCEPTION,
dialectSQLException.getMessage());
}
- private SQLException toSQLException(final SQLErrorCode errorCode, final
Object... messageArguments) {
- return new SQLException(String.format(errorCode.getReason(),
messageArguments), errorCode.getSqlState().getValue(),
errorCode.getVendorCode());
+ private SQLException toSQLException(final VendorError vendorError, final
Object... messageArguments) {
+ return new SQLException(String.format(vendorError.getReason(),
messageArguments), vendorError.getSqlState().getValue(),
vendorError.getVendorCode());
}
@Override
diff --git
a/shardingsphere-error/shardingsphere-mysql-error/src/test/java/org/apache/shardingsphere/error/mysql/code/MySQLErrorCodeTest.java
b/shardingsphere-error/shardingsphere-mysql-error/src/test/java/org/apache/shardingsphere/error/mysql/code/MyVendorErrorTest.java
similarity index 58%
rename from
shardingsphere-error/shardingsphere-mysql-error/src/test/java/org/apache/shardingsphere/error/mysql/code/MySQLErrorCodeTest.java
rename to
shardingsphere-error/shardingsphere-mysql-error/src/test/java/org/apache/shardingsphere/error/mysql/code/MyVendorErrorTest.java
index 4949d671fe4..a5408a68d5f 100644
---
a/shardingsphere-error/shardingsphere-mysql-error/src/test/java/org/apache/shardingsphere/error/mysql/code/MySQLErrorCodeTest.java
+++
b/shardingsphere-error/shardingsphere-mysql-error/src/test/java/org/apache/shardingsphere/error/mysql/code/MyVendorErrorTest.java
@@ -22,27 +22,27 @@ import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class MySQLErrorCodeTest {
+public final class MyVendorErrorTest {
@Test
public void assertAccessDeniedError() {
- assertThat(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getVendorCode(),
is(1045));
-
assertThat(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getSqlState().getValue(),
is("28000"));
- assertThat(MySQLErrorCode.ER_ACCESS_DENIED_ERROR.getReason(),
is("Access denied for user '%s'@'%s' (using password: %s)"));
+ assertThat(MyVendorError.ER_ACCESS_DENIED_ERROR.getVendorCode(),
is(1045));
+
assertThat(MyVendorError.ER_ACCESS_DENIED_ERROR.getSqlState().getValue(),
is("28000"));
+ assertThat(MyVendorError.ER_ACCESS_DENIED_ERROR.getReason(),
is("Access denied for user '%s'@'%s' (using password: %s)"));
}
@Test
public void assertBadDbError() {
- assertThat(MySQLErrorCode.ER_BAD_DB_ERROR.getVendorCode(), is(1049));
- assertThat(MySQLErrorCode.ER_BAD_DB_ERROR.getSqlState().getValue(),
is("42000"));
- assertThat(MySQLErrorCode.ER_BAD_DB_ERROR.getReason(), is("Unknown
database '%s'"));
+ assertThat(MyVendorError.ER_BAD_DB_ERROR.getVendorCode(), is(1049));
+ assertThat(MyVendorError.ER_BAD_DB_ERROR.getSqlState().getValue(),
is("42000"));
+ assertThat(MyVendorError.ER_BAD_DB_ERROR.getReason(), is("Unknown
database '%s'"));
}
@Test
public void assertErrorOnModifyingGtidExecutedTable() {
-
assertThat(MySQLErrorCode.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE.getVendorCode(),
is(3176));
-
assertThat(MySQLErrorCode.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE.getSqlState().getValue(),
is("HY000"));
-
assertThat(MySQLErrorCode.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE.getReason(),
is("Please do not modify the %s table with an XA transaction. "
+
assertThat(MyVendorError.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE.getVendorCode(),
is(3176));
+
assertThat(MyVendorError.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE.getSqlState().getValue(),
is("HY000"));
+
assertThat(MyVendorError.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE.getReason(),
is("Please do not modify the %s table with an XA transaction. "
+ "This is an internal system table used to store GTIDs for
committed transactions. "
+ "Although modifying it can lead to an inconsistent GTID
state, if necessary you can modify it with a non-XA transaction."));
}
diff --git
a/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/code/PostgreSQLErrorCode.java
b/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/code/PostgreSQLVendorError.java
similarity index 96%
rename from
shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/code/PostgreSQLErrorCode.java
rename to
shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/code/PostgreSQLVendorError.java
index d427b892556..bf4c0492212 100644
---
a/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/code/PostgreSQLErrorCode.java
+++
b/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/code/PostgreSQLVendorError.java
@@ -21,13 +21,13 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
- * PostgreSQL error code.
+ * PostgreSQL vendor error.
*
* @see <a
href="https://www.postgresql.org/docs/12/errcodes-appendix.html">Appendix A.
PostgreSQL Error Codes</a>
*/
@RequiredArgsConstructor
@Getter
-public enum PostgreSQLErrorCode {
+public enum PostgreSQLVendorError {
SUCCESSFUL_COMPLETION("00000", "successful_completion"),
diff --git
a/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/mapper/PostgreSQLExceptionMapper.java
b/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/mapper/PostgreSQLExceptionMapper.java
index 16d3a81e68f..ef22c6e13d0 100644
---
a/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/mapper/PostgreSQLExceptionMapper.java
+++
b/shardingsphere-error/shardingsphere-postgresql-error/src/main/java/org/apache/shardingsphere/error/postgresql/mapper/PostgreSQLExceptionMapper.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.error.postgresql.mapper;
import org.apache.shardingsphere.error.mapper.DialectSQLExceptionMapper;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.infra.exception.dialect.DBCreateExistsException;
import
org.apache.shardingsphere.infra.exception.dialect.InTransactionException;
import
org.apache.shardingsphere.infra.exception.dialect.InsertColumnsAndValuesMismatchedException;
@@ -49,10 +49,10 @@ public final class PostgreSQLExceptionMapper implements
DialectSQLExceptionMappe
return new PSQLException(message,
PSQLState.INVALID_PARAMETER_VALUE);
}
if (dialectSQLException instanceof DBCreateExistsException) {
- return new
PSQLException(PostgreSQLErrorCode.DUPLICATE_DATABASE.getConditionName(), null);
+ return new
PSQLException(PostgreSQLVendorError.DUPLICATE_DATABASE.getConditionName(),
null);
}
if (dialectSQLException instanceof TooManyConnectionsException) {
- return new
PSQLException(PostgreSQLErrorCode.TOO_MANY_CONNECTIONS.getConditionName(),
null);
+ return new
PSQLException(PostgreSQLVendorError.TOO_MANY_CONNECTIONS.getConditionName(),
null);
}
return new PSQLException(dialectSQLException.getMessage(), null);
}
diff --git
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
index d2d390226e6..b4479bd9ed5 100644
---
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
+++
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
@@ -24,7 +24,7 @@ import io.netty.util.concurrent.Promise;
import org.apache.shardingsphere.data.pipeline.core.util.ReflectionUtil;
import org.apache.shardingsphere.data.pipeline.mysql.ingest.client.ServerInfo;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLAuthenticationMethod;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
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.mysql.packet.handshake.MySQLAuthPluginData;
@@ -96,7 +96,7 @@ public final class MySQLNegotiateHandlerTest {
@Test(expected = RuntimeException.class)
public void assertChannelReadErrorPacket() {
- MySQLErrPacket errorPacket = new MySQLErrPacket(0,
MySQLErrorCode.ER_NO_DB_ERROR);
+ MySQLErrPacket errorPacket = new MySQLErrPacket(0,
MyVendorError.ER_NO_DB_ERROR);
mysqlNegotiateHandler.channelRead(channelHandlerContext, errorPacket);
}
}
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/DistVendorError.java
similarity index 89%
rename from
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistSQLErrorCode.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/exception/DistVendorError.java
index 95f51c4e883..94cde638dfb 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/DistVendorError.java
@@ -19,16 +19,16 @@ package
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.excep
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.error.code.SQLErrorCode;
+import org.apache.shardingsphere.error.vendor.VendorError;
import org.apache.shardingsphere.error.sqlstate.SQLState;
import org.apache.shardingsphere.error.sqlstate.XOpenSQLState;
/**
- * Dist SQL error code.
+ * Dist SQL vendor error.
*/
@RequiredArgsConstructor
@Getter
-public enum DistSQLErrorCode implements SQLErrorCode {
+public enum DistVendorError implements VendorError {
UNSUPPORTED_VARIABLE(XOpenSQLState.GENERAL_ERROR, 11001, "Could not
support variable `%s`"),
@@ -46,7 +46,7 @@ public enum DistSQLErrorCode implements SQLErrorCode {
* @param distSQLException dist SQL exception
* @return dist SQL error code
*/
- public static DistSQLErrorCode valueOf(final DistSQLException
distSQLException) {
+ public static DistVendorError valueOf(final DistSQLException
distSQLException) {
if (distSQLException instanceof UnsupportedVariableException) {
return UNSUPPORTED_VARIABLE;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
index 43a3e31dd8f..1bcf05d6b29 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
@@ -24,7 +24,7 @@ import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLCapabilityFlag;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLCharacterSet;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConnectionPhase;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLStatusFlag;
import
org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.MySQLStatementIDGenerator;
import
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
@@ -82,7 +82,7 @@ public final class MySQLAuthenticationEngine implements
AuthenticationEngine {
} else if (MySQLConnectionPhase.AUTHENTICATION_METHOD_MISMATCH ==
connectionPhase) {
authenticationMethodMismatch((MySQLPacketPayload) payload);
}
- Optional<MySQLErrorCode> errorCode =
authenticationHandler.login(currentAuthResult.getUsername(),
getHostAddress(context), authResponse, currentAuthResult.getDatabase());
+ Optional<MyVendorError> errorCode =
authenticationHandler.login(currentAuthResult.getUsername(),
getHostAddress(context), authResponse, currentAuthResult.getDatabase());
context.writeAndFlush(errorCode.isPresent() ?
createErrorPacket(errorCode.get(), context) : new MySQLOKPacket(++sequenceId,
DEFAULT_STATUS_FLAG));
return
AuthenticationResultBuilder.finished(currentAuthResult.getUsername(),
getHostAddress(context), currentAuthResult.getDatabase());
}
@@ -95,7 +95,7 @@ public final class MySQLAuthenticationEngine implements
AuthenticationEngine {
context.channel().attr(CommonConstants.CHARSET_ATTRIBUTE_KEY).set(mySQLCharacterSet.getCharset());
context.channel().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).set(mySQLCharacterSet);
if (!Strings.isNullOrEmpty(packet.getDatabase()) &&
!ProxyContext.getInstance().databaseExists(packet.getDatabase())) {
- context.writeAndFlush(new MySQLErrPacket(++sequenceId,
MySQLErrorCode.ER_BAD_DB_ERROR, packet.getDatabase()));
+ context.writeAndFlush(new MySQLErrPacket(++sequenceId,
MyVendorError.ER_BAD_DB_ERROR, packet.getDatabase()));
return AuthenticationResultBuilder.continued();
}
MySQLAuthenticator authenticator =
authenticationHandler.getAuthenticator(packet.getUsername(),
getHostAddress(context));
@@ -117,10 +117,10 @@ public final class MySQLAuthenticationEngine implements
AuthenticationEngine {
authResponse = packet.getAuthPluginResponse();
}
- private MySQLErrPacket createErrorPacket(final MySQLErrorCode errorCode,
final ChannelHandlerContext context) {
- return MySQLErrorCode.ER_DBACCESS_DENIED_ERROR == errorCode
- ? new MySQLErrPacket(++sequenceId,
MySQLErrorCode.ER_DBACCESS_DENIED_ERROR, currentAuthResult.getUsername(),
getHostAddress(context), currentAuthResult.getDatabase())
- : new MySQLErrPacket(++sequenceId,
MySQLErrorCode.ER_ACCESS_DENIED_ERROR, currentAuthResult.getUsername(),
getHostAddress(context), getErrorMessage());
+ private MySQLErrPacket createErrorPacket(final MyVendorError vendorError,
final ChannelHandlerContext context) {
+ return MyVendorError.ER_DBACCESS_DENIED_ERROR == vendorError
+ ? new MySQLErrPacket(++sequenceId,
MyVendorError.ER_DBACCESS_DENIED_ERROR, currentAuthResult.getUsername(),
getHostAddress(context), currentAuthResult.getDatabase())
+ : new MySQLErrPacket(++sequenceId,
MyVendorError.ER_ACCESS_DENIED_ERROR, currentAuthResult.getUsername(),
getHostAddress(context), getErrorMessage());
}
private String getErrorMessage() {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
index 31c1ccacdeb..cf7450bf731 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.mysql.authentication;
import lombok.Getter;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
import
org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLAuthPluginData;
import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
@@ -48,14 +48,14 @@ public final class MySQLAuthenticationHandler {
* @param databaseName database name
* @return login success or failure
*/
- public Optional<MySQLErrorCode> login(final String username, final String
hostname, final byte[] authenticationResponse, final String databaseName) {
+ public Optional<MyVendorError> login(final String username, final String
hostname, final byte[] authenticationResponse, final String databaseName) {
Grantee grantee = new Grantee(username, hostname);
Collection<ShardingSphereRule> rules =
ProxyContext.getInstance().getRules(databaseName);
MySQLAuthenticator authenticator = getAuthenticator(username,
hostname);
if (!SQLCheckEngine.check(grantee, (a, b) ->
authenticator.authenticate((ShardingSphereUser) a, (byte[]) b),
authenticationResponse, rules)) {
- return Optional.of(MySQLErrorCode.ER_ACCESS_DENIED_ERROR);
+ return Optional.of(MyVendorError.ER_ACCESS_DENIED_ERROR);
}
- return null == databaseName || SQLCheckEngine.check(databaseName,
rules, grantee) ? Optional.empty() :
Optional.of(MySQLErrorCode.ER_DBACCESS_DENIED_ERROR);
+ return null == databaseName || SQLCheckEngine.check(databaseName,
rules, grantee) ? Optional.empty() :
Optional.of(MyVendorError.ER_DBACCESS_DENIED_ERROR);
}
/**
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
index aaafeb315cc..50fa0a167bc 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
@@ -23,10 +23,10 @@ import lombok.NoArgsConstructor;
import
org.apache.shardingsphere.data.pipeline.core.exception.PipelineJobNotFoundException;
import
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
import org.apache.shardingsphere.error.SQLExceptionHandler;
-import org.apache.shardingsphere.error.code.StandardSQLErrorCode;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.vendor.StandardVendorError;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
import
org.apache.shardingsphere.infra.util.exception.inside.ShardingSphereInsideException;
-import
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLErrorCode;
+import
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistVendorError;
import
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.exception.DistSQLException;
import
org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
@@ -48,7 +48,7 @@ public final class MySQLErrPacketFactory {
public static MySQLErrPacket newInstance(final Exception cause) {
if (cause instanceof SQLException) {
SQLException sqlException = (SQLException) cause;
- return null == sqlException.getSQLState() ? new MySQLErrPacket(1,
MySQLErrorCode.ER_INTERNAL_ERROR, getErrorMessage(sqlException))
+ return null == sqlException.getSQLState() ? new MySQLErrPacket(1,
MyVendorError.ER_INTERNAL_ERROR, getErrorMessage(sqlException))
: new MySQLErrPacket(1, sqlException.getErrorCode(),
sqlException.getSQLState(), sqlException.getMessage());
}
if (cause instanceof ShardingSphereInsideException) {
@@ -57,18 +57,18 @@ public final class MySQLErrPacketFactory {
}
if (cause instanceof DistSQLException) {
DistSQLException distSQLException = (DistSQLException) cause;
- return new MySQLErrPacket(1,
DistSQLErrorCode.valueOf(distSQLException), distSQLException.getVariable());
+ return new MySQLErrPacket(1,
DistVendorError.valueOf(distSQLException), distSQLException.getVariable());
}
if (cause instanceof UnsupportedPreparedStatementException) {
- return new MySQLErrPacket(1, MySQLErrorCode.ER_UNSUPPORTED_PS);
+ return new MySQLErrPacket(1, MyVendorError.ER_UNSUPPORTED_PS);
}
if (cause instanceof PipelineJobNotFoundException) {
- return new MySQLErrPacket(1,
StandardSQLErrorCode.SCALING_JOB_NOT_EXIST, ((PipelineJobNotFoundException)
cause).getJobId());
+ return new MySQLErrPacket(1,
StandardVendorError.SCALING_JOB_NOT_EXIST, ((PipelineJobNotFoundException)
cause).getJobId());
}
if (cause instanceof UnsupportedCharsetException) {
- return new MySQLErrPacket(1,
MySQLErrorCode.ER_UNKNOWN_CHARACTER_SET, cause.getMessage());
+ return new MySQLErrPacket(1,
MyVendorError.ER_UNKNOWN_CHARACTER_SET, cause.getMessage());
}
- return new MySQLErrPacket(1, StandardSQLErrorCode.UNKNOWN_EXCEPTION,
cause.getMessage());
+ return new MySQLErrPacket(1, StandardVendorError.UNKNOWN_EXCEPTION,
cause.getMessage());
}
private static String getErrorMessage(final SQLException cause) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngineTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngineTest.java
index 1920b82e5ed..a9a2c587aae 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngineTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngineTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.db.protocol.CommonConstants;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLCapabilityFlag;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConnectionPhase;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
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.mysql.packet.handshake.MySQLAuthPluginData;
@@ -135,7 +135,7 @@ public final class MySQLAuthenticationEngineTest extends
ProxyContextRestorer {
setConnectionPhase(MySQLConnectionPhase.AUTH_PHASE_FAST_PATH);
ChannelHandlerContext context = getContext();
setMetaDataContexts();
- when(authenticationHandler.login(anyString(), any(), any(),
anyString())).thenReturn(Optional.of(MySQLErrorCode.ER_ACCESS_DENIED_ERROR));
+ when(authenticationHandler.login(anyString(), any(), any(),
anyString())).thenReturn(Optional.of(MyVendorError.ER_ACCESS_DENIED_ERROR));
authenticationEngine.authenticate(context, getPayload("root",
"sharding_db", authResponse));
verify(context).writeAndFlush(any(MySQLErrPacket.class));
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
index 611d82a8075..2c65ebf7985 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandlerTest.java
@@ -24,7 +24,7 @@ import
org.apache.shardingsphere.authority.model.AuthorityRegistry;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.rule.builder.AuthorityRuleBuilder;
import
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLAuthenticationMethod;
-import org.apache.shardingsphere.error.mysql.code.MySQLErrorCode;
+import org.apache.shardingsphere.error.mysql.code.MyVendorError;
import
org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLAuthPluginData;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
@@ -92,14 +92,14 @@ public final class MySQLAuthenticationHandlerTest extends
ProxyContextRestorer {
public void assertLoginWithAbsentUser() {
initProxyContext(new ShardingSphereUser("root", "root", ""), true);
byte[] authResponse = {-27, 89, -20, -27, 65, -120, -64, -101, 86,
-100, -108, -100, 6, -125, -37, 117, 14, -43, 95, -113};
- assertThat(authenticationHandler.login("root1", "", authResponse,
"db1").orElse(null), is(MySQLErrorCode.ER_ACCESS_DENIED_ERROR));
+ assertThat(authenticationHandler.login("root1", "", authResponse,
"db1").orElse(null), is(MyVendorError.ER_ACCESS_DENIED_ERROR));
}
@Test
public void assertLoginWithIncorrectPassword() {
initProxyContext(new ShardingSphereUser("root", "root", ""), true);
byte[] authResponse = {0, 89, -20, -27, 65, -120, -64, -101, 86, -100,
-108, -100, 6, -125, -37, 117, 14, -43, 95, -113};
- assertThat(authenticationHandler.login("root", "", authResponse,
"db1").orElse(null), is(MySQLErrorCode.ER_ACCESS_DENIED_ERROR));
+ assertThat(authenticationHandler.login("root", "", authResponse,
"db1").orElse(null), is(MyVendorError.ER_ACCESS_DENIED_ERROR));
}
@Test
@@ -113,7 +113,7 @@ public final class MySQLAuthenticationHandlerTest extends
ProxyContextRestorer {
public void assertLoginWithUnauthorizedSchema() {
initProxyContext(new ShardingSphereUser("root", "root", ""), false);
byte[] authResponse = {-27, 89, -20, -27, 65, -120, -64, -101, 86,
-100, -108, -100, 6, -125, -37, 117, 14, -43, 95, -113};
- assertThat(authenticationHandler.login("root", "", authResponse,
"db11").orElse(null), is(MySQLErrorCode.ER_DBACCESS_DENIED_ERROR));
+ assertThat(authenticationHandler.login("root", "", authResponse,
"db11").orElse(null), is(MyVendorError.ER_DBACCESS_DENIED_ERROR));
}
@Test
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngine.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngine.java
index efa6dba206b..8a1cf27ca01 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngine.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngine.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.db.protocol.CommonConstants;
import
org.apache.shardingsphere.db.protocol.opengauss.packet.authentication.OpenGaussAuthenticationSCRAMSha256Packet;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
import
org.apache.shardingsphere.proxy.backend.handler.admin.postgresql.PostgreSQLCharacterSets;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLServerInfo;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationOKPacket;
@@ -117,8 +117,8 @@ public final class OpenGaussAuthenticationEngine implements
AuthenticationEngine
PostgreSQLPasswordMessagePacket passwordMessagePacket = new
PostgreSQLPasswordMessagePacket(payload);
PostgreSQLLoginResult loginResult =
OpenGaussAuthenticationHandler.loginWithSCRAMSha256Password(currentAuthResult.getUsername(),
currentAuthResult.getDatabase(),
saltHexString, nonceHexString, serverIteration,
passwordMessagePacket);
- if (PostgreSQLErrorCode.SUCCESSFUL_COMPLETION !=
loginResult.getErrorCode()) {
- throw new
PostgreSQLAuthenticationException(loginResult.getErrorCode(),
loginResult.getErrorMessage());
+ if (PostgreSQLVendorError.SUCCESSFUL_COMPLETION !=
loginResult.getVendorError()) {
+ throw new
PostgreSQLAuthenticationException(loginResult.getVendorError(),
loginResult.getErrorMessage());
}
context.write(new PostgreSQLAuthenticationOKPacket());
context.write(new PostgreSQLParameterStatusPacket("server_version",
PostgreSQLServerInfo.getServerVersion()));
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
index 9e76719fe7e..f6e40368546 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandler.java
@@ -21,7 +21,7 @@ import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLPasswordMessagePacket;
import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
@@ -75,17 +75,17 @@ public final class OpenGaussAuthenticationHandler {
String clientDigest = passwordMessagePacket.getDigest();
Grantee grantee = new Grantee(username, "%");
if (!Strings.isNullOrEmpty(databaseName) &&
!ProxyContext.getInstance().databaseExists(databaseName)) {
- return new
PostgreSQLLoginResult(PostgreSQLErrorCode.INVALID_CATALOG_NAME,
String.format("database \"%s\" does not exist", databaseName));
+ return new
PostgreSQLLoginResult(PostgreSQLVendorError.INVALID_CATALOG_NAME,
String.format("database \"%s\" does not exist", databaseName));
}
if (!SQLCheckEngine.check(grantee, getRules(databaseName))) {
- return new
PostgreSQLLoginResult(PostgreSQLErrorCode.INVALID_AUTHORIZATION_SPECIFICATION,
String.format("unknown username: %s", username));
+ return new
PostgreSQLLoginResult(PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION,
String.format("unknown username: %s", username));
}
if (!SQLCheckEngine.check(grantee, (a, b) ->
isPasswordRight((ShardingSphereUser) a, (Object[]) b), new
Object[]{clientDigest, salt, nonce, serverIteration}, getRules(databaseName))) {
- return new
PostgreSQLLoginResult(PostgreSQLErrorCode.INVALID_PASSWORD,
String.format("password authentication failed for user \"%s\"", username));
+ return new
PostgreSQLLoginResult(PostgreSQLVendorError.INVALID_PASSWORD,
String.format("password authentication failed for user \"%s\"", username));
}
return null == databaseName || SQLCheckEngine.check(databaseName,
getRules(databaseName), grantee)
- ? new
PostgreSQLLoginResult(PostgreSQLErrorCode.SUCCESSFUL_COMPLETION, null)
- : new
PostgreSQLLoginResult(PostgreSQLErrorCode.PRIVILEGE_NOT_GRANTED,
String.format("Access denied for user '%s' to database '%s'", username,
databaseName));
+ ? new
PostgreSQLLoginResult(PostgreSQLVendorError.SUCCESSFUL_COMPLETION, null)
+ : new
PostgreSQLLoginResult(PostgreSQLVendorError.PRIVILEGE_NOT_GRANTED,
String.format("Access denied for user '%s' to database '%s'", username,
databaseName));
}
private static Collection<ShardingSphereRule> getRules(final String
databaseName) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
index 02e7d354b67..25b60765701 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
@@ -24,7 +24,7 @@ import lombok.SneakyThrows;
import
org.apache.shardingsphere.db.protocol.opengauss.packet.command.generic.OpenGaussErrorResponsePacket;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import org.apache.shardingsphere.error.SQLExceptionHandler;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.infra.util.exception.inside.ShardingSphereInsideException;
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.InvalidAuthorizationSpecificationException;
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.PostgreSQLAuthenticationException;
@@ -79,15 +79,15 @@ public final class OpenGaussErrorPacketFactory {
return
createErrorResponsePacket(SQLExceptionHandler.convert("PostgreSQL",
(ShardingSphereInsideException) cause));
}
if (cause instanceof InvalidAuthorizationSpecificationException) {
- return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLErrorCode.INVALID_AUTHORIZATION_SPECIFICATION.getErrorCode(),
cause.getMessage());
+ return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION.getErrorCode(),
cause.getMessage());
}
if (cause instanceof PostgreSQLProtocolViolationException) {
- return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLErrorCode.PROTOCOL_VIOLATION.getErrorCode(),
+ return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLVendorError.PROTOCOL_VIOLATION.getErrorCode(),
String.format("expected %s response, got message type %s",
((PostgreSQLProtocolViolationException) cause).getExpectedMessageType(),
((PostgreSQLProtocolViolationException)
cause).getActualMessageType()));
}
if (cause instanceof PostgreSQLAuthenticationException) {
- return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL,
((PostgreSQLAuthenticationException) cause).getErrorCode().getErrorCode(),
cause.getMessage());
+ return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL,
((PostgreSQLAuthenticationException) cause).getVendorError().getErrorCode(),
cause.getMessage());
}
// TODO OpenGauss need consider FrontendConnectionLimitException
return createErrorResponsePacketForUnknownException(cause);
@@ -106,7 +106,7 @@ public final class OpenGaussErrorPacketFactory {
private static OpenGaussErrorResponsePacket
createErrorResponsePacket(final SQLException cause) {
// TODO consider what severity to use
- String sqlState = Strings.isNullOrEmpty(cause.getSQLState()) ?
PostgreSQLErrorCode.SYSTEM_ERROR.getErrorCode() : cause.getSQLState();
+ String sqlState = Strings.isNullOrEmpty(cause.getSQLState()) ?
PostgreSQLVendorError.SYSTEM_ERROR.getErrorCode() : cause.getSQLState();
String message = Strings.isNullOrEmpty(cause.getMessage()) ?
cause.toString() : cause.getMessage();
return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.ERROR, sqlState,
message);
}
@@ -118,6 +118,6 @@ public final class OpenGaussErrorPacketFactory {
private static OpenGaussErrorResponsePacket
createErrorResponsePacketForUnknownException(final Exception cause) {
// TODO add FIELD_TYPE_CODE for common error and consider what
severity to use
String message = Strings.isNullOrEmpty(cause.getLocalizedMessage()) ?
cause.toString() : cause.getLocalizedMessage();
- return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.SYSTEM_ERROR.getErrorCode(), message);
+ return new
OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLVendorError.SYSTEM_ERROR.getErrorCode(), message);
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
index f11facdeccb..cf835eb686f 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationHandlerTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.rule.builder.AuthorityRuleBuilder;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLPasswordMessagePacket;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
@@ -90,21 +90,21 @@ public final class OpenGaussAuthenticationHandlerTest
extends ProxyContextRestor
public void assertLoginWithPassword() {
initProxyContext(new ShardingSphereUser(username, password, "%"));
PostgreSQLLoginResult postgreSQLLoginResult =
OpenGaussAuthenticationHandler.loginWithSCRAMSha256Password(username, database,
random64Code, token, serverIteration, passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.SUCCESSFUL_COMPLETION));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.SUCCESSFUL_COMPLETION));
}
@Test
public void assertLoginWithAbsentUser() {
initProxyContext(new ShardingSphereUser("username", password, "%"));
PostgreSQLLoginResult postgreSQLLoginResult =
OpenGaussAuthenticationHandler.loginWithSCRAMSha256Password(username, database,
random64Code, token, serverIteration, passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_AUTHORIZATION_SPECIFICATION));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION));
}
@Test
public void assertLoginWithIncorrectPassword() {
initProxyContext(new ShardingSphereUser(username, "password", "%"));
PostgreSQLLoginResult postgreSQLLoginResult =
OpenGaussAuthenticationHandler.loginWithSCRAMSha256Password(username, database,
random64Code, token, serverIteration, passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_PASSWORD));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_PASSWORD));
}
@Test
@@ -112,7 +112,7 @@ public final class OpenGaussAuthenticationHandlerTest
extends ProxyContextRestor
initProxyContext(new ShardingSphereUser(username, password, "%"));
String database = "non_exist_database";
PostgreSQLLoginResult postgreSQLLoginResult =
OpenGaussAuthenticationHandler.loginWithSCRAMSha256Password(username, database,
random64Code, token, serverIteration, passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_CATALOG_NAME));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_CATALOG_NAME));
}
private void initProxyContext(final ShardingSphereUser user) {
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
index c3ddbeba891..5a206ce4035 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngine.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.db.protocol.CommonConstants;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLAuthenticationMethod;
import
org.apache.shardingsphere.proxy.backend.handler.admin.postgresql.PostgreSQLCharacterSets;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLServerInfo;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationOKPacket;
@@ -101,8 +101,8 @@ public final class PostgreSQLAuthenticationEngine
implements AuthenticationEngin
}
PostgreSQLPasswordMessagePacket passwordMessagePacket = new
PostgreSQLPasswordMessagePacket(payload);
PostgreSQLLoginResult loginResult =
authenticationHandler.login(currentAuthResult.getUsername(),
currentAuthResult.getDatabase(), md5Salt, passwordMessagePacket);
- if (PostgreSQLErrorCode.SUCCESSFUL_COMPLETION !=
loginResult.getErrorCode()) {
- throw new
PostgreSQLAuthenticationException(loginResult.getErrorCode(),
loginResult.getErrorMessage());
+ if (PostgreSQLVendorError.SUCCESSFUL_COMPLETION !=
loginResult.getVendorError()) {
+ throw new
PostgreSQLAuthenticationException(loginResult.getVendorError(),
loginResult.getErrorMessage());
}
// TODO implement PostgreSQLServerInfo like MySQLServerInfo
context.write(new PostgreSQLAuthenticationOKPacket());
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
index a62e1fd17ab..3402860c91d 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.postgresql.authentication;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLPasswordMessagePacket;
import org.apache.shardingsphere.infra.executor.check.SQLCheckEngine;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
@@ -49,18 +49,18 @@ public final class PostgreSQLAuthenticationHandler {
String digest = passwordMessagePacket.getDigest();
Grantee grantee = new Grantee(username, "%");
if (!Strings.isNullOrEmpty(databaseName) &&
!ProxyContext.getInstance().databaseExists(databaseName)) {
- return new
PostgreSQLLoginResult(PostgreSQLErrorCode.INVALID_CATALOG_NAME,
String.format("database \"%s\" does not exist", databaseName));
+ return new
PostgreSQLLoginResult(PostgreSQLVendorError.INVALID_CATALOG_NAME,
String.format("database \"%s\" does not exist", databaseName));
}
if (!SQLCheckEngine.check(grantee, getRules(databaseName))) {
- return new
PostgreSQLLoginResult(PostgreSQLErrorCode.INVALID_AUTHORIZATION_SPECIFICATION,
String.format("unknown username: %s", username));
+ return new
PostgreSQLLoginResult(PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION,
String.format("unknown username: %s", username));
}
PostgreSQLAuthenticator authenticator = getAuthenticator(username,
grantee.getHostname());
if (!SQLCheckEngine.check(grantee, (a, b) ->
authenticator.authenticate((ShardingSphereUser) a, (Object[]) b), new
Object[]{digest, md5Salt}, getRules(databaseName))) {
- return new
PostgreSQLLoginResult(PostgreSQLErrorCode.INVALID_PASSWORD,
String.format("password authentication failed for user \"%s\"", username));
+ return new
PostgreSQLLoginResult(PostgreSQLVendorError.INVALID_PASSWORD,
String.format("password authentication failed for user \"%s\"", username));
}
return null == databaseName || SQLCheckEngine.check(databaseName,
getRules(databaseName), grantee)
- ? new
PostgreSQLLoginResult(PostgreSQLErrorCode.SUCCESSFUL_COMPLETION, null)
- : new
PostgreSQLLoginResult(PostgreSQLErrorCode.PRIVILEGE_NOT_GRANTED,
String.format("Access denied for user '%s' to database '%s'", username,
databaseName));
+ ? new
PostgreSQLLoginResult(PostgreSQLVendorError.SUCCESSFUL_COMPLETION, null)
+ : new
PostgreSQLLoginResult(PostgreSQLVendorError.PRIVILEGE_NOT_GRANTED,
String.format("Access denied for user '%s' to database '%s'", username,
databaseName));
}
private Collection<ShardingSphereRule> getRules(final String databaseName)
{
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLLoginResult.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLLoginResult.java
index a209a741140..7e930be8732 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLLoginResult.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLLoginResult.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.authentication;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
/**
* PostgreSQL login result.
@@ -28,7 +28,7 @@ import
org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
@Getter
public final class PostgreSQLLoginResult {
- private final PostgreSQLErrorCode errorCode;
+ private final PostgreSQLVendorError vendorError;
private final String errorMessage;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/exception/PostgreSQLAuthenticationException.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/exception/PostgreSQLAuthenticationException.java
index fa2bb001371..49976fcc722 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/exception/PostgreSQLAuthenticationException.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/exception/PostgreSQLAuthenticationException.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.excep
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import org.apache.shardingsphere.proxy.frontend.exception.FrontendException;
/**
@@ -31,7 +31,7 @@ public final class PostgreSQLAuthenticationException extends
FrontendException {
private static final long serialVersionUID = 1331782847269278560L;
- private final PostgreSQLErrorCode errorCode;
+ private final PostgreSQLVendorError vendorError;
private final String message;
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutor.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutor.java
index 44cc7330ca0..eafedf78431 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutor.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutor.java
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.generic;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLErrorResponsePacket;
import
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
@@ -36,8 +36,8 @@ public final class PostgreSQLUnsupportedCommandExecutor
implements CommandExecut
@Override
public Collection<DatabasePacket<?>> execute() {
// TODO consider what severity and error code to use
- PostgreSQLErrorResponsePacket packet =
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.FEATURE_NOT_SUPPORTED,
-
PostgreSQLErrorCode.FEATURE_NOT_SUPPORTED.getConditionName()).build();
+ PostgreSQLErrorResponsePacket packet =
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLVendorError.FEATURE_NOT_SUPPORTED,
+
PostgreSQLVendorError.FEATURE_NOT_SUPPORTED.getConditionName()).build();
return Collections.singletonList(packet);
}
}
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 e5a240520fe..400835f13f2 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
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
@@ -164,7 +164,7 @@ public final class PostgreSQLComDescribeExecutor implements
CommandExecutor {
}
if (null == column) {
String reason = String.format("Column \"%s\" of relation
\"%s\" does not exist. Please check the SQL or execute REFRESH TABLE
METADATA.", columnName, logicTableName);
- throw new SQLException(reason,
PostgreSQLErrorCode.UNDEFINED_COLUMN.getErrorCode());
+ throw new SQLException(reason,
PostgreSQLVendorError.UNDEFINED_COLUMN.getErrorCode());
}
PostgreSQLColumnType parameterType =
PostgreSQLColumnType.valueOfJDBCType(column.getDataType());
preparedStatement.getParameterTypes().set(parameterMarkerIndex++,
parameterType);
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
index 8c9bf65d393..1439328e99a 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
@@ -23,7 +23,7 @@ import lombok.NoArgsConstructor;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLErrorResponsePacket;
import org.apache.shardingsphere.error.SQLExceptionHandler;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.infra.util.exception.inside.ShardingSphereInsideException;
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.InvalidAuthorizationSpecificationException;
import
org.apache.shardingsphere.proxy.frontend.postgresql.authentication.exception.PostgreSQLAuthenticationException;
@@ -56,16 +56,16 @@ public final class PostgreSQLErrPacketFactory {
return createErrorResponsePacket((SQLException) cause);
}
if (cause instanceof InvalidAuthorizationSpecificationException) {
- return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLErrorCode.INVALID_AUTHORIZATION_SPECIFICATION,
cause.getMessage()).build();
+ return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION,
cause.getMessage()).build();
}
if (cause instanceof PostgreSQLProtocolViolationException) {
- return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLErrorCode.PROTOCOL_VIOLATION,
+ return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
PostgreSQLVendorError.PROTOCOL_VIOLATION,
String.format("expected %s response, got message type %s",
((PostgreSQLProtocolViolationException) cause).getExpectedMessageType(),
((PostgreSQLProtocolViolationException)
cause).getActualMessageType()))
.build();
}
if (cause instanceof PostgreSQLAuthenticationException) {
- return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
((PostgreSQLAuthenticationException) cause).getErrorCode(),
cause.getMessage()).build();
+ return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL,
((PostgreSQLAuthenticationException) cause).getVendorError(),
cause.getMessage()).build();
}
// TODO PostgreSQL need consider FrontendConnectionLimitException
return createErrorResponsePacketForUnknownException(cause);
@@ -73,7 +73,7 @@ public final class PostgreSQLErrPacketFactory {
private static PostgreSQLErrorResponsePacket
createErrorResponsePacket(final SQLException cause) {
// TODO consider what severity to use
- String sqlState = Strings.isNullOrEmpty(cause.getSQLState()) ?
PostgreSQLErrorCode.SYSTEM_ERROR.getErrorCode() : cause.getSQLState();
+ String sqlState = Strings.isNullOrEmpty(cause.getSQLState()) ?
PostgreSQLVendorError.SYSTEM_ERROR.getErrorCode() : cause.getSQLState();
String message = Strings.isNullOrEmpty(cause.getMessage()) ?
cause.toString() : cause.getMessage();
return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
sqlState, message).build();
}
@@ -89,6 +89,6 @@ public final class PostgreSQLErrPacketFactory {
private static PostgreSQLErrorResponsePacket
createErrorResponsePacketForUnknownException(final Exception cause) {
// TODO add FIELD_TYPE_CODE for common error and consider what
severity to use
String message = Strings.isNullOrEmpty(cause.getLocalizedMessage()) ?
cause.toString() : cause.getLocalizedMessage();
- return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLErrorCode.SYSTEM_ERROR, message).build();
+ return
PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.ERROR,
PostgreSQLVendorError.SYSTEM_ERROR, message).build();
}
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
index e0be621d841..18d56d262ff 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandlerTest.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.authority.rule.builder.AuthorityRuleBuilder;
import
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLAuthenticationMethod;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLPasswordMessagePacket;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
@@ -89,28 +89,28 @@ public final class PostgreSQLAuthenticationHandlerTest
extends ProxyContextResto
public void assertLoginWithPassword() {
initProxyContext(new ShardingSphereUser(username, password, "%"));
PostgreSQLLoginResult postgreSQLLoginResult = new
PostgreSQLAuthenticationHandler().login(username, database,
md5Salt.getBytes(StandardCharsets.UTF_8), passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.SUCCESSFUL_COMPLETION));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.SUCCESSFUL_COMPLETION));
}
@Test
public void assertLoginWithAbsentUser() {
initProxyContext(new ShardingSphereUser("username", password, "%"));
PostgreSQLLoginResult postgreSQLLoginResult = new
PostgreSQLAuthenticationHandler().login(username, database,
md5Salt.getBytes(StandardCharsets.UTF_8), passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_AUTHORIZATION_SPECIFICATION));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_AUTHORIZATION_SPECIFICATION));
}
@Test
public void assertLoginWithIncorrectPassword() {
initProxyContext(new ShardingSphereUser(username, "password", "%"));
PostgreSQLLoginResult postgreSQLLoginResult = new
PostgreSQLAuthenticationHandler().login(username, database,
md5Salt.getBytes(StandardCharsets.UTF_8), passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_PASSWORD));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_PASSWORD));
}
@Test
public void assertLoginWithoutPassword() {
initProxyContext(new ShardingSphereUser(username, null, "%"));
PostgreSQLLoginResult postgreSQLLoginResult = new
PostgreSQLAuthenticationHandler().login(username, database,
md5Salt.getBytes(StandardCharsets.UTF_8), passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_PASSWORD));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_PASSWORD));
}
@Test
@@ -118,7 +118,7 @@ public final class PostgreSQLAuthenticationHandlerTest
extends ProxyContextResto
initProxyContext(new ShardingSphereUser(username, password, "%"));
String database = "non_exist_database";
PostgreSQLLoginResult postgreSQLLoginResult = new
PostgreSQLAuthenticationHandler().login(username, database,
md5Salt.getBytes(StandardCharsets.UTF_8), passwordMessagePacket);
- assertThat(postgreSQLLoginResult.getErrorCode(),
is(PostgreSQLErrorCode.INVALID_CATALOG_NAME));
+ assertThat(postgreSQLLoginResult.getVendorError(),
is(PostgreSQLVendorError.INVALID_CATALOG_NAME));
}
@Test
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 bb544c2073b..56fe434766e 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
@@ -19,7 +19,7 @@ package
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.extend
import lombok.SneakyThrows;
import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
-import org.apache.shardingsphere.error.postgresql.code.PostgreSQLErrorCode;
+import org.apache.shardingsphere.error.postgresql.code.PostgreSQLVendorError;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLColumnDescription;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLNoDataPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.PostgreSQLParameterDescriptionPacket;
@@ -233,7 +233,7 @@ public final class PostgreSQLComDescribeExecutorTest
extends ProxyContextRestore
} catch (final SQLException ex) {
actual = ex;
}
- assertThat(actual.getSQLState(),
is(PostgreSQLErrorCode.UNDEFINED_COLUMN.getErrorCode()));
+ assertThat(actual.getSQLState(),
is(PostgreSQLVendorError.UNDEFINED_COLUMN.getErrorCode()));
assertThat(actual.getMessage(), is("Column \"undefined_column\" of
relation \"t_order\" does not exist. Please check the SQL or execute REFRESH
TABLE METADATA."));
}