Skip site navigation (1) Skip section navigation (2)

Re: COPY (query) TO file

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tino Wildenhain <tino(at)wildenhain(dot)de>
Cc: Mark Woodward <pgsql(at)mohawksoft(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY (query) TO file
Date: 2006-06-03 02:44:57
Message-ID: 12511.1149302697@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Tino Wildenhain <tino(at)wildenhain(dot)de> writes:
> Tom Lane wrote:
>> You're not seriously suggesting we reimplement evaluation of WHERE clauses
>> on the client side, are you?

> no, did I? But what is wrong with something like:

> \COPY 'SELECT foo,bar,baz FROM footable WHERE baz=5 ORDER BY foo' TO
> file|stdout

> which would just run the query (in the backend of course) and
> format the output just like copy would...

Oh, I see what you have in mind.  But that's hardly free either.  It
requires psql to be able to translate between the frontend SELECT data
format and COPY format; which is far from a trivial thing, especially
when you consider all those CSV options ;-).  And then we get to
maintain that code in parallel with the backend code anytime someone
wants another COPY feature.  And then if you want the feature in a
different client, you get to do it all over again.

On balance I think doing it in the backend is more flexible and requires
less duplication of code.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Qingqing ZhouDate: 2006-06-03 05:41:53
Subject: Re: bgwriter statistics
Previous:From: Tom LaneDate: 2006-06-03 02:27:02
Subject: Re: Why do we want to %Remove behavior of postmaster -o

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group