Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EB29664FCF2 for ; Wed, 17 Sep 2008 00:00:58 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41333-07 for ; Wed, 17 Sep 2008 00:00:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.esilo.com (manager.esilo.com [63.150.152.211]) by postgresql.org (Postfix) with ESMTP id C7A7B64FCE9 for ; Wed, 17 Sep 2008 00:00:55 -0300 (ADT) Received: from [192.168.1.2] (75-149-240-149-Miami.hfc.comcastbusiness.net [75.149.240.149] (may be forged)) (authenticated bits=0) by mail.esilo.com (8.13.1/8.13.1) with ESMTP id m8H30oeu005610; Tue, 16 Sep 2008 23:00:50 -0400 Message-ID: <48D072E3.6010703@esilo.com> Date: Tue, 16 Sep 2008 23:00:51 -0400 From: Andrew Chernow User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Tom Lane CC: Alvaro Herrera , PostgreSQL-development , Merlin Moncure Subject: Re: [PATCHES] libpq events patch (with sgml docs) References: <48C18533.2000204@esilo.com> <20080905192215.GK4353@alvh.no-ip.org> <48C18B48.509@esilo.com> <20080905194853.GL4353@alvh.no-ip.org> <48C191A7.3000205@esilo.com> <20080905201504.GM4353@alvh.no-ip.org> <48C19759.90402@esilo.com> <27615.1221619326@sss.pgh.pa.us> In-Reply-To: <27615.1221619326@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-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/1073 X-Sequence-Number: 124202 Tom Lane wrote: > Andrew Chernow writes: >> Missed that one. Good catch :) Update attached. > > Looking at this now. Question: why does PQgetResult invoke the > RESULTCREATE event only for non-error results? It didn't seem useful to have the eventproc implementation allocate its private storage (or do whatever prep work it does), just to have it PQclear'd once the user gets the dead result back. I guess we figured an error result typically has a short life-span, not very useful outside of indicating an error. Is there a use case you think requires the opposite behavior? > odd asymmetry, particularly in view of the fact that a RESULTDESTROY > event will occur for error results. And surely we do not need to > micro-optimize error cases for speed. > It is odd. Actually, it looks like a bug to me. PQgetResult is the behavior we were after, don't trigger the event if the creation failed. Same thing occurs during a conn reset. Looks like PQclear needs to check resultStatus before it triggers RESULTDESTROY events. But before I fix this and put a patch up, please let me know if you prefer the opposite behavior ... trigger events on success or failure (including connreset). -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/