Re: [PATCHES] libpq events patch (with sgml docs)

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Merlin Moncure <mmoncure(at)gmail(dot)com>
Subject: Re: [PATCHES] libpq events patch (with sgml docs)
Date: 2008-09-17 03:00:51
Message-ID: 48D072E3.6010703@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Andrew Chernow <ac(at)esilo(dot)com> 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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2008-09-17 03:14:31 Re: Common Table Expressions (WITH RECURSIVE) patch
Previous Message Tom Lane 2008-09-17 02:42:06 Re: [PATCHES] libpq events patch (with sgml docs)

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-09-17 03:40:17 Re: [PATCHES] libpq events patch (with sgml docs)
Previous Message Tom Lane 2008-09-17 02:42:06 Re: [PATCHES] libpq events patch (with sgml docs)