Re: Add header support to text format and matching feature

vignesh C <vignesh21@gmail.com>

From: vignesh C <vignesh21@gmail.com>
To: Rémi Lapeyre <remi.lapeyre@lenstra.fr>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-07-18T11:23:19Z
Lists: pgsql-hackers
On Fri, Jul 17, 2020 at 10:18 PM Rémi Lapeyre <remi.lapeyre@lenstra.fr> wrote:
>
> >
> > I don't know how to do that with git-send-email, but you can certainly do it easy with git-format-patch and just attach them using your regular MUA.
> >
> > (and while the cfbot and the archives have no problems dealing with the change in subject, it does break threading in some other MUAs, so I would recommend not doing that and sticking to the existing subject of the thread)
> >
>
> Thanks, here are both patches attached so cfbot can read them.

Few comments:
Few tests are failing because of hardcoded path:
+-- test header matching
+CREATE FOREIGN TABLE header_match ("1" int, foo text) SERVER file_server
+OPTIONS (format 'csv', filename
'/Users/remi/src/postgresql/contrib/file_fdw/data/list1.csv',
delimiter ',', header 'match');
+CREATE FOREIGN TABLE header_dont_match (a int, foo text) SERVER file_server
+OPTIONS (format 'csv', filename
'/Users/remi/src/postgresql/contrib/file_fdw/data/list1.csv',
delimiter ',', header 'match');  -- ERROR
Generally path is not specified like this. file_fdw test of make
check-world is failing because of this.

There is one warning present in the changes:
copy.c: In function ‘ProcessCopyOptions’:
copy.c:1208:5: warning: ISO C90 forbids mixed declarations and code
[-Wdeclaration-after-statement]
     char    *sval = defGetString(defel);

There is space before tab in indent in the below code, check for git
diff --check.
+                       if (fldct < list_length(cstate->attnumlist))
+                               ereport(ERROR,
+
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
+                                        errmsg("missing header")));

Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com



Commits

  1. Fix two issues with HEADER MATCH in COPY

  2. Add header matching mode to COPY FROM

  3. Add HEADER support to COPY text format

  4. Fix handling of redundant options with COPY for "freeze" and "header"