Re: libpq object hooks - Mailing list pgsql-patches

From Andrew Chernow
Subject Re: libpq object hooks
Date
Msg-id 482C7B8E.9050709@esilo.com
Whole thread Raw
In response to Re: libpq object hooks  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-patches
Andrew Dunstan wrote:
>
>
> Tom Lane wrote:
>>
>> 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
>
>

The problem with this is that hooks can be registered on a per-conn
basis.  Is there a way to ensure the libpq returned handle would be the
unique across every registration of a given PGobjectHooks?  ISTM that
the hook handle needs to be constant and unique somehow.  Tom's idea
would work with the "very" small limitation of not being able to reuse
hook callbacks.  I throw out an idea of using the address of a static,
which is constant and unique.

app_func(PGresult *res)
{
   PQresultHookData(res, ?handle?);
}

app_func is not aware of what PGconn generated the result so it has no
idea what libpq returned handle to use.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

pgsql-patches by date:

Previous
From: Andrew Chernow
Date:
Subject: Re: libpq object hooks
Next
From: Tom Lane
Date:
Subject: Re: libpq object hooks