[
https://issues.apache.org/jira/browse/DERBY-6665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14068485#comment-14068485
]
Dyre Tjeldvoll commented on DERBY-6665:
---------------------------------------
I tried simply returning false if the there was no {{ConstraintDescriptor}} for
the UUID being passed in, cf. comment in the braindump patch, but that did not
work. Running in the debugger shows that
{{SQLSessionContextImpl.checkConstraintModes}} is null in the call to
{{isDeferred(UUID constraintId)}}, meaning that {{setDeferred}} cannot have
been called for this (or any other) UUID. Inspecting the call hierarchy for
{{setDeferred}} reveals that it is only called from
{{SetConstraintsConstantAction.executeConstantAction}}.
In the failing test case there are no explicit SET DEFERRED call, but the table
is created with "...constraint ct primary key(i) deferrable initially
deferred". I'm a bit unsure about how the constraint specifications embedded in
the CREATE TABLE statement are handled - should the CreateTableConstantAction
have handled it, or should it somehow "link" to a
SetConstraintConstantAction...?
> Violation of deferred constraints not detected when conglomerates are shared
> ----------------------------------------------------------------------------
>
> Key: DERBY-6665
> URL: https://issues.apache.org/jira/browse/DERBY-6665
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.11.0.0
> Reporter: Knut Anders Hatlen
> Attachments: braindump.diff, junit.diff
>
>
> See the following script:
> {noformat}
> ij version 10.11
> ij> connect 'jdbc:derby:memory:db;create=true';
> ij> create table t1(x int primary key);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int primary key);
> 0 rows inserted/updated/deleted
> ij> create table t3(x int, constraint fk1 foreign key (x) references t1
> initially deferred, constraint fk2 foreign key (x) references t2 initially
> deferred);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1;
> 1 row inserted/updated/deleted
> ij> autocommit off;
> ij> insert into t3 values 1;
> 1 row inserted/updated/deleted
> ij> insert into t2 values 1;
> 1 row inserted/updated/deleted
> ij> delete from t1;
> 1 row inserted/updated/deleted
> ij> commit;
> ij> select * from t1;
> X
> -----------
> 0 rows selected
> ij> select * from t2;
> X
> -----------
> 1
> 1 row selected
> ij> select * from t3;
> X
> -----------
> 1
> 1 row selected
> {noformat}
> Since T3.X contains a value (1) that is not present in T1, the foreign key
> FK1 is violated, and the COMMIT statement should have failed.
--
This message was sent by Atlassian JIRA
(v6.2#6252)