Will make all of those changes. We appreciate the help.
1. remove global registration :(
2. New Name: PGCallback
3. use instanceData and passThrough names (passThrough with upper 'T')
3. separate getters for conn/result instanceData and passthrough
4. add a setter for result instance data
- There should also be a PQsetInstanceData(PGconn*, ...)
- I see no need for a passThrough setter
5. move callback stuff to its own header, maybe pgcallback.h?
No issue with any of them. Although, small issue below:
Maybe instead of having the ResultCreate
callback scribble on the event data structure, provide an additional
API routine to store the pointer:
PQresultSetInstanceData(PGresult *res, PGeventProc proc,
void *instanceData);
Adding PQresultSetInstanceData doesn't removes the need for a resultcreate
callback event. This is an event the callbacks are informed about (instanceData
or not). It does remove the need for an instance data member in all event info
structures, just use the getter/setter when desired. If the passThrough is
needed, one can use the public getters.
> hooks registered. Also, meseems you need such a callback anyway:
> what if the hook library desires to realloc its instance data
> larger?
>
With your suggestions, this would work:
res = PQexec(conn, "blah");
data = PQresultInstanceData(res, cbfunc);
data = realloc(data, 1024);
PQresultSetInstanceData(res, cbfunc, data);
The API user should have a valid instanceData whenever libpq returns a result,
assuming they registered a callback that allocates instance data during a
resultcreate event.
--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/
--
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches