Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
10.0.2.1
-
None
-
Normal
-
Repro attached
-
Embedded/Client difference
Description
When running embedded Derby in autocommit true mode(default), a foreign key violation closes the open cursors. But the cursors remain open after the foreign key violation when Derby is running in Network Server. Following code can be tried in ij for embedded and network server to see the behavior difference.
create table tableWithPrimaryKey (c1 int not null, c2 int not null, constraint pk primary key(c1,c2));
create table tableWithConstraint (c1 int, c2 int, constraint fk foreign key(c1,c2) references tableWithPrimaryKey);
create table t1 (c11 int, c12 int);
insert into t1 values (1,1), (2,2), (3,3);
insert into tableWithPrimaryKey values (1, 1), (2, 2), (3, 3), (4, 4);
insert into tableWithConstraint values (1, 1), (2, 2), (3, 3), (4, 4);
get cursor c1 as 'select * from t1';
next c1;
– In both embedded and Network server modes, delete below will throw exception "ERROR 23503: DELETE on
– table 'TABLEWITHPRIMARYKEY' caused a violation of foreign key constraint 'FK' for key (1,1).
– The statement has been rolled back."
delete from tableWithPrimaryKey;
– In embedded mode, next on cursor below throws exception "ERROR XCL16: ResultSet not open, operation 'next' not
– permitted. Verify that autocommit is OFF." But in Network Server mode, the cursor is still open and
– next c1 spits out contents of next row.
next c1;
Attachments
Issue Links
- is duplicated by
-
DERBY-3436 Embedded closes all open ResultSets on failure in auto-commit mode, whereas client keeps them open
- Closed
- is part of
-
DERBY-310 Document and/or change Derby client code to match behavior with Embedded driver where possible.
- Closed
- relates to
-
DERBY-3422 Embedded returns wrong value for DatabaseMetaData.autoCommitFailureClosesAllResultSets()
- Closed