This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b21140df326 Add TableExistsException mapper for PostgreSQL (#25719)
b21140df326 is described below
commit b21140df326158b9a22ca8db489be83d6fa645d1
Author: ChenJiaHao <[email protected]>
AuthorDate: Wed May 17 13:23:36 2023 +0800
Add TableExistsException mapper for PostgreSQL (#25719)
---
.../dialect/postgresql/mapper/PostgreSQLDialectExceptionMapper.java | 4 ++++
.../shardingsphere/dialect/postgresql/sqlstate/PostgreSQLState.java | 2 ++
.../dialect/postgresql/vendor/PostgreSQLVendorError.java | 2 ++
3 files changed, 8 insertions(+)
diff --git
a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
index 3726869a2e9..98c9aec403f 100644
---
a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
+++
b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.dialect.exception.data.InsertColumnsAndValuesMi
import
org.apache.shardingsphere.dialect.exception.data.InvalidParameterValueException;
import
org.apache.shardingsphere.dialect.exception.syntax.database.DatabaseCreateExistsException;
import
org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
+import
org.apache.shardingsphere.dialect.exception.syntax.table.TableExistsException;
import
org.apache.shardingsphere.dialect.exception.transaction.InTransactionException;
import org.apache.shardingsphere.dialect.mapper.SQLDialectExceptionMapper;
import
org.apache.shardingsphere.dialect.postgresql.exception.PostgreSQLException;
@@ -55,6 +56,9 @@ public final class PostgreSQLDialectExceptionMapper
implements SQLDialectExcepti
if (sqlDialectException instanceof DatabaseCreateExistsException) {
return new PostgreSQLException(new
ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.DUPLICATE_DATABASE,
((DatabaseCreateExistsException) sqlDialectException).getDatabaseName()));
}
+ if (sqlDialectException instanceof TableExistsException) {
+ return new PostgreSQLException(new
ServerErrorMessage(ERROR_SEVERITY, PostgreSQLVendorError.DUPLICATE_TABLE,
((TableExistsException) sqlDialectException).getTableName()));
+ }
if (sqlDialectException instanceof InTransactionException) {
return new PostgreSQLException(new
ServerErrorMessage(ERROR_SEVERITY,
PostgreSQLVendorError.TRANSACTION_STATE_INVALID));
}
diff --git
a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/sqlstate/PostgreSQLState.java
b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/sqlstate/PostgreSQLState.java
index b9c967e5d06..bedcc448819 100644
---
a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/sqlstate/PostgreSQLState.java
+++
b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/sqlstate/PostgreSQLState.java
@@ -34,6 +34,8 @@ public enum PostgreSQLState implements SQLState {
DUPLICATE_DATABASE("42P04"),
+ DUPLICATE_TABLE("42P07"),
+
INVALID_PASSWORD("28P01"),
UNDEFINED_COLUMN("42703"),
diff --git
a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/vendor/PostgreSQLVendorError.java
b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/vendor/PostgreSQLVendorError.java
index c2f1f3332ac..134a9526241 100644
---
a/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/vendor/PostgreSQLVendorError.java
+++
b/dialect-exception/postgresql/src/main/java/org/apache/shardingsphere/dialect/postgresql/vendor/PostgreSQLVendorError.java
@@ -43,6 +43,8 @@ public enum PostgreSQLVendorError implements VendorError {
DUPLICATE_DATABASE(PostgreSQLState.DUPLICATE_DATABASE, "Database '%s'
already exists"),
+ DUPLICATE_TABLE(PostgreSQLState.DUPLICATE_TABLE, "Table '%s' already
exists"),
+
INVALID_AUTHORIZATION_SPECIFICATION(XOpenSQLState.INVALID_AUTHORIZATION_SPECIFICATION,
"unknown username: %s"),
NO_USERNAME(XOpenSQLState.INVALID_AUTHORIZATION_SPECIFICATION, "no
PostgreSQL user name specified in startup packet"),