Skip site navigation (1) Skip section navigation (2)

Re: \copy (query) delimiter syntax error

From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: \copy (query) delimiter syntax error
Date: 2007-02-03 16:52:29
Message-ID: 63462.24.211.165.134.1170521549.squirrel@www.dunslane.net (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Michael Fuhr wrote:
> psql's \copy (query) with a delimiter yields a syntax error:
>
>   test=> \copy foo to foo.txt delimiter '|'
>   (works)
>
>   test=> \copy (select * from foo) to foo.txt
>   (works)
>
>   test=> \copy (select * from foo) to foo.txt delimiter '|'
>   ERROR:  syntax error at or near "USING"
>   LINE 1: COPY ( select * from foo ) TO STDOUT USING DELIMITERS '|'
>
> The problem is that \copy sends USING DELIMITERS for backward
> compatibility (comment on line 502 of src/bin/psql/copy.c) but that
> COPY (query) doesn't support USING DELIMITERS:
>
>   CopyStmt:   COPY opt_binary qualified_name opt_column_list opt_oids
>               copy_from copy_file_name copy_delimiter opt_with
> copy_opt_list
>               ...
>               | COPY select_with_parens TO copy_file_name opt_with
>                 copy_opt_list
>
>   copy_delimiter:
>               /* USING DELIMITERS kept for backward compatibility.
> 2002-06-15 */
>              opt_using DELIMITERS Sconst
>
> What should be fixed -- COPY or \copy?  Does psql's \copy still
> need backward compatibility to unsupported pre-7.3?
>


I'd say fix psql. Not sure how far back we should backpatch it. It's
interesting that this has been there since 8.0 and is only now discovered.

cheers

andrew



In response to

Responses

pgsql-hackers by date

Next:From: Michael FuhrDate: 2007-02-03 17:12:07
Subject: Re: \copy (query) delimiter syntax error
Previous:From: Markus SchiltknechtDate: 2007-02-03 16:08:26
Subject: Fix "database is ready" race condition

pgsql-patches by date

Next:From: Michael FuhrDate: 2007-02-03 17:12:07
Subject: Re: \copy (query) delimiter syntax error
Previous:From: Markus SchiltknechtDate: 2007-02-03 16:08:26
Subject: Fix "database is ready" race condition

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group