Revisiting this, it occurred to me that I could achieve what I need of we extend the proposed API a bit. Currently, it has:

   extern CopyState BeginCopyFrom(Relation rel, const char *filename,
                                   List *attnamelist, List *options);


I'd like to be able to add a callback function to construct the values for the tuple. So it would become something like:

   typedef void (*copy_make_values) (CopyState cstate, NumFieldsRead int);

   extern CopyState BeginCopyFrom(Relation rel, const char *filename,
                                   List *attnamelist, List *options,
                                    copy_make_values custom_values_func);


If custom_values_func were NULL (as it would be if using the builtin COPY), then the builtin code would be run to construct the values for making tuple. If not null, the function would be called.

Of course, I want this so I could construct a text array from the read in data, but I could also imagine a foreign data wrapper wanting to mangle the data before handing it to postgres, say by filling in a field or hashing it.

The intrusiveness of this would be very small, I think.

Thoughts?

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to