Guest User

Untitled

a guest
Feb 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select version();
  2.  PostgreSQL 8.4.6 on i386-apple-darwin, compiled by GCC i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5370), 32-bit
  3.  PostgreSQL 9.1.1 on x86_64-apple-darwin10.8.0, compiled by i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), 64-bit
  4.  
  5.  
  6. drop table if exists t2;
  7.  
  8.  
  9. create table t2 (
  10.  
  11.     a text not null,
  12.     b text null,
  13.    
  14.     constraint t2_pk primary key (a),
  15.    
  16.     constraint t2_t2_fk foreign key (b)
  17.        references t2 (a) match simple
  18.            on update cascade            --  !
  19.            on delete cascade
  20.                deferrable
  21.                initially deferred       --  !
  22. );
  23.  
  24. --Test data
  25. insert into t2
  26. values
  27.     ('asd', 'www'),
  28.     ('www', 'asd');
  29.    
  30. start transaction;
  31.     set constraints all immediate;  -- If not switched then everything is ok
  32. --    set constraints all deferred;
  33.  
  34.     update t2
  35.     set a = '123'
  36.     where a = 'asd';
  37.    
  38.     select * from t2;
  39.    
  40.     update t2
  41.     set a = 'kkk'
  42.     where a = '123'; --have a error here
  43.  
  44. commit;
Add Comment
Please, Sign In to add comment