Skip to content

Commit b97e8ba

Browse files
Atsushi TorikoshiCommitfest Bot
authored andcommitted
COPY TO: provide hint when WHERE clause is used
Provide a hint suggesting COPY TO when a WHERE clause is specified, similar to the hint already given for views or others.
1 parent 317c117 commit b97e8ba

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)