Fix wrong assertion and poor error messages in "COPY (query) TO".
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Oct 2024 19:08:22 +0000 (15:08 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Oct 2024 19:08:22 +0000 (15:08 -0400)
commit68ad9816c189958a0731d8d5ead7545878fdf15d
treeb03efa2a4b5fed3c324768cfbadebeb4668e22a0
parent3c7d78427ea9d92d346ee9aada4fa483bd1059e8
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
src/backend/commands/copyto.c
src/test/regress/expected/copydml.out
src/test/regress/sql/copydml.sql