Re: libpq object hooks (libpq events)

Поиск
Список
Период
Сортировка
От Andrew Chernow
Тема Re: libpq object hooks (libpq events)
Дата
Msg-id 48323593.4060302@esilo.com
обсуждение исходный текст
Ответ на Re: libpq object hooks (libpq events)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: libpq object hooks (libpq events)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-patches
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/

В списке pgsql-patches по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Simplify formatting.c
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Simplify formatting.c