allow COPY routines to read arbitrary numbers of fields - Mailing list pgsql-hackers

From Andrew Dunstan
Subject allow COPY routines to read arbitrary numbers of fields
Date
Msg-id 4CFBD15B.8010000@dunslane.net
Whole thread Raw
Responses Re: allow COPY routines to read arbitrary numbers of fields  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Attached is a patch that allows CopyReadAttibutesText() and
CopyReadAttributesCSV() to read arbitrary numbers of attributes.
Underflowing attributes are recorded as null, and space is made for
overflowing attributes on a line.

This patch doesn't result in any user-visible behavior. The current
calling code will fail if the number of attributes read is not what is
expected, as happens now. But it will allow the API to be used (when
exposed) by a foreign data wrapper that can accept arbitrary numbers of
attributes. My aim here is to get to something like:

    CREATE FOREIGN TABLE my_csv (
         t text[]
    )
    SERVER file_server
    OPTIONS (format 'csv', filename '/path/to/my/data.csv', textarray
    'true',
              header 'true', delimiter ';', quote '@', escape '"', null '');

    SELECT t[3] as f1, t[1] as f2, t[9999] as probably_null
    FROM my_csv;

It would probably be nice to apply this before we start exposing the
COPY API to FDW routines, as discussed earlier today.

cheers

andrew




Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: FK's to refer to rows in inheritance child
Next
From: Greg Smith
Date:
Subject: Re: WIP patch for parallel pg_dump