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

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Atsushi Torikoshi <torikoshia(dot)tech(at)gmail(dot)com>
Cc: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, 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-09-01 09:09:38
Message-ID: CAHGQGwHasq+udkW8Uo9rwpwVWVwg+G2d+T=agYDuL0zSt6CWSQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 1, 2025 at 7:58 AM Atsushi Torikoshi
<torikoshia(dot)tech(at)gmail(dot)com> wrote:
>
>
>
> On Sun, Aug 31, 2025 at 3:14 AM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
> >
> > 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

+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.
>
> Thanks for your review!
>
> Updated the patch to pass regression tests.

The patch looks good to me. Barring any objections, I'm thinking to
commit the patch.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2025-09-01 09:23:59 Re: Correction of RowMark Removal During Sel-Join Elimination
Previous Message Mihail Nikalayeu 2025-09-01 09:06:35 Re: Adding REPACK [concurrently]