[CONJ-629] Incorrect SQL exception thrown when referential integrity Created: 2018-07-31  Updated: 2018-08-22  Resolved: 2018-08-22

Status: Closed
Project: MariaDB Connector/J
Component/s: batch
Affects Version/s: 2.1.0
Fix Version/s: 2.1.2

Type: Bug Priority: Minor
Reporter: Radek Wikturna Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Java 8, Windows 10, MariaDB 10.2.13



 Description   

After executing a DELETE statement on a row which cannot be deleted due to violation of a referential contraint, an SQL exception is thrown as expected. The exception is:
java.sql.SQLIntegrityConstraintViolationException: (conn:1569) Cannot delete or update a parent row: a foreign key constraint fails (`VM_51_TEST`.`AMA_SYSTYPEUSAGE_SYSTYPE`, CONSTRAINT `F_SYSTPUSGSTP_STP` FOREIGN KEY (`SYSTYPE_ID`) REFERENCES `AMA_SYSTYPE` (`SYSTYPE_ID`))

However, when the same DELETE statement is executed as a batch (PreparedStatement.executeBatch()), then an incorrect exception is thrown:
java.sql.BatchUpdateException: Error reading results Index: 1, Size: 1

calling getCause() returns: java.sql.SQLException: Error reading results Index: 1, Size: 1
(expected result of getCause() is SQLIntegrityConstraintViolationException as in non-batch mode)

Details on the BatchUpdateException :
vendor code: 0
updateCounts: [-3,-3]
(everything else is null or empty)



 Comments   
Comment by Diego Dupin [ 2018-08-22 ]

this has been corrected since in 2.1.2.
so closing issue

Generated at Thu Feb 08 03:17:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.