Re: COPY Transform support - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: COPY Transform support
Date
Msg-id 200804072136.43679.dfontaine@hi-media.com
Whole thread Raw
In response to Re: COPY Transform support  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: COPY Transform support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Le Monday 07 April 2008 21:04:26 Andrew Dunstan, vous avez écrit :
> Quite apart from any other reason why not, this would be a horrid hack
> and is just the sort of "feature" we rightly eschew, IMNSHO. COPY is
> designed as a bulk load/unload facility. It's fragile enough in that role.

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. More often than not, you get this kind of data from another
system, so in a deterministic way, and you want a chance to transform their
representation just before PostgreSQL parses it.

May I try to insist on my second syntax proposal form:

  COPY destination_table(col1, col2, col3)
 USING (field1, field2 || field3, myfunc(field4, field5))
  FROM 'file.txt'
  WITH ...

This allows for the case I'm concerned with to be taken care of, AND the other
case pointed out by several posters on this thread too. N input fields, M
stored columns, any line to row transformation (after same column splitting
as of now), any column pre-parsing through SQL callable functions --- myfunc
is called before feeding col3%ROWTYPE input function, e.g.
And no support (that I see) for optional second storage system back door.

Comments?
--
dim

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: File system snapshots for multiple file systems
Next
From: Zoltan Boszormenyi
Date:
Subject: Re: TRUNCATE TABLE with IDENTITY