pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Chernow <ac@esilo.com>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Merlin Moncure <mmoncure@gmail.com>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Patches (PostgreSQL) <pgsql-patches@postgresql.org>
Subject: Re: libpq object hooks
Date: Thu, 15 May 2008 14:06:06 -0400
Message-ID: <482C7B8E.9050709@esilo.com> (raw)
In-Reply-To: <482C7778.40707@dunslane.net>
References: <b42b73150804301323i18b00019i62e765708abb65aa@mail.gmail.com>
	<482A58D8.2030205@dunslane.net>
	<20080514043313.GS6966@alvh.no-ip.org>
	<482AD896.4000504@dunslane.net>
	<19342.1210776271@sss.pgh.pa.us>
	<b42b73150805150852m7b3c28fai2d7a4497c84118b2@mail.gmail.com>
	<6044.1210867771@sss.pgh.pa.us>
	<482C7778.40707@dunslane.net>

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/



view thread (45+ messages)  latest in thread

Message-ID: <482C7B8E.9050709@esilo.com>
Permalink:  ../482C7B8E.9050709@esilo.com/
Also on:    postgresql.org/message-id/482C7B8E.9050709@esilo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ac@esilo.com, andrew@dunslane.net, tgl@sss.pgh.pa.us, mmoncure@gmail.com, alvherre@commandprompt.com, pgsql-patches@postgresql.org
  Subject: Re: libpq object hooks
  In-Reply-To: <482C7B8E.9050709@esilo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox