better error handling for COPY from stdin - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject better error handling for COPY from stdin
Date
Msg-id 20080422140217.GA12194@depesz.com
Whole thread Raw
List pgsql-general
if you have .sql file with COPY table FROM stdin;
and the table doesn't exist, psql prints a lot of errors from lines
which contain only data for copy.

to reproduce:
=> echo -ne "COPY non_existing_table FROM stdin;\n1\n\\N\n2\n\\.\n" | psql
ERROR:  relation "non_existing_table" does not exist
invalid command \N
invalid command \.
ERROR:  syntax error at or near "1"
LINE 1: 1
        ^

would it be possible to make it smarter, so it will not treat datalines from
failed copy as statements?

i see a lot of questions that "postgresql says command \N is invalid" - which
is of course rubbish, but making psql a bit smarter would make all of these
question go away.

regards,

depesz

--
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA.  here's my CV!" :)
http://www.depesz.com/ - blog dla ciebie (i moje CV)

pgsql-general by date:

Previous
From: Joris Dobbelsteen
Date:
Subject: Re: table as log (multiple writers and readers)
Next
From: Erik Jones
Date:
Subject: Re: How is statement level read consistency implemented?