pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add HINT for COPY TO when WHERE clause is used.
Date: Tue, 02 Sep 2025 23:37:41 +0000
Message-ID: <E1utaZJ-000E5I-1W@gemulon.postgresql.org> (raw)

Add HINT for COPY TO when WHERE clause is used.

COPY TO does not support a WHERE clause, and currently fails with the error:

    ERROR:  WHERE clause not allowed with COPY TO

Since the intended behavior can be achieved by using
COPY (SELECT ... WHERE ...) TO, this commit adds a HINT
to the error message:

    HINT:  Try the COPY (SELECT ... WHERE ...) TO variant.

This makes the error more informative and helps users
quickly find the alternative usage.

Author: Atsushi Torikoshi <torikoshia@oss.nttdata.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/3520c224c5ffac0113aef84a9179f37e@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/229911c4bf9a4acfb2b81cff148fd8391e0a577b

Modified Files
--------------
src/backend/parser/gram.y           | 1 +
src/test/regress/expected/copy2.out | 1 +
2 files changed, 2 insertions(+)



Message-ID: <E1utaZJ-000E5I-1W@gemulon.postgresql.org>
Permalink:  ../E1utaZJ-000E5I-1W@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1utaZJ-000E5I-1W@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add HINT for COPY TO when WHERE clause is used.
  In-Reply-To: <E1utaZJ-000E5I-1W@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox