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 50df28e6a96 Add duplicate entry error for MySQL (#35321)
50df28e6a96 is described below

commit 50df28e6a962cbf8981c3f6f8993cf0de2c070d4
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Sun May 4 21:46:05 2025 +0800

    Add duplicate entry error for MySQL (#35321)
    
    - Add new error code for duplicate entry in MySQL
    - Update existing parse error code to handle duplicate entry scenario
    - Add integrity constraint violation SQL state
---
 .../infra/exception/core/external/sql/sqlstate/XOpenSQLState.java     | 2 ++
 .../shardingsphere/infra/exception/mysql/vendor/MySQLVendorError.java | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/sqlstate/XOpenSQLState.java
 
b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/sqlstate/XOpenSQLState.java
index f23d1c3c2f6..05ad8598ee7 100644
--- 
a/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/sqlstate/XOpenSQLState.java
+++ 
b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/sqlstate/XOpenSQLState.java
@@ -47,6 +47,8 @@ public enum XOpenSQLState implements SQLState {
     
     INVALID_PARAMETER_VALUE("22023"),
     
+    INTEGRITY_CONSTRAINT_VIOLATION("23000"),
+    
     INVALID_TRANSACTION_STATE("25000"),
     
     INVALID_AUTHORIZATION_SPECIFICATION("28000"),
diff --git 
a/infra/exception/dialect/type/mysql/src/main/java/org/apache/shardingsphere/infra/exception/mysql/vendor/MySQLVendorError.java
 
b/infra/exception/dialect/type/mysql/src/main/java/org/apache/shardingsphere/infra/exception/mysql/vendor/MySQLVendorError.java
index 36538dae5ee..e8be69694ee 100644
--- 
a/infra/exception/dialect/type/mysql/src/main/java/org/apache/shardingsphere/infra/exception/mysql/vendor/MySQLVendorError.java
+++ 
b/infra/exception/dialect/type/mysql/src/main/java/org/apache/shardingsphere/infra/exception/mysql/vendor/MySQLVendorError.java
@@ -50,7 +50,9 @@ public enum MySQLVendorError implements VendorError {
     
     ER_TABLE_EXISTS_ERROR(XOpenSQLState.DUPLICATE, 1050, "Table '%s' already 
exists"),
     
-    ER_PARSE_ERROR(XOpenSQLState.SYNTAX_ERROR, 1064, "%s near '%s' at line 
%d"),
+    ER_DUP_ENTRY(XOpenSQLState.SYNTAX_ERROR, 1062, "%s near '%s' at line %d"),
+    
+    ER_PARSE_ERROR(XOpenSQLState.INTEGRITY_CONSTRAINT_VIOLATION, 1064, 
"Duplicate entry '%s' for key %d"),
     
     ER_UNKNOWN_CHARACTER_SET(XOpenSQLState.SYNTAX_ERROR, 1115, "Unknown 
character set: '%s'"),
     

Reply via email to