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

From Dimitri Fontaine
Subject Re: COPY IN as SELECT target
Date
Msg-id 5722892F-DBA6-4E5C-8844-C83E45375A94@hi-media.com
Whole thread Raw
In response to Re: COPY IN as SELECT target  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
Hi,

Le 17 déc. 2009 à 19:39, Josh Berkus a écrit :
> Mind you, returning (arbitrary expression) would be even better, but if
> we can get returning TEXT[] for 8.5, I think it's worth doing on its own.

Well, you already have it as soon as you have text[]:
INSERT INTO destinationSELECT row[0], row[1], myfunction(row[0], row[1]), row[2]::int + 1  FROM (COPY RETURNING text[]
FROM'/path/to/file.cvs' CVS HEADER) as file(row); 

Of course as Andrew said already what it needs that the syntax here does not cover is ragged file processing, that is
acceptingfile content when all the rows will not have the same number of columns. 

But if you have ragged input reading and COPY as a relation in a query, then you're able to apply any expression you
wantto in the query itself. Such as transforming the input slightly in order to conform to PostgreSQL datatype input
syntaxes,e.g. 

Regards,
--
dim

Let's deprecate pgloader.

pgsql-hackers by date:

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