Re: variable filename for psql \copy

From: Jiří Fejfar <jurafejfar(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: variable filename for psql \copy
Date: 2022-04-26 11:55:14
Message-ID: CA+8wVNWFSGSkMj7fzV=D+KehZx4iVjUaYqkyuf3b_m4xnhOquw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Daniel, David

On Mon, 25 Apr 2022 at 18:07, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

> On Mon, Apr 25, 2022 at 1:24 AM Jiří Fejfar <jurafejfar(at)gmail(dot)com> wrote:
>
>> contrib_regression=# copy (select 1) to :'afile';
>>
>
> Hopefully you realize that COPY is going to place that file on the server,
> not send it to the psql client to be placed on the local machine.
>
> The best way to do copy in psql is:
> \set afile '...'
> \o :'afile'
> copy ... to stdout; --or the variant where you one-shot the \o ( \g with
> arguments )
>
> Not only do you get variable expansion but you can write the COPY command
> on multiple lines just like any other SQL command.
>
>
thank you for your advice, \g works pretty well in my case

> Additionally, we have a list, and even an online form, for submitting bug
> reports. That would have been the more appropriate place to direct this
> email.
>
>
sorry, I didn't realize that, next time I will send report there

J.

> David J.
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Sharma 2022-04-26 12:16:39 double inclusion of '-p' flex flag
Previous Message Andrey Borodin 2022-04-26 11:22:38 Re: An attempt to avoid locally-committed-but-not-replicated-to-standby-transactions in synchronous replication