Re: COPY TO: provide hint when WHERE clause is used

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: COPY TO: provide hint when WHERE clause is used
Date: 2025-08-30 18:14:29
Message-ID: f0d8f544-fc41-44d3-a933-b69e4464c6c8@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

On 19.08.25 03:35, torikoshia wrote:
> Considering what the user was trying to do, it might be helpful to
> provide a similar hint in this case as well.
> I’ve attached a patch that adds such a hint.
>
> What do you think?
>

+1

I tested the patch and the error message now has the intended HINT ...

postgres=# COPY t1 TO STDOUT WHERE i > 5;
ERROR:  WHERE clause not allowed with COPY TO
LINE 1: COPY t1 TO STDOUT WHERE i > 5;
                          ^
HINT:  Try the COPY (SELECT ... WHERE ...) TO variant.

... which aligns with the HINT from COPY TO from views

postgres=# COPY v1 TO STDOUT;
ERROR:  cannot copy from view "v1"
HINT:  Try the COPY (SELECT ...) TO variant.

Best, Jim

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-08-30 18:14:40 Re: Move block_range_read_stream_cb batchmode comment
Previous Message Alvaro Herrera 2025-08-30 17:50:56 Re: Adding REPACK [concurrently]