Re: dblink memory leak - Mailing list pgsql-hackers

From Tom Lane
Subject Re: dblink memory leak
Date
Msg-id 17818.1254711182@sss.pgh.pa.us
Whole thread Raw
In response to dblink memory leak  (Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: dblink memory leak  (Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
List pgsql-hackers
Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:
> Joe Conway <mail@joeconway.com> wrote:
>> Please see if this works for you.

> It does not work because errors can occur in caller of dblink functions;
> Error callback should be still registered after SRF_RETURN_NEXT, so we
> cannot place callback context on stack of the function. More works needed.

Yeah, I meant to comment on that: it's an abuse of the error context
mechanism and will never be safe.  (An example is that if someone
innocently did an elog(LOG) or something like that, the callback would
get triggered.)  The global PGresult value seems awfully dangerous too.

I think what you want to do instead is use PG_TRY blocks to ensure that
transient results are cleaned up.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Rules: A Modest Proposal
Next
From: Itagaki Takahiro
Date:
Subject: Re: dblink memory leak