Title: Re: ODP: [Firebird-devel] Inserts and FKs
tx1 starts (read commited)
tx1 INSERT INTO A (ID) VALUES (1);
tx2 starts (snapshot isolation) - How did you started tx2? If you are in isql, you need at last to run some statement, like a select, to actually start a transaction. For example, run this on the second isql section:
commit; -- making sure that if there is a transaction started, it will be closed now
select * from a; -- Doing this you are actually starting a transaction (tx2)
tx1 commits
tx2 INSERT INTO B (ID, ID_A) VALUES (1, 1);
tx2 commits – i have an error here! violation of FOREIGN KEY constraint "FK_B__A" on table "B" Foreign key reference target does not exist Problematic key value is ("ID_A" = 1)
or transaction wait if i specifi wait for locks.

I tested your steps (following my comments above) and get no error (FB 2.5).

[]s
Carlos
http://www.firebirdnews.org
FireBase - http://www.FireBase.com.br


I have tested this and i got an error all the time or i get waiting for lock depending on transaction settings.
I do the following:
 
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;
 
tx1 starts (read commited)
tx1 INSERT INTO A (ID) VALUES (1);
tx2 starts (snapshot isolation)
tx1 commits
tx2 INSERT INTO B (ID, ID_A) VALUES (1, 1);
tx2 commits – i have an error here! violation of FOREIGN KEY constraint "FK_B__A" on table "B" Foreign key reference target does not exist Problematic key value is ("ID_A" = 1)
or transaction wait if i specifi wait for locks.
 
I have also create empty triggers but no change
I suppose you do someting different. Please describe exact steeps to reproduce this.
 
Regards,
Karol Bieniaszewski
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to