Re: Why no INSTEAD OF triggers on tables?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why no INSTEAD OF triggers on tables?
Date: 2013-12-17 17:42:44
Message-ID: 52B08D14.8080100@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Weber 2013-12-17 17:46:57 Re: patch: make_timestamp function
Previous Message Stephen Frost 2013-12-17 17:40:59 Re: Extension Templates S03E11