[PATCH v3 2/2] Add header matching mode to "COPY FROM"

From: Rémi Lapeyre <remi(dot)lapeyre(at)lenstra(dot)fr>
To: pgsql-hackers(at)postgresql(dot)org, peter(dot)eisentraut(at)2ndquadrant(dot)com
Cc: Rémi Lapeyre <remi(dot)lapeyre(at)lenstra(dot)fr>
Subject: [PATCH v3 2/2] Add header matching mode to "COPY FROM"
Date: 2020-07-17 14:54:10
Message-ID: 20200717145410.5158-3-remi.lapeyre@lenstra.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

COPY FROM supports the HEADER option to silently discard the header 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 option adds the possibility to actually check the header to make
sure it matches what is expected and exit immediatly if it does not.

Discussion: https://www.postgresql.org/message-id/flat/CAF1-J-0PtCWMeLtswwGV2M70U26n4g33gpe1rcKQqe6wVQDrFA(at)mail(dot)gmail(dot)com
contrib/file_fdw/input/file_fdw.source | 6 ++
contrib/file_fdw/output/file_fdw.source | 9 ++-
doc/src/sgml/ref/copy.sgml | 8 ++-
src/backend/commands/copy.c | 84 +++++++++++++++++++++++--
src/test/regress/input/copy.source | 25 ++++++++
src/test/regress/output/copy.source | 17 +++++
6 files changed, 140 insertions(+), 9 deletions(-)

Attachment Content-Type Size
v3-0002-Add-header-matching-mode-to-COPY-FROM.patch text/x-patch 9.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2020-07-17 14:55:09 Re: Partitioning and postgres_fdw optimisations for multi-tenancy
Previous Message Rémi Lapeyre 2020-07-17 14:54:09 [PATCH v3 1/2] Add header support to "COPY TO" text format