Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules
Date: 2014-06-17 07:18:18
Message-ID: 20140617071818.GB9121@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jun 14, 2014 at 03:35:33PM -0400, Tom Lane wrote:
> The best that I think is reasonable to do in such cases is to pull out
> a separate copy of the sub-select for each actual NEW reference in a
> rule query. So the example above would give rise to an expanded
> rule query along the lines of
>
> INSERT INTO foolog VALUES ( (SELECT x as a, y as b, ...).a,
> (SELECT x as a, y as b, ...).b,
> ... );

Would it not be possible to use WITH here, like:

WITH bar AS ( ... subselect ... )
INSERT INTO foolog VALUES (bar.a, bar.b, ...)

Or am I missing something?

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
-- Arthur Schopenhauer

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2014-06-17 07:43:14 Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules
Previous Message Amit Kapila 2014-06-17 07:11:26 Re: Wait free LW_SHARED acquisition - v0.2