pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add header matching mode to COPY FROM
Date: Wed, 30 Mar 2022 07:10:07 +0000
Message-ID: <E1nZST0-00218v-Eg@gemulon.postgresql.org> (raw)

Add header matching mode to COPY FROM

COPY FROM supports the HEADER option to silently discard the header
line from a CSV or text file.  It is possible to load by mistake a
file that matches the expected format, for example, if two text
columns have been swapped, resulting in garbage in the database.

This adds a new option value HEADER MATCH that checks the column names
in the header line against the actual column names and errors out if
they do not match.

Author: Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Reviewed-by: Daniel Verite <daniel@manitou-mail.org>
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/CAF1-J-0PtCWMeLtswwGV2M70U26n4g33gpe1rcKQqe6wVQDrFA@mail....

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/072132f04e55c1c3b0f1a582318da78de7334379

Modified Files
--------------
contrib/file_fdw/expected/file_fdw.out | 19 ++++++++++-
contrib/file_fdw/sql/file_fdw.sql      |  9 +++++
doc/src/sgml/ref/copy.sgml             |  8 +++--
src/backend/commands/copy.c            | 60 +++++++++++++++++++++++++++++++++-
src/backend/commands/copyfromparse.c   | 53 ++++++++++++++++++++++++++++--
src/include/commands/copy.h            | 13 +++++++-
src/test/regress/expected/copy.out     | 23 +++++++++++++
src/test/regress/sql/copy.sql          | 33 +++++++++++++++++++
8 files changed, 210 insertions(+), 8 deletions(-)



Message-ID: <E1nZST0-00218v-Eg@gemulon.postgresql.org>
Permalink:  ../E1nZST0-00218v-Eg@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nZST0-00218v-Eg@gemulon.postgresql.org

 · 

reply

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: peter@eisentraut.org
  Subject: Re: pgsql: Add header matching mode to COPY FROM
  In-Reply-To: <E1nZST0-00218v-Eg@gemulon.postgresql.org>
  References: <E1nZST0-00218v-Eg@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