pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #8227: referential integrity problem
2+ messages / 2 participants
[nested] [flat]

* BUG #8227: referential integrity problem
@ 2013-06-12 20:08  greg@antrez.pl
  0 siblings, 1 reply; 2+ messages in thread

From: greg@antrez.pl @ 2013-06-12 20:08 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      8227
Logged by:          Greg Brzezinski
Email address:      greg@antrez.pl
PostgreSQL version: 9.2.4
Operating system:   linux
Description:        

postgres=# CREATE TABLE test( id int primary key, name text );
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey"
for table "test"
CREATE TABLE
postgres=# CREATE TABLE test_item( id int primary key, test_id int
references test(id)  match full on update cascade on delete cascade, content
text );
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"test_item_pkey" for table "test_item"
CREATE TABLE
postgres=# CREATE OR REPLACE FUNCTION test_item_delete_lock() returns
trigger AS $f$
postgres$# begin
postgres$#     return null;
postgres$# end;
postgres$# $f$ language plpgsql;
CREATE FUNCTION
postgres=# CREATE TRIGGER test_item_delete_lock BEFORE DELETE ON test_item
FOR EACH ROW EXECUTE PROCEDURE test_item_delete_lock();
CREATE TRIGGER
postgres=#
postgres=# insert into test values (1, 'one');
INSERT 0 1
postgres=# insert into test_item values (1, 1, 'for one');
INSERT 0 1
postgres=# delete from test where id = 1;
DELETE 1
postgres=# select * from test_item;
 id | test_id | content
----+---------+---------
  1 |       1 | for one
(1 row)

postgres=# select * from test;
 id | name
----+------
(0 rows)


Is it ok that we loose referential integrity by locking DELETE on table
test_item ?



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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #8227: referential integrity problem
@ 2013-06-12 21:36  Tom Lane <tgl@sss.pgh.pa.us>
  parent: greg@antrez.pl
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2013-06-12 21:36 UTC (permalink / raw)
  To: greg@antrez.pl; +Cc: pgsql-bugs

greg@antrez.pl writes:
> Is it ok that we loose referential integrity by locking DELETE on table
> test_item ?

Yes.  If you put a trigger on a table involved in an FK constraint, it's
your responsibility that the trigger doesn't break FK update operations.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2013-06-12 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-06-12 20:08 BUG #8227: referential integrity problem greg@antrez.pl
2013-06-12 21:36 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox