Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id DEA3E2E0043 for ; Fri, 16 May 2008 21:01:54 -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 10674-05 for ; Fri, 16 May 2008 21:01:07 -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 B8B4F2E0030 for ; Fri, 16 May 2008 21:00:19 -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 m4H009FA024849; Fri, 16 May 2008 20:00:10 -0400 Message-ID: <482E2007.6050502@esilo.com> Date: Fri, 16 May 2008 20:00: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 References: <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> <482CD76E.6000202@esilo.com> <17177.1210949948@sss.pgh.pa.us> <482DD3AC.9020207@esilo.com> <20531.1210969396@sss.pgh.pa.us> In-Reply-To: <20531.1210969396@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/343 X-Sequence-Number: 6369 Tom Lane wrote: > Where > exactly does the hook hand off the storage pointer to libpq? What > are you going to do if the hook fails to create the storage > (ie, out of memory during PGresult creation)? The current submitted patch has 3 of its function callbacks returning a void*, initHookData after the creation of a conn, resultCreate, and resultCopy. We have recently changed this design so all hooks, now called events, go through a single callback ... PGEventProc. The old function callbacks are just eventIds now. ///////////////////////////////// // The libpq side (looping registered event procs) PGEventResultCreate info; info.stateData = NULL; /* our event data ptr */ info.conn = conn; info.result = result; if(!result->evtState[i].proc(PGEVT_RESULTCREATE, (void *)&info, result->evtState[i].passThrough) { PQclear(result); // destroy result? ... not sure return error; // previously, we ignored it } // assign event data created by event proc. result->evtState[i].data = info.stateData; /////////////////////////////////////// // example of what the event proc does int my_evtproc(PGEventId evtId, void *evtInfo, void *passThrough) { switch(eventId) { case PGEVT_RESULTCREATE: { void *data = makeresultdata(....) if(!data) return FALSE; ((PGEventResultCreate *)evtInfo)->stateData = data; break; } } return TRUE; } -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/ -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/