Fix MySQLStatementCancelledException created with null SQLState#126
Open
gastaldi wants to merge 1 commit into
Open
Fix MySQLStatementCancelledException created with null SQLState#126gastaldi wants to merge 1 commit into
gastaldi wants to merge 1 commit into
Conversation
SQLExceptionsMapping.translateException() was using the single-arg constructors for MySQLStatementCancelledException and MySQLTimeoutException, which do not set the SQLState. This caused frameworks like Spring JDBC that rely on getSQLState() for exception classification to produce UncategorizedSQLException instead of properly categorized exceptions. Also set the default SQLState in OperationCancelledException to "70100" (SQLSTATE_MYSQL_QUERY_INTERRUPTED), matching MySQL's ER_QUERY_INTERRUPTED error mapping. Fixes: mysql#125
This was referenced Jun 9, 2026
|
Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SQLExceptionsMapping.translateException()used single-arg constructors forMySQLStatementCancelledExceptionandMySQLTimeoutException, dropping the SQLState and vendorCode from the underlyingCJExceptionOperationCancelledExceptioninherited the generic "S1000" default fromCJExceptioninstead of setting "70100" (SQLSTATE_MYSQL_QUERY_INTERRUPTED)This caused
MySQLStatementCancelledException.getSQLState()to returnnull, breaking frameworks like Spring JDBC that rely on SQLState for exception classification (producingUncategorizedSQLExceptioninstead of properly categorized exceptions).Changes
OperationCancelledException: set default SQLState toMysqlErrorNumbers.SQLSTATE_MYSQL_QUERY_INTERRUPTED("70100") in all constructorsSQLExceptionsMapping.translateException(): propagate SQLState and vendorCode when creatingMySQLStatementCancelledExceptionandMySQLTimeoutExceptionTest plan
MySQLStatementCancelledException.getSQLState()returns "70100" afterStatement.cancel()interrupts a running queryMySQLTimeoutException.getSQLState()is not null after a query timeoutFixes: #125