Re: Add partial :-variable expansion to psql \copy - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Add partial :-variable expansion to psql \copy
Date
Msg-id CAFj8pRBNgnxCuSuUGm_Mad4RwCMCQ6SBC8v3t9qz5rqXTJTqRg@mail.gmail.com
Whole thread Raw
In response to Re: Add partial :-variable expansion to psql \copy  (Christoph Berg <myon@debian.org>)
List pgsql-hackers
Hi

út 1. 4. 2025 v 12:00 odesílatel Christoph Berg <myon@debian.org> napsal:
Re: Fabien Coelho
> (1) it seems that is the only command which is really full SQL hidden in a
> backslash command

Perhaps this form could be improved by changing `\copy (select) to file`
to something like `select \gcopy (to file)`. That might make :expansion
in the "select" part easier to handle.

I've heard several complaints that `\copy (select)` can't be wrapped
over several lines, so offering the alternative syntax in parallel to
\copy would also solve another problem.

What is the reason to use \copy (select) to ?

psql (on client side) supports csv format pretty well with single line switching to this format (i know so it not have the full functionality of COPY statement).

(2025-04-01 12:08:36) postgres=# select 1,2 \g (format=csv) output.csv
(2025-04-01 12:08:53) postgres=#

For me, the original proposal has interesting benefits (Tom wrote about it). Inconsistency where psql's variable can or cannot be used is unhappy. It is always bad surprising when you find some inconsistencies

Regards

Pavel
 

Christoph


pgsql-hackers by date:

Previous
From: Christoph Berg
Date:
Subject: Re: Add partial :-variable expansion to psql \copy
Next
From: Kirill Reshke
Date:
Subject: Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query).