pgsql: Add HINT for COPY TO when WHERE clause is used.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add HINT for COPY TO when WHERE clause is used.
Date: 2025-09-02 23:37:41
Message-ID: E1utaZJ-000E5I-1W@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)oss(dot)nttdata(dot)com>
Reviewed-by: Jim Jones <jim(dot)jones(at)uni-muenster(dot)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(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-09-03 01:21:18 pgsql: Update outdated references to the SLRU ControlLock
Previous Message Nathan Bossart 2025-09-02 21:54:37 pgsql: Change ReplicationSlotPersistentData's "synced" member to a bool