exposing COPY API - Mailing list pgsql-hackers

From Andrew Dunstan
Subject exposing COPY API
Date
Msg-id 4D4B4CF8.4020403@dunslane.net
Whole thread Raw
Responses Re: exposing COPY API
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Per-column collation, the finale
Next
From: Alex Hunsaker
Date:
Subject: Re: arrays as pl/perl input arguments [PATCH]