Re: RETURNING and DO INSTEAD ... Intentional or not?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RETURNING and DO INSTEAD ... Intentional or not?
Date: 2007-09-12 17:39:24
Message-ID: 24374.1189618764@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> A Hibernate developer pointed out the following odd behavior to me in 8.2.1:

> create table test ( test1 text );
> create table test2 ( test_col text );
> create rule test_insert as on insert to test do instead insert into test2
> values ( NEW.test1 ) RETURNING test2.test_col;

> postgres=# insert into test values ( 'joe' );
> INSERT 0 1

> ... no RETURNING.

It would surely be quite broken for an INSERT that has *not* got a
returning clause to spit data at you, don't you think?

What the RETURNING clause in the rule does is let you define the data
that should be returned if the rewritten INSERT had a returning clause
to start with.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2007-09-12 17:58:01 Re: RETURNING and DO INSTEAD ... Intentional or not?
Previous Message Joshua D. Drake 2007-09-12 16:52:49 Re: RETURNING and DO INSTEAD ... Intentional or not?