Re: Why no INSTEAD OF triggers on tables? - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: Why no INSTEAD OF triggers on tables?
Date
Msg-id 52B08D14.8080100@agliodbs.com
Whole thread Raw
In response to Why no INSTEAD OF triggers on tables?  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
On 12/16/2013 07:53 PM, Robert Haas wrote:
> So, put a BEFORE trigger, and make it return NULL.  Same effect,
> different notation.

NOT the same:

Master partition table with BEFORE trigger:

josh=# insert into a ( id, val ) values ( 23, 'test' ), ( 24, 'test'),
(25,'test');

INSERT 0 0       ^^^

View with INSTEAD OF trigger:

josh=# insert into a_v ( id, val ) values ( 23, 'test' ), ( 24, 'test'),
(25,'test');

INSERT 0 3       ^^^

The difference here is that the INSTEAD OF trigger returns a
rows-affected count, and the BEFORE trigger does not (it returns 0).
Some drivers and ORMs, most notably Hibernate, check this rows-returned
count, and error if they don't match the rows sent.

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Extension Templates S03E11
Next
From: Michael Weber
Date:
Subject: Re: patch: make_timestamp function