Re: Add partial :-variable expansion to psql \copy

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Christoph Berg <myon(at)debian(dot)org>
Cc: Fabien Coelho <coelho(at)cri(dot)ensmp(dot)fr>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add partial :-variable expansion to psql \copy
Date: 2025-04-01 10:15:30
Message-ID: CAFj8pRBNgnxCuSuUGm_Mad4RwCMCQ6SBC8v3t9qz5rqXTJTqRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

út 1. 4. 2025 v 12:00 odesílatel Christoph Berg <myon(at)debian(dot)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
>
>
>

In response to

Browse pgsql-hackers by date

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