pg.ddx.io  pgsql-patches@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Chernow <ac@esilo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Merlin Moncure <mmoncure@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Patches (PostgreSQL) <pgsql-patches@postgresql.org>
Subject: Re: libpq object hooks
Date: Thu, 15 May 2008 17:18:59 -0400
Message-ID: <482CA8C3.2000507@esilo.com> (raw)
In-Reply-To: <9867.1210877054@sss.pgh.pa.us>
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>
	<482C77E5.1060500@esilo.com>
	<9458.1210875556@sss.pgh.pa.us>
	<482C82BA.3090100@esilo.com>
	<9867.1210877054@sss.pgh.pa.us>

Tom Lane wrote:
> Andrew Chernow <ac@esilo.com> writes:
>> Which callback do we use as the key?  Currently, none are required (only 
>> the name was required).  We have to choose one callback that must be 
>> provided.
> 
> What?  I thought what you wanted back was the void * pointer that had
> been registered with a particular callback function.  So you use that
> callback function.  If it's not actually registered, you get a NULL.
> 
>> This is what is passed to PQaddObjectHooks, along with a conn:
> 
> This is all wrong IMHO, not least because it creates ABI problems if you
> want to add another hook type later.  Register each hook separately, eg
> 
> typedef void (*PGCRHook) (PGconn *conn, void *passthrough);
> 
> void PQregisterConnResetHook(PGconn *conn, PQCRHook func, void *passthrough);
> 
> ... repeat for each possible hook ...
> 
> 			regards, tom lane
> 
> 

One can make a case to break apart the obj hooks structure into 
individual register functions, but I think you have a different idea in 
your head than what is being proposed.  For starters, there is no 
passthru pointer to register with a callback (there could be but that is 
different than hook data...your register looks more like a user_ptr). 
The passthru pointer, what we call hookData, is allocated with a PGconn 
(not provided by the user).  This is the point of the initHookData callback.

typedef void *(*PGinitHookData)(const PGconn *conn);

PQregisterInitHookData((PGconn *)NULL, (PGinitHookData)func);
PQregisterConnResetHook((PGconn *)NULL, (PGCRHook)func);
//etc...
conn = PQconnectdb();

When connectdb returns, initHookData has already been called.  So, a 
call to PQhookData(conn, ????) will work.  BUT, what is still missing 
from the equation is how to uniquely reference hookData on a conn.

What I was previously suggesting was to use the address of initHookData, 
since w/o this address there wouldn't be any hook data to get.  Seemed 
like a logical choice.

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



view thread (45+ messages)  latest in thread

Message-ID: <482CA8C3.2000507@esilo.com>
Permalink:  ../482CA8C3.2000507@esilo.com/
Also on:    postgresql.org/message-id/482CA8C3.2000507@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-patches@postgresql.org
  Cc: ac@esilo.com, tgl@sss.pgh.pa.us, mmoncure@gmail.com, andrew@dunslane.net, alvherre@commandprompt.com
  Subject: Re: libpq object hooks
  In-Reply-To: <482CA8C3.2000507@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