Re: insert/update/delete returning and rules

From: Jens-Wolfhard Schicke <j(dot)schicke(at)asco(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: insert/update/delete returning and rules
Date: 2006-08-16 07:48:37
Message-ID: 36B4DDEAF5A53F0D4C4F235F@[192.168.1.72]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

--On Dienstag, August 15, 2006 16:33:27 -0400 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
wrote:
> I'm tempted to suggest that the RETURNING commands might need to be
> separate rule events, and that to support this you'd need to write
> an additional rule:
>
> CREATE RULE r1 AS ON INSERT RETURNING TO myview DO INSTEAD
> INSERT ... RETURNING ...
> ...
>
> But even this seems like it would fail in complicated cases. What if
> the view is a join, and your ON INSERT rule inserts into two different
> underlying tables in two commands? If you need fields from both tables
> to generate a full RETURNING list then there's no apparent way to make
> it work.
>
> Ugh. Any ideas out there?
CREATE RULE r1 AS ON INSERT RETURNING TO myview DO INSTEAD
INSERT ... INTO tbl_1;
INSERT ... INTO tbl_2;
RETURNING SELECT .... FROM tbl_1, tbl_2 WHERE ...;

Just what crossed my mind first, no idea whether this is implementable or
realistic or whatever.

Mit freundlichem Gruß
Jens Schicke
--
Jens Schicke j(dot)schicke(at)asco(dot)de
asco GmbH http://www.asco.de
Mittelweg 7 Tel 0531/3906-127
38106 Braunschweig Fax 0531/3906-400

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefan Kaltenbrunner 2006-08-16 10:24:30 seahorse buildfarm issues
Previous Message andrew 2006-08-16 07:37:33 Re: Enum proposal / design