pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
"on insert" rules happen before the insert?
2+ messages / 2 participants
[nested] [flat]

* "on insert" rules happen before the insert?
@ 2003-12-30 21:49  Thomas Reat <treat00@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: treat00@yahoo.com @ 2003-12-30 21:49 UTC (permalink / raw)
  To: pgsql-sql

The postgresql documentation claims that "on insert" rules are executed
after the insert. This is not happening for me. I have a rule that is being
executed even though the insert should have failed due to a foreign key check.

The rule does an insert that is failing, and the whole insert fails. So in 
this case it's not a huge problem. But I get a completely useless error 
message, and as far as I can tell there is no way to determine exactly what
caused the failure (except for the fact that I happen to know what rule
can cause that error). 

I'd like the person inserting a row that violates the foreign key check to
get a useful error message.

Is this a documentation bug? How can I get the desired behavior?



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

* Re: "on insert" rules happen before the insert?
@ 2004-01-05 05:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas Reat <treat00@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2004-01-05 05:26 UTC (permalink / raw)
  To: treat00@yahoo.com; +Cc: pgsql-sql

treat00@yahoo.com (Thomas Reat) writes:
> The postgresql documentation claims that "on insert" rules are executed
> after the insert. This is not happening for me. I have a rule that is being
> executed even though the insert should have failed due to a foreign key check.

The INSERT certainly happens before any rules that it triggers.  But
foreign key checks probably don't happen until all the dust has settled.
This is arguably not a bug --- there are situations where it's essential.

			regards, tom lane



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


end of thread, other threads:[~2004-01-05 05:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-12-30 21:49 "on insert" rules happen before the insert? Thomas Reat <treat00@yahoo.com>
2004-01-05 05:26 ` 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