Peter, there seem to be problems with the COPY statement when psql is run
with redirected stdin.

If I have a file ${DUMPDIR}/dbdump.product containing:

COPY product FROM stdin;
05 \N 000000   \N \N S  D9 t  f  f  f  POLY BAGS-BLACK      .        Single   f
...
\.


and I run this command:
psql -e -d bray < ${DUMPDIR}/dbdump.product

no error messages are seen.

If I remove the COPY command from the file and run the COPY frpm inside
psql, I see the errors:

bray=> copy product from '/tmp/dbdump.product';
ERROR:  <unnamed> referential integrity violation - key referenced from 
product not found in brandname

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "And, behold, I come quickly; and my reward is with me,
      to give every man according as his work shall be."    
                               Revelation 22:12 



Mon, 17 Jan 2000 14:34:06 +0000
"Oliver Elphick" <olly@lfix.co.uk>
psql and COPY 
Sorry, I can't reproduce that. I have not been able to keep up with RI, so
I can't seem to get a usable table configuration together. I used a script

COPY three FROM STDIN;
\N
\.

on a table CREATE TABLE three ( a int4 not null ) and it gives me proper
error messages either way.

I am almost tempted to say that this is a bug in COPY, though I sure don't
want to blame anyone before I see it. Could you send me a complete test
case please?

	-Peter


On 2000-01-17, Oliver Elphick mentioned:

> Peter, there seem to be problems with the COPY statement when psql is run
> with redirected stdin.
> 
> If I have a file ${DUMPDIR}/dbdump.product containing:
> 
> COPY product FROM stdin;
> 05 \N 000000   \N \N S  D9 t  f  f  f  POLY BAGS-BLACK      .        Single   f
> ...
> \.
> 
> 
> and I run this command:
> psql -e -d bray < ${DUMPDIR}/dbdump.product
> 
> no error messages are seen.
> 
> If I remove the COPY command from the file and run the COPY frpm inside
> psql, I see the errors:
> 
> bray=> copy product from '/tmp/dbdump.product';
> ERROR:  <unnamed> referential integrity violation - key referenced from 
> product not found in brandname
> 
> 

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



Wed, 19 Jan 2000 00:28:19 +0100 (CET)
Peter Eisentraut <peter_e@gmx.net>
Re: [HACKERS] psql and COPY 