Re: COPY table FROM STDIN doesn't show count tag - Mailing list pgsql-hackers

From Tom Lane
Subject Re: COPY table FROM STDIN doesn't show count tag
Date
Msg-id 12040.1394547696@sss.pgh.pa.us
Whole thread Raw
In response to Re: COPY table FROM STDIN doesn't show count tag  (Rajeev rastogi <rajeev.rastogi@huawei.com>)
Responses Re: COPY table FROM STDIN doesn't show count tag
List pgsql-hackers
Rajeev rastogi <rajeev.rastogi@huawei.com> writes:
> On 10 March 2014 23:44, Tom Lane wrote:
>> Unfortunately, while testing it I noticed that there's a potentially
>> fatal backwards-compatibility problem, namely that the "COPY n" status
>> gets printed on stdout, which is the same place that COPY OUT data is
>> going.  While this isn't such a big problem for interactive use, usages
>> like this one are pretty popular:
>> 
>> psql -c 'copy mytable to stdout' mydatabase | some-program
>> 
>> With the patch, "COPY n" gets included in the data sent to some-program,
>> which never happened before and is surely not what the user wants.
>> The same if the -c string uses \copy.

> Is it OK to have different status output for different flavor of COPY command? 
> I am afraid that It will become kind of inconsistent result.

Well, that's the big question here.

We already do have different status output for different kinds of COPY,
ie we don't report it for COPY FROM STDIN/TO STDOUT.  What now emerges
is that there's a good reason for the omission in the case of TO STDOUT.
I certainly hadn't remembered that, and there's no documentation of it
in either code comments or the SGML docs.

After sleeping on it, I'm inclined to think we should continue to not
print status for COPY TO STDOUT.  Aside from the risk of breaking scripts,
there's a decent analogy to be made to SELECT: we don't print a status
tag for that either.

That leaves the question of whether we want to start printing a tag for
the COPY FROM STDIN case.  I don't think that'd create much risk of
breaking anything, and the analogy to SELECT doesn't hold either.
OTOH, Robert opined upthread that FROM STDIN and TO STDOUT shouldn't
behave differently; does that argument still impress anyone?  And given
that different COPY cases are still going to behave differently, maybe
we should just stick with the status quo.  It's been like this for a
mighty long time with few complaints.

In any case, some documentation and code comment changes would be
appropriate ...
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: db_user_namespace a "temporary measure"
Next
From: Andrew Dunstan
Date:
Subject: Re: db_user_namespace a "temporary measure"