> 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 of the 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers