Presently you get a million lines of '\N command not recognised' and various other random things because if a line of the copy fails due to say a FK constraint, or even if the COPY is run in an aborted transaction, it tries to execute all the stdin data as actual statements.

I'd like to see a test case for this in v3 protocol. It was definitely a problem before that, but I thought I fixed it.

This is with 7.4 and it still does it.... Here is an example:

Make file called test.sql:

BEGIN;
CREATE TABLE blah (a int4);
COPY blah FROM STDIN;
1
2
3
\.
COMMIT;

Now, execute it TWICE on a clean database:

-bash-2.05b$ psql -f test.sql test
BEGIN
CREATE TABLE
COMMIT
-bash-2.05b$ psql -f test.sql test
BEGIN
psql:test.sql:2: ERROR: relation "blah" already exists
psql:test.sql:3: ERROR: current transaction is aborted, commands ignored until end of transaction block
psql:test.sql:7: invalid command \.
psql:test.sql:8: ERROR: syntax error at or near "1" at character 1
-bash-2.05b$


Also, sometimes when you copy and paste SQL into a psql window, it executes help on commands for each line, although it doesn't affect the paste. That is also really annoying.

Disable tab completion, or don't paste tabs. I don't think psql can be expected to recognize that a tab is coming from pasted input.

How about if it's in a literal, eg. function definition.

Chris

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to