Re: Memory context in exception handler - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Memory context in exception handler
Date
Msg-id 28302.1168733692@sss.pgh.pa.us
Whole thread Raw
In response to Memory context in exception handler  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Memory context in exception handler
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> But this fails because CopyErrorData() complains by way of assertion 
> that we're still in ErrorContext.  A nearby comment suggests to switch 
> away to another context to preserve the data across FlushErrorState(), 
> but that doesn't seem necessary in this situation.  Are there other 
> reasons why this rule is so rigorously enforced?

I think it's a good error check because if you are trying to make a copy
of the current error data, doing so within the ErrorContext seems highly
unlikely to be safe.

As near as I can tell, you're using CopyErrorData not because you need
an actual copy but just because elog.c doesn't export any other API to
let you see the current sqlerrorcode.  Perhaps adding a function to
return the top stack entry's sqlerrorcode would be a better API change?
(I'm a bit uncomfortable with handing out direct access to the struct,
but getting a peek at sqlerrorcode or other scalar values seems safe
enough.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: elein
Date:
Subject: Re: [GENERAL] Autovacuum Improvements
Next
From: Tom Lane
Date:
Subject: Re: [PERFORM] Performance of Parser?