Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-5111

NullPointerException on unique constraint violation with unique index

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.1.0, 10.6.2.1, 10.7.1.1, 10.11.1.1
    • 10.10.2.1, 10.11.1.1
    • SQL
    • Normal
    • High Value Fix, Repro attached
    • Crash, Seen in production

    Description

      Given the below DDL, violations of the unique constraint (an example follows the DDL) specified on table t1 will result in a NullPointerException that terminates the active connection. The root cause appears to be related to the unique indexes; removing them results in the correct constraint violation.

      CREATE TABLE s.t0 (t0_id INTEGER NOT NULL, value VARCHAR(75) NOT NULL);
      ALTER TABLE s.t0 ADD CONSTRAINT pk_1 PRIMARY KEY (t0_id);

      CREATE TABLE s.t1 (t1_id INTEGER NOT NULL, t0_id INTEGER NOT NULL, value VARCHAR(75) NOT NULL);
      CREATE UNIQUE INDEX s.ui_1 ON s.t1 (t1_id);

      ALTER TABLE s.t1 ADD CONSTRAINT pk_2 PRIMARY KEY (t1_id);
      ALTER TABLE s.t1 ADD CONSTRAINT fk_1 FOREIGN KEY (t0_id) REFERENCES s.t0 (t0_id) ON DELETE CASCADE;
      CREATE UNIQUE INDEX s.ui_2 ON s.t1 (t0_id, value);
      ALTER TABLE s.t1 ADD CONSTRAINT uc_1 UNIQUE (t0_id, value);

      Minimal DML to trigger the constraint violation:

      INSERT INTO s.t0 VALUES (0, 'foobar');
      INSERT INTO s.t1 VALUES(0, 0, 'Test');
      INSERT INTO s.t1 VALUES(1, 0, 'Test');

      Attachments

        1. derby-5111.diff
          0.7 kB
          Dag H. Wanvik
        2. derby-5111-test.diff
          2 kB
          Dag H. Wanvik

        Issue Links

          Activity

            People

              dagw Dag H. Wanvik
              mlarue Mark La Rue
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: