Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior regarding visibility of master record on detail inserts [CORE6138] #6387

Closed
firebird-automations opened this issue Sep 7, 2019 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @WarmBooter

Votes: 3

During a master-detail insert using two different transactions, where the detail transaction is snapshot, FB allows the detail insert even when the master record is not visible for the detail transaction. It can be easily reproduced with the following steps:

Open two isql sessions (isql1 and isql2) connected to the same database, and follow the sequence of commands in this order:

isql1:
CREATE TABLE A
(
ID BIGINT NOT null PRIMARY KEY);

CREATE TABLE B
(
ID BIGINT NOT null PRIMARY KEY,
ID_A BIGINT NOT NULL
);

ALTER TABLE B ADD constraint FK_B__A FOREIGN KEY(ID_A) REFERENCES A(ID) ON UPDATE CASCADE ON DELETE CASCADE;

commit;
INSERT INTO A (ID) VALUES (1);

isql2:
commit; -- to be sure that if there is active transaction, it will be ended now
select * from a; -- just to be sure that snapshot transaction is started now

isql1:
commit;

isql2:
INSERT INTO B (ID, ID_A) VALUES (1, 1); -- This SHOULD break, since master is not visible for this transaction, but FB will accept it
-- Any trigger based action against the master record will have null effect, but the detail insert will not fail!
commit;

PS: For people with business rules on triggers, this behavior may lead to wrong results.

Commits: 4a322b3 7e70c01

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

Confirmed on WI-V3.0.5.33168, WI-T4.0.0.1598.

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 3.0.5 [ 10885 ]

Fix Version: 4.0 Beta 2 [ 10888 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment