This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 47552e852fc Added No Table Exist Exception in 
PostgreSQLDialectExceptionMapper (#33885)
47552e852fc is described below

commit 47552e852fcc9a83f80f1f332b651ace852ea848
Author: Yash-cor <[email protected]>
AuthorDate: Tue Dec 3 18:25:44 2024 +0530

    Added No Table Exist Exception in PostgreSQLDialectExceptionMapper (#33885)
    
    * Added No Table Exist Exception in PostgressSQLDialectExceptionMapper
    
    * Made Spotless correction inside PostgreSQLVendorError
    
    * Changed occurence of No Such Table Exception in  
PostgreSQLDialectExceptionMapper
    
    * Corrected the Table Not Exist Error Code for Postgress
---
 .../postgresql/mapper/PostgreSQLDialectExceptionMapper.java      | 5 +++++
 .../infra/exception/postgresql/sqlstate/PostgreSQLState.java     | 9 +--------
 .../infra/exception/postgresql/vendor/PostgreSQLVendorError.java | 3 +--
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git 
a/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
 
b/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
index 38470611c64..a4287db32b8 100644
--- 
a/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
+++ 
b/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/mapper/PostgreSQLDialectExceptionMapper.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.infra.exception.dialect.exception.data.InsertCo
 import 
org.apache.shardingsphere.infra.exception.dialect.exception.data.InvalidParameterValueException;
 import 
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.DatabaseCreateExistsException;
 import 
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
+import 
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.table.NoSuchTableException;
 import 
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.table.TableExistsException;
 import 
org.apache.shardingsphere.infra.exception.dialect.exception.transaction.InTransactionException;
 import 
org.apache.shardingsphere.infra.exception.dialect.mapper.SQLDialectExceptionMapper;
@@ -56,6 +57,10 @@ 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 NoSuchTableException) {
+            NoSuchTableException cause = (NoSuchTableException) 
sqlDialectException;
+            return new PostgreSQLException(new 
ServerErrorMessage(FATAL_SEVERITY, PostgreSQLVendorError.NO_SUCH_TABLE, 
cause.getTableName()));
+        }
         if (sqlDialectException instanceof TableExistsException) {
             return new PostgreSQLException(new 
ServerErrorMessage(ERROR_SEVERITY, PostgreSQLVendorError.DUPLICATE_TABLE, 
((TableExistsException) sqlDialectException).getTableName()));
         }
diff --git 
a/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/sqlstate/PostgreSQLState.java
 
b/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/sqlstate/PostgreSQLState.java
index edc3c5aebbc..1f561817df0 100644
--- 
a/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/sqlstate/PostgreSQLState.java
+++ 
b/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/sqlstate/PostgreSQLState.java
@@ -29,20 +29,13 @@ import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.SQLS
 public enum PostgreSQLState implements SQLState {
     
     PROTOCOL_VIOLATION("08P01"),
-    
     SYNTAX_ERROR("42601"),
-    
     DUPLICATE_DATABASE("42P04"),
-    
     DUPLICATE_TABLE("42P07"),
-    
     INVALID_PASSWORD("28P01"),
-    
     UNDEFINED_COLUMN("42703"),
-    
+    UNDEFINED_TABLE("42P01"),
     SYSTEM_ERROR("58000"),
-    
     UNEXPECTED_ERROR("99999");
-    
     private final String value;
 }
diff --git 
a/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/vendor/PostgreSQLVendorError.java
 
b/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/vendor/PostgreSQLVendorError.java
index ae8ab5f23da..002bc453e31 100644
--- 
a/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/vendor/PostgreSQLVendorError.java
+++ 
b/infra/exception/dialect/type/postgresql/src/main/java/org/apache/shardingsphere/infra/exception/postgresql/vendor/PostgreSQLVendorError.java
@@ -48,9 +48,8 @@ public enum PostgreSQLVendorError implements VendorError {
     
INVALID_AUTHORIZATION_SPECIFICATION(XOpenSQLState.INVALID_AUTHORIZATION_SPECIFICATION,
 "unknown username: %s"),
     
     NO_USERNAME(XOpenSQLState.INVALID_AUTHORIZATION_SPECIFICATION, "no 
PostgreSQL user name specified in startup packet"),
-    
+    NO_SUCH_TABLE(PostgreSQLState.UNDEFINED_TABLE, "Table '%s' doesn't exist"),
     INVALID_PASSWORD(PostgreSQLState.INVALID_PASSWORD, "password 
authentication failed for user \"%s\""),
-    
     INVALID_CATALOG_NAME(XOpenSQLState.INVALID_CATALOG_NAME, "database \"%s\" 
does not exist"),
     
     UNDEFINED_COLUMN(PostgreSQLState.UNDEFINED_COLUMN, "Column \"%s\" of table 
\"%s\" does not exist"),

Reply via email to