From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix two issues with HEADER MATCH in COPY
Date: Thu, 23 Jun 2022 01:50:56 +0000
Message-ID: <E1o4Bzk-001Mag-Gc@gemulon.postgresql.org> (raw)
Fix two issues with HEADER MATCH in COPY
072132f0 used the attnum offset to access the raw_fields array when
checking that the attribute names of the header and of the relation
match, leading to incorrect results or even crashes if the attribute
numbers of a relation are changed, like on a dropped attribute. This
fixes the logic to use the correct attribute names for the header
matching requirements.
Also, this commit disallows HEADER MATCH in COPY TO as there is no
validation that can be done in this case.
The tests are expanded for HEADER MATCH with COPY FROM and dropped
columns, with cases where a relation has a dropped and re-added column,
as well as a reduced set of columns.
Author: Julien Rouhaud
Reviewed-by: Peter Eisentraut, Michael Paquier
Discussion: https://postgr.es/m/20220607154744.vvmitnqhyxrne5ms@jrouhaud
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ca7a0d1d368216e89359c63531a4df0b99a437e4
Modified Files
--------------
doc/src/sgml/ref/copy.sgml | 2 ++
src/backend/commands/copy.c | 11 +++++++--
src/backend/commands/copyfromparse.c | 5 ++--
src/test/regress/expected/copy.out | 43 ++++++++++++++++++++++++++++++++++-
src/test/regress/sql/copy.sql | 44 +++++++++++++++++++++++++++++++++---
5 files changed, 97 insertions(+), 8 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz
Subject: Re: pgsql: Fix two issues with HEADER MATCH in COPY
In-Reply-To: <E1o4Bzk-001Mag-Gc@gemulon.postgresql.org>
References: <E1o4Bzk-001Mag-Gc@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox