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

* BUG #6531: integrity constraint failure
@ 2012-03-14 16:07  claudiomsi@hotmail.com
  0 siblings, 1 reply; 2+ messages in thread

From: claudiomsi@hotmail.com @ 2012-03-14 16:07 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6531
Logged by:          Claudio Oliveira
Email address:      claudiomsi@hotmail.com
PostgreSQL version: 9.1.3
Operating system:   windows 7
Description:        

Hello,

It would be a BUG.

Please run by separate blocks for the comment.

One to One Works.

By not blocks.

-----------------------------------------------------------------------

create table mestre (chave serial primary key, descricao varchar(50));

create table detalhe (chave serial primary key, 
                      mestre integer references mestre(chave) ON DELETE
CASCADE, 
                      valor numeric);

CREATE OR REPLACE FUNCTION ftrig_detalhe()
  RETURNS trigger AS
$BODY$
begin
 return null;
end;$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

---------------------------------------------------------------------
insert into mestre (chave, descricao) values (1, 'TESTE');
insert into detalhe (chave, mestre, valor) values (1, 1, 10);
select * from detalhe d left join mestre m on m.chave = d.mestre;
---------------------------------------------------------------------
delete from mestre where chave = 1;
select * from detalhe d left join mestre m on m.chave = d.mestre;
---------------------------------------------------------------------

CREATE TRIGGER tdetalhe
  before DELETE
  ON detalhe
  FOR EACH ROW
  EXECUTE PROCEDURE ftrig_detalhe();

---------------------------------------------------------------------
insert into mestre (chave, descricao) values (1, 'TESTE');
insert into detalhe (chave, mestre, valor) values (1, 1, 10);
select * from detalhe d left join mestre m on m.chave = d.mestre;
---------------------------------------------------------------------
delete from mestre where chave = 1;
select * from detalhe d left join mestre m on m.chave = d.mestre;
---------------------------------------------------------------------




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

* Re: BUG #6531: integrity constraint failure
@ 2012-03-14 16:20  Tom Lane <tgl@sss.pgh.pa.us>
  parent: claudiomsi@hotmail.com
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2012-03-14 16:20 UTC (permalink / raw)
  To: claudiomsi@hotmail.com; +Cc: pgsql-bugs

claudiomsi@hotmail.com writes:
> It would be a BUG.

No, this is not a bug.  If you create a trigger that disables deletions
on the referencing table, you should not be surprised that
foreign-key-related deletions don't happen.  Triggers do fire on FK
actions; it would be substantially less useful if they didn't.

			regards, tom lane



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


end of thread, other threads:[~2012-03-14 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-03-14 16:07 BUG #6531: integrity constraint failure claudiomsi@hotmail.com
2012-03-14 16:20 ` 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