The following bug has been logged online:

Bug reference:      6268
Logged by:          Roman Lytovchenko
Email address:      [email protected]
PostgreSQL version: 9.1.1
Operating system:   Mac OS X 10.6.8
Description:        multiple update with on cascade
Details: 

create table t2 (

    a text not null,
    b text null,
    
    constraint t2_pk primary key (a),
    
    constraint t2_t2_fk foreign key (b)
       references t2 (a) match simple
           on update cascade            --  !
           on delete cascade
               deferrable 
               initially deferred       --  !
);

insert into t2 (a, b)
values
    ('www', 'www'),
    ('asd', 'asd');
    
    
--  run this transaction in another connection!
start transaction;
    set constraints all immediate;

    update t2
    set a = '123'
    where a = 'www';
    
    select
        a, b
    from t2;
    
    --  this update failed with
    --  ERROR: insert or update on table "t2" violates foreign key
constraint "t2_t2_fk"
    --  Detail: Key (b)=(123) is not present in table "t2".

    update t2
    set a = 'kkk'
    where a = '123';

commit;

-- 
Sent via pgsql-bugs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to