db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-5111) NullPointerException on unique constraint violation with unique index
Date Tue, 15 Mar 2011 14:43:29 GMT

    [ https://issues.apache.org/jira/browse/DERBY-5111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13006947#comment-13006947
] 

Knut Anders Hatlen commented on DERBY-5111:
-------------------------------------------

Another observation: If the primary key constraint is created before the unique index on the
same column, the NPE doesn't happen. But then there's a warning when the unique index is created:

ij> CREATE UNIQUE INDEX UI1 ON T1 (t1_id);
0 rows inserted/updated/deleted
WARNING 01504: The new index is a duplicate of an existing index: SQL110315145452330.

I think Derby doesn't create an index when it raises this warning.

CreateIndexConstantAction allows creation of duplicate indexes if the second index is a constraint,
but then it has one physical index and two logical indexes. I'm wondering if it's these logical
indexes that cause confusion in the case that fails with NPE.

> NullPointerException on unique constraint violation with unique index
> ---------------------------------------------------------------------
>
>                 Key: DERBY-5111
>                 URL: https://issues.apache.org/jira/browse/DERBY-5111
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.6.1.0, 10.6.2.1, 10.7.1.1
>            Reporter: Mark La Rue
>
> 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');

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message