Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-629

Incorrect SQL exception thrown when referential integrity

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 2.1.0
    • 2.1.2
    • batch
    • None
    • 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)

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            Roderick Radek Wikturna
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.