Re: pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-committers(at)postgresql(dot)org" <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL
Date: 2013-07-25 18:02:30
Message-ID: CAFj8pRBqC6OL09tBgDGYXJ0aJNq2Y+NCSrQqc+1B9xSb7Zwo-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

2013/7/25 Stephen Frost <sfrost(at)snowman(dot)net>:
> Pavel,
>
> First, please only quote the relevant parts of the email when
> responding.
>
> * Pavel Stehule (pavel(dot)stehule(at)gmail(dot)com) wrote:
>> I used a ErrorContext because I wasn't sure so errcontext and similar
>> function can work in different context. Now I look there and there
>> should be well initialized ErrorDataStack, due
>>
>> int
>> set_errcontext_domain(const char *domain)
>> {
>> <------>ErrorData *edata = &errordata[errordata_stack_depth];
>>
>> <------>/* we don't bother incrementing recursion_depth */
>> <------>CHECK_STACK_DEPTH();
>>
>> <------>edata->context_domain = domain;
>>
>> <------>return 0;
>> }
>>
>> but MemoryContext can be any - so probably some private context is ideal.
>
> While set_errcontext_domain() doesn't care about the MemoryContext, per
> se, the errcontext() macro further calls errcontext_msg() which is
> currently set up to explicitly use ErrorContext. Perhaps an elog.c
> global to tell errcontext_msg() to not switch memory contexts, but what
> happens if there's an error thrown by a callback function..?

Probably then will be raised a panic due recursion call of error API

Our PL doesn't raise a exception in callback function explicitly.
Probably there is risk - "out of memory" - but same risk is when you
call errcontext inside elog function.

Pavel

>
> Thanks,
>
> Stephen

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Stephen Frost 2013-07-25 18:04:40 Re: pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL
Previous Message Tom Lane 2013-07-25 17:56:56 Re: pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2013-07-25 18:04:40 Re: pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL
Previous Message Tom Lane 2013-07-25 17:56:56 Re: pgsql: Add GET DIAGNOSTICS ... PG_CONTEXT in PL/PgSQL