Re: libpq object hooks - Mailing list pgsql-patches

From Andrew Dunstan
Subject Re: libpq object hooks
Date
Msg-id 482C7778.40707@dunslane.net
Whole thread Raw
In response to Re: libpq object hooks  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: libpq object hooks  (Andrew Chernow <ac@esilo.com>)
Re: libpq object hooks  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches

Tom Lane wrote:
> "Merlin Moncure" <mmoncure@gmail.com> writes:
>
>> The problem is the functions PQhookData(conn, hookname) and
>> PQresultHookData(result, hookName).  We need these to work in
>> functions that are not callbacks.  If we eliminate hookname
>> completely, there is no way for libpq to know which private state we
>> are asking for.
>>
>
> Well, depending on a hook name for this is broken-by-design anyway,
> because there is no way for two independently written libraries to
> be sure they don't choose conflicting hook names.  So the need for
> a hook name has to go away.
>
> It might work to use the address of the hook callback function as
> a key for retrieving the associated void * pointer.  You'd need to
> not register the same callback function more than once per object,
> but from what I gather here you don't need to.
>
>
>

Or else have the library return a unique handle when registering hooks,
rather than supplying a hook name.

cheers

andrew

pgsql-patches by date:

Previous
From: Ron Mayer
Date:
Subject: Re: Patch to change psql default banner v6
Next
From: Andrew Chernow
Date:
Subject: Re: libpq object hooks