Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 92EA72E0031 for ; Mon, 19 May 2008 23:21:15 -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 61139-03 for ; Mon, 19 May 2008 23:21:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.esilo.com (ns1.esilo.com [63.150.152.211]) by developer.postgresql.org (Postfix) with ESMTP id 573B62E002C for ; Mon, 19 May 2008 23:21:12 -0300 (ADT) Received: from [192.168.1.103] (c-65-34-212-214.hsd1.fl.comcast.net [65.34.212.214]) (authenticated bits=0) by mail.esilo.com (8.13.1/8.13.1) with ESMTP id m4K2L51j019378; Mon, 19 May 2008 22:21:06 -0400 Message-ID: <48323593.4060302@esilo.com> Date: Mon, 19 May 2008 22:21:07 -0400 From: Andrew Chernow User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Tom Lane CC: Merlin Moncure , Andrew Dunstan , Alvaro Herrera , "Patches (PostgreSQL)" Subject: Re: libpq object hooks (libpq events) References: <482A58D8.2030205@dunslane.net> <20080514043313.GS6966@alvh.no-ip.org> <482AD896.4000504@dunslane.net> <19342.1210776271@sss.pgh.pa.us> <482B1480.1070705@esilo.com> <482B2AC5.7000503@esilo.com> <482ECF62.7010901@esilo.com> <12200.1211242959@sss.pgh.pa.us> In-Reply-To: <12200.1211242959@sss.pgh.pa.us> 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/392 X-Sequence-Number: 6418 Will make all of those changes. We appreciate the help. 1. remove global registration :( 2. New Name: PGCallback 3. use instanceData and passThrough names (passThrough with upper 'T') 3. separate getters for conn/result instanceData and passthrough 4. add a setter for result instance data - There should also be a PQsetInstanceData(PGconn*, ...) - I see no need for a passThrough setter 5. move callback stuff to its own header, maybe pgcallback.h? No issue with any of them. Although, small issue below: > Maybe instead of having the ResultCreate > callback scribble on the event data structure, provide an additional > API routine to store the pointer: > PQresultSetInstanceData(PGresult *res, PGeventProc proc, > void *instanceData); Adding PQresultSetInstanceData doesn't removes the need for a resultcreate callback event. This is an event the callbacks are informed about (instanceData or not). It does remove the need for an instance data member in all event info structures, just use the getter/setter when desired. If the passThrough is needed, one can use the public getters. > hooks registered. Also, meseems you need such a callback anyway: > what if the hook library desires to realloc its instance data > larger? > With your suggestions, this would work: res = PQexec(conn, "blah"); data = PQresultInstanceData(res, cbfunc); data = realloc(data, 1024); PQresultSetInstanceData(res, cbfunc, data); The API user should have a valid instanceData whenever libpq returns a result, assuming they registered a callback that allocates instance data during a resultcreate event. -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/