Re: variable filename for psql \copy

2022-04-26 Thread Jiří Fejfar
Dear Daniel, David On Mon, 25 Apr 2022 at 18:07, David G. Johnston wrote: > On Mon, Apr 25, 2022 at 1:24 AM Jiří Fejfar 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

Re: variable filename for psql \copy

2022-04-25 Thread David G. Johnston
On Mon, Apr 25, 2022 at 1:24 AM Jiří Fejfar 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

Re: variable filename for psql \copy

2022-04-25 Thread Daniel Verite
Jiří Fejfar wrote: > I have found maybe buggy behaviour (of psql parser?) when using psql \copy > with psql variable used for filename. While it's annoying that it doesn't work as you tried it, this behavior is documented, so in that sense it's not a bug. The doc also suggests a

variable filename for psql \copy

2022-04-25 Thread Jiří Fejfar
Hi all, I have found maybe buggy behaviour (of psql parser?) when using psql \copy with psql variable used for filename. SQL copy is working fine: contrib_regression=# \set afile '/writable_dir/out.csv' contrib_regression=# select :'afile' as filename; filename ---