Re: Nasty, propagating POLA violation in COPY CSV HEADER - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: Nasty, propagating POLA violation in COPY CSV HEADER
Date
Msg-id 4FE20302.3080909@agliodbs.com
Whole thread Raw
In response to Re: Nasty, propagating POLA violation in COPY CSV HEADER  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
> In the past people have asked me to have copy use the CSV header line in
> place of supplying a column list in the COPY command. I can certainly
> see some utility in that, and I think it might achieve what David wants.
> Using that scenario it would be an error to supply an explicit column
> list and also use the header line. But then I don't think CHECK_HEADER
> would be the right name for the option. In any case, specifying a name
> before we settle on an exact behaviour seems wrong :-)

Actually, I can see three valid and valuable-to-users behaviors here:

1) current behavior, header line is ignored.

2) CHECK HEADER: a column list is supplied, but a "check header" flag is
set.  If the column list and header list don't match *exactly*, you get
an error.

3) USE HEADER: no column list is supplied, but a "use header" flag is
set.  A column list is created to match the columns from the CSV header.Of necessity, this will consist of all or some
ofthe columns in the
 
table.  If columns are supplied which are not in the table, then you get
an error (as well as if columns are missing which are NOT NULL, as you
get at present).

(2) is more valuable to people who want to check data integrity
rigorously, and test for unexpected API changes.  (3) is more valuable
for regular users who want CSV import to "just work".  (1) is valuable
for backwards compatibility, and for cases where the CSV header was
generated by another program (Excel?) so the column names don't match.

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com




pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node
Next
From: Christopher Browne
Date:
Subject: Re: [PATCH 10/16] Introduce the concept that wal has a 'origin' node