Re: [PATCHES] Current-stream read for psql's \copy

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Mark Feit <mfeit+postgresql(at)notonthe(dot)net>
Subject: Re: [PATCHES] Current-stream read for psql's \copy
Date: 2004-02-10 22:08:34
Message-ID: 200402102208.i1AM8YH27772@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:
> Bruce Momjian wrote:
> >
> > What do people want to do with the current \copy behavior for stdin?
> > Right now if you supply a file name with queries using psql -f, the copy
> > input is read from the terminal, not from the file.
>
> Actually, I was wrong. Right now \copy reads from psql's stdin, not
> always the terminal. It doesn't read from the same descriptor it gets
> its SQL commands, unless they are the same as psql's stdin, like:
>
> psql test < commands.sql
>
> You could make STDIN be the command stream, and add 'psqlstdin' for
> psql's stdin, but it seems like a very little used feature. It doesn't
> seem worth documenting it, let alone adding code to allow it.
>
> I assume \copy is designed primarily to allow reading from _local_ files
> rather than only files that exist on the database server, as COPY
> requires.

Now, I am really confused. First I see the \copy from '-' is already in
CVS. I missed that commit message, but it has been in for a few weeks.

Second, I think I now see the designer's goal of using stdin/stdout for
\copy. \copy is for reading local files rather than only server files
via COPY, but for stdin/stdout, there isn't any 'local' file that makes
it different than COPY, so I am not sure even why someone would use
\copy when they could use COPY.

Also, I came upon this gem:

$ echo '\\copy test to stdout' | psql -o /tmp/z test
444
444
444
444
444

Seems 'copy to stdout' also has this split idea of sending \copy output
to a different place from other output.

I guess my big question now is why someone would use \copy stdin/stdout
for reading input from the command stream when they can use COPY?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Keith Bottner 2004-02-10 22:14:51 Re: MS SQL features for new version
Previous Message James William Pye 2004-02-10 22:03:14 Re: Advice regarding configuration parameters

Browse pgsql-patches by date

  From Date Subject
Next Message Mark Gibson 2004-02-11 16:33:16 Re: [GENERAL] dblink - custom datatypes don't work
Previous Message Scott Goodwin 2004-02-10 22:04:56 Re: Patch to psql to allow SEARCH_PATH to be set from env