· 8 years ago · Feb 19, 2018, 11:14 AM
1select 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
6drop table if exists t2;
7
8
9create 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
25insert into t2
26values
27 ('www', 'www'),
28 ('asd', 'asd');
29
30start 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
44commit;