aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-10-21 15:08:22 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2024-10-21 15:08:22 -0400
commit68ad9816c189958a0731d8d5ead7545878fdf15d (patch)
treeb03efa2a4b5fed3c324768cfbadebeb4668e22a0 /src/backend
parent3c7d78427ea9d92d346ee9aada4fa483bd1059e8 (diff)
downloadpostgresql-68ad9816c189958a0731d8d5ead7545878fdf15d.tar.gz
postgresql-68ad9816c189958a0731d8d5ead7545878fdf15d.zip
Fix wrong assertion and poor error messages in "COPY (query) TO".
If the query is rewritten into a NOTIFY command by a DO INSTEAD rule, we'd get an assertion failure, or in non-assert builds issue a rather confusing error message. Improve that. Also fix a longstanding grammar mistake in a nearby error message. Per bug #18664 from Alexander Lakhin. Back-patch to all supported branches. Tender Wang and Tom Lane Discussion: https://postgr.es/m/18664-ffd0ebc2386598df@postgresql.org
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/copyto.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index 463083e645d..f55e6d96751 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -475,7 +475,7 @@ BeginCopyTo(ParseState *pstate,
if (q->querySource == QSRC_NON_INSTEAD_RULE)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("DO ALSO rules are not supported for the COPY")));
+ errmsg("DO ALSO rules are not supported for COPY")));
}
ereport(ERROR,
@@ -492,7 +492,11 @@ BeginCopyTo(ParseState *pstate,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY (SELECT INTO) is not supported")));
- Assert(query->utilityStmt == NULL);
+ /* The only other utility command we could see is NOTIFY */
+ if (query->utilityStmt != NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("COPY query must not be a utility command")));
/*
* Similarly the grammar doesn't enforce the presence of a RETURNING