Re: COPY with column headings

From: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY with column headings
Date: 2004-08-16 15:45:22
Message-ID: 20040816154521.GA9953@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 16, 2004 at 11:30:49AM -0400, Tom Lane wrote:

> The bigger question is whether this would do anything to satisfy the
> requestor. He probably wants the headings to appear in the file
> resulting from COPY TO file (or the psql equivalent), which this would
> not do. Providing the info in the COPY PGresult would change nothing
> except the behavior of client applications specially rewritten to use it.

True, and from a compatibility standpoint that would probably be good...

Output post-processing (translation to CSV or XML output, XSLT transforms,
what have you) IMHO should probably go on top of COPY anyway, rather than
into it. Are people really having problems with

select * from table where 1=0 ; copy table to stdout

and first printing the column names found in the first PGresult, then
dumping the COPY lines to the same fd? I think that should do the trick for
most uses, although obviously I'm no expert.

Jeroen

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-08-16 15:49:50 Re: COPY with column headings
Previous Message Tom Lane 2004-08-16 15:30:49 Re: COPY with column headings