Skip to content

Commit 5b0060a

Browse files
author
Commitfest Bot
committed
[CF 6016] v2 - COPY TO: provide hint when WHERE clause is used
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/6016 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAM6-o=DVOd-jpO6WparhuPjOG5QkNiyspdPzeOrDT6x_JAqDMw@mail.gmail.com Author(s): Atsushi Torikoshi
2 parents 317c117 + b97e8ba commit 5b0060a

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/backend/parser/gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,6 +3442,7 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list
34423442
ereport(ERROR,
34433443
(errcode(ERRCODE_SYNTAX_ERROR),
34443444
errmsg("WHERE clause not allowed with COPY TO"),
3445+
errhint("Try the COPY (SELECT ... WHERE ...) TO variant."),
34453446
parser_errposition(@11)));
34463447

34473448
n->options = NIL;

src/test/regress/expected/copy2.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ COPY x TO stdout WHERE a = 1;
163163
ERROR: WHERE clause not allowed with COPY TO
164164
LINE 1: COPY x TO stdout WHERE a = 1;
165165
^
166+
HINT: Try the COPY (SELECT ... WHERE ...) TO variant.
166167
COPY x from stdin WHERE a = 50004;
167168
COPY x from stdin WHERE a > 60003;
168169
COPY x from stdin WHERE f > 60003;

0 commit comments

Comments
 (0)