Re: COPY IN as SELECT target - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: COPY IN as SELECT target
Date
Msg-id 4B2A6912.1080509@enterprisedb.com
Whole thread Raw
In response to COPY IN as SELECT target  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: COPY IN as SELECT target  (Robert Haas <robertmhaas@gmail.com>)
Re: COPY IN as SELECT target  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Andrew Dunstan wrote:
> 
> Recently there was discussion about allowing a COPY statement to be a
> SELECT target, returning a text array, although the syntax wasn't really
> nailed down that I recall. I was thinking that  we might have
> 
>    COPY RETURNING ARRAY FROM ...
> 
> instead of
> 
>    COPY tablename opt_column_list FROM ...

It's not really returning an array, is it? It's returning a bag of rows
like a (sub)query.

> the we possibly could do things like:
> 
>    SELECT t[5] as a, 3*(t[3]::numeric) as b FROM (COPY RETURNING ARRAY
> FROM STDIN CSV) as t;

How about just COPY FROM? As in

SELECT t[5] as a, 3*(t[3]::numeric) as b FROM (COPY FROM STDIN CSV) as t

--  Heikki Linnakangas EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: determine snapshot after obtaining locks for first statement
Next
From: Robert Haas
Date:
Subject: Re: COPY IN as SELECT target