Re: [HACKERS] psql -f inconsistency with "copy from stdin" - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [HACKERS] psql -f inconsistency with "copy from stdin"
Date
Msg-id Pine.LNX.4.21.0001121812260.1646-100000@localhost.localdomain
Whole thread Raw
In response to psql -f inconsistency with "copy from stdin"  (Brook Milligan <brook@biology.nmsu.edu>)
Responses Re: [HACKERS] psql -f inconsistency with "copy from stdin"
List pgsql-hackers
After further contemplation I am not completely sure which way is the
correct behaviour. Consider me doing this:

--test.sql
COPY foo FROM stdin;
data    data
data    data
SELECT * FROM foo;

and running psql -f test.sql < (anything) on it. Then I would expect it
to behave the other way.

The -f option is just another way of saying "get the input from there". If
you use both -f and stdin you're in essence saying "get the input from
there and there", and that feature does not exist in psql and would be
hard to extend to the general case.


On 2000-01-12, Brook Milligan mentioned:

> Today I ran into an inconsistency between two versions of postgresql
> in how psql handles copies from stdin.  At this point I am not sure
> how the rewrite of psql does things, but thought I'd mention the
> problem in case someone with it installed can check.
> 
> The issue is how the command
> 
>     psql -f test.sql db < test.dat
> 
> is treated, given the following files:
> 
>    -- test.sql
>    drop table test;
>    create table test (name text);
>    copy test from stdin;
>    select * from test;
> 
> and
> 
>    test.dat
>    a
>    b
> 
> Specifically v6.4.2 and v6.5.2 differ in the outcome, with v6.4.2
> producing what I would expect and v6.5.2 producing anomalous output.
> Note that performing the copy as
> 
>    psql -c "copy test from stdin" db < test.dat
> 
> works fine in either case.
> 
> v6.4.2 output:  The contents of test.dat are read into the table as
> one might expect having redirected that file to stdin and copying from
> stdin.
> 
> v6.5.2 output: The contents of test.dat are not read into the table at
> all.  Instead, the remainder of the test.sql file (i.e., select * ...)
> are read into the table.
> 
> How does the current version behave when performing these copies?  If
> it still behaves like 6.5.2, I suspect there is some bug in handling
> the copy command.
> 
> Cheers,
> Brook
> 
> 
> ************
> 
> 

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




pgsql-hackers by date:

Previous
From: Hideyuki Kawashima
Date:
Subject: ...
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] dubious improvement in new psql