|
This is author's slightly modified script; checked on 2.1.7, 2.5.9, 3.0.6, 4.0.0 - result the same. It will create PK and UNIQUE for table with fully duplicate rows.
set bail on; shell del c:\temp\tmp4test.fdb 2>nul; create database 'localhost:c:\temp\tmp4test.fdb'; show version; set autoddl off; -- [ !! ] commit; set echo on; recreate table test( a int not null, b int not null ); commit; insert into test(a, b) values (1,1); insert into test(a, b) values (1,2); commit; ------------------------------------------------------- update test set b = 1; alter table test add constraint test_unq unique (a); ------------------------------------------------------- commit; ------------------------------------------------------- update test set a = 1; alter table test add constraint test_pk primary key (b); ------------------------------------------------------- commit; show table test; show index test; select * from test; commit; |
FB should deny such situations since it seems that mixing both operations in the same transaction is not "safe". A better option, of course, would be to fix the problems, but I'm not sure if this is possible.