exposing COPY API

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: exposing COPY API
Date: 2011-02-04 00:48:56
Message-ID: 4D4B4CF8.4020403@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeremy Harris 2011-02-04 00:49:52 Re: [HACKERS] Slow count(*) again...
Previous Message Mladen Gogala 2011-02-04 00:39:42 Re: [HACKERS] Slow count(*) again...