Re: COPY Transform support - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: COPY Transform support
Date
Msg-id 200804080959.13877.dfontaine@hi-media.com
Whole thread Raw
In response to Re: COPY Transform support  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: COPY Transform support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Le mardi 08 avril 2008, Tom Lane a écrit :
> Dimitri Fontaine <dfontaine@hi-media.com> writes:
> > And my main concern would still be left as-is, COPY wouldn't have any
> > facility to cope with data representation not matching what datatype
> > input functions want to read.
>
> That's sufficiently covered by the proposal to allow a COPY FROM as a
> table source within SELECT, no?

Well, yes, the table source has text as datatypes and the select expression on
the column will call whatever function/cast etc to do the work. But that
opens the door to second class citizen storage solution for PostgreSQL, by
letting the user CREATE VIEW atop of it:
 CREATE VIEW csv_storage AS   SELECT a, myfunc(b)::timestamp, c::int+3     FROM (COPY ... FROM '/tmp/file.csv' ...) AS
x(a,b, c)    WHERE c ~ '^[0-9]+$'; 

What happens to the view when /tmp/file.csv is changed (new lines appended, or
complete rewrite by another application, etc)?

Andrew comment is clear about it: he does not want PostgreSQL to offer this
kind of support. I suppose it would be possible to stop CREATE VIEW to accept
any form of SELECT, but I was hoping for my idea to get back some
attractiveness at this point :)

At least I tried ;)
--
dim

pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Feature freeze status
Next
From: Heikki Linnakangas
Date:
Subject: Free Space Map data structure