Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules
Date
Msg-id 20140617071818.GB9121@svana.org
Whole thread Raw
In response to UPDATE SET (a,b,c) = (SELECT ...) versus rules  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@svana.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

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Wait free LW_SHARED acquisition - v0.2
Next
From: Hannu Krosing
Date:
Subject: Re: UPDATE SET (a,b,c) = (SELECT ...) versus rules