Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id D330D2E003D for ; Thu, 15 May 2008 15:06:35 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75483-01 for ; Thu, 15 May 2008 15:06:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.esilo.com (web-qwest-sterling2.esilo.com [63.150.152.211]) by developer.postgresql.org (Postfix) with ESMTP id 13BB32E002D for ; Thu, 15 May 2008 15:06:30 -0300 (ADT) Received: from [10.0.0.84] (fwext-esilo-jupiter.esilo.com [64.135.45.146]) (authenticated bits=0) by mail.esilo.com (8.13.1/8.13.1) with ESMTP id m4FI67TH027215; Thu, 15 May 2008 14:06:13 -0400 Message-ID: <482C7B8E.9050709@esilo.com> Date: Thu, 15 May 2008 14:06:06 -0400 From: Andrew Chernow User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Andrew Dunstan CC: Tom Lane , Merlin Moncure , Alvaro Herrera , "Patches (PostgreSQL)" Subject: Re: libpq object hooks References: <482A58D8.2030205@dunslane.net> <20080514043313.GS6966@alvh.no-ip.org> <482AD896.4000504@dunslane.net> <19342.1210776271@sss.pgh.pa.us> <6044.1210867771@sss.pgh.pa.us> <482C7778.40707@dunslane.net> In-Reply-To: <482C7778.40707@dunslane.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/281 X-Sequence-Number: 6307 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/