| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Disallow system columns in COPY FROM WHERE conditions. |
| Date: | 2026-04-06 18:05:22 |
| Message-ID: | E1w9oK9-003Gl9-2N@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Disallow system columns in COPY FROM WHERE conditions.
These columns haven't been computed yet when the filtering happens
(since we've not written the candidate tuple into the table); so
any check on them is wrong or useless. Worse, since aa606b931 such a
reference results in an access off the end of a TupleDesc, potentially
causing a phony "generated columns are not supported in COPY FROM
WHERE conditions" error; and since c98ad086a it throws an Assert
instead.
Actually we could allow tableoid, which has been set to the OID of the
table named as the COPY target. However, plausible uses for tests of
tableoid would involve a partitioned target table, and the user would
wish it to read as the OID of the destination partition. There has
been some discussion of changing things to make it work like that,
but pending that happening we should just disallow tableoid along
with other system columns.
It seems best though to install this prohibition only in HEAD.
In the back branches we'll just guard the unsafe TupleDesc access,
and people will keep getting whatever semantics they got before.
Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/6f435023-8ab6-47c2-ba07-035d0c4212f9@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/21c69dc73f9d0af6a11f13ef61522577126a8674
Modified Files
--------------
src/backend/commands/copy.c | 36 ++++++++++++++++++++++++++++--------
src/test/regress/expected/copy2.out | 3 +++
src/test/regress/sql/copy2.sql | 2 ++
3 files changed, 33 insertions(+), 8 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-04-06 18:11:59 | pgsql: Rename cluster.c to repack.c (and corresponding .h) |
| Previous Message | Tom Lane | 2026-04-06 17:25:35 | pgsql: Add missing .gitignore files. |