Add header matching mode to COPY FROM
Peter Eisentraut <peter@eisentraut.org>
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.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| contrib/file_fdw/expected/file_fdw.out | modified | +18 −1 |
| contrib/file_fdw/sql/file_fdw.sql | modified | +9 −0 |
| doc/src/sgml/ref/copy.sgml | modified | +6 −2 |
| src/backend/commands/copy.c | modified | +59 −1 |
| src/backend/commands/copyfromparse.c | modified | +50 −3 |
| src/include/commands/copy.h | modified | +12 −1 |
| src/test/regress/expected/copy.out | modified | +23 −0 |
| src/test/regress/sql/copy.sql | modified | +33 −0 |
Documentation touched
Discussion
- Allow COPY's 'text' format to output a header 88 messages · 2018-05-13 → 2022-06-23