Re: Switching from OSX to Linux, multi-line queries in \copy don't work anymore

From: Ryan Kelly <rpkelly22(at)gmail(dot)com>
To: Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk>
Cc: pgsql-general(at)PostgreSQL(dot)org
Subject: Re: Switching from OSX to Linux, multi-line queries in \copy don't work anymore
Date: 2012-07-27 14:27:49
Message-ID: 20120727142749.GC1807@llserver.lakeliving.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 27, 2012 at 02:06:01PM +0000, Mark Morgan Lloyd wrote:
> Craig Ringer wrote:
> >On 07/27/2012 09:28 PM, Ryan Kelly wrote:
> >>I recently switched from OSX to Linux and \copy in psql no longer
> >>accepts multi-line queries. For instance:
> >>
> >>\copy (
> >> select
> >> *
> >> from
> >> pg_settings
> >>) to '/tmp/settings.csv' with csv header
> >>
> >>This works fine on OSX. On Linux I get:
> >>\copy: parse error at end of line
> >>
> >>Am I missing something here?
> >A wild guess: I'd say this is a consequence of the fact that psql
> >on OS X uses libedit, on Linux it uses readline.
> >
> >Personally I had no idea that multiline \copy was possible at all.
> >I've always though the way backslash commands are EOL-terminated
> >while everything else is semicolon terminated is a bit of a wart,
> >though.
> >
> >I don't have an answer for you. Using the --no-readline argument
> >makes no difference on my 9.1.4 here. This may just be an area
> >where libedit is smarter than readline - or it might be that I'm
> >totally wrong and the real issue is something else entirely.
> >
> >Thanks for making the effort to produce a good post with all the
> >detailed version info, exact error text, etc.
>
> Also appear to get it here on single-line queries:
>
> markMLl=> \copy (select * from pg_settings) to '/tmp/settings.csv'
> with csv header;
> \copy: parse error at "select"
> markMLl=>
>
> However my psql and server are rather old which could be an issue
> (8.1.19 to server 8.4 if I recall correctly).
This works for me, it might be the case that your psql is too old.
Perhaps \copy didn't support queries until later?

-Ryan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Neyman 2012-07-27 14:47:52 Re: information_schema.referential_constraints broken?
Previous Message Chris Angelico 2012-07-27 14:21:45 Re: Terminating a rogue connection