Re: PL/pgSQL, RAISE and error context

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Joel Jacobson <joel(at)trustly(dot)com>, Fabrízio Mello <fabriziomello(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>
Subject: Re: PL/pgSQL, RAISE and error context
Date: 2015-04-30 10:03:48
Message-ID: CAFj8pRCTRHS-o_+9Py3UJ8CjAQhD-x=jt-afnOEcbPuS=SkDdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-04-30 10:50 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:

>
>
> 2015-04-30 10:24 GMT+02:00 Marko Tiikkaja <marko(at)joh(dot)to>:
>
>> Hi Pavel,
>>
>> This doesn't seem to be what I thought we had agreed on. For example:
>>
>> =# create function barf() returns void as $$ begin raise notice without
>> context 'hello world'; end $$ language plpgsql;
>> CREATE FUNCTION
>> =# create function foof() returns void as $$ begin perform barf(); end $$
>> language plpgsql;
>> CREATE FUNCTION
>> =# select foof();
>> NOTICE: hello world
>> CONTEXT: SQL statement "SELECT barf()"
>> PL/pgSQL function foof() line 1 at PERFORM
>>
>> It's not only clear that WITHOUT CONTEXT didn't really work here, but it
>> also had absolutely no effect since the context within barf() is also
>> displayed.
>>
>
> It doesn't look well - because it should be solve by errhidecontext(true)
>
> yes, there is a issue in send_message_to_frontend - this ignore
> edata->hide_ctx field. After fixing, it working as expected - so this is a
> bug in implementation of errhidecontext()
>
> should be
>
> if (edata->context && !edata->hide_ctx)
> {
> pq_sendbyte(&msgbuf, PG_DIAG_CONTEXT);
> err_sendstring(&msgbuf, edata->context);
> }
>
> and probably getting stack in err_finish should be fixed too:
>
> if (!edata->hide_ctx)
> for (econtext = error_context_stack;
> econtext != NULL;
> econtext = econtext->previous)
> (*econtext->callback) (econtext->arg);
>
> Regards
>
> Pavel
>
>
I am sending patch

>
>
> I'll look on this issue.
>
> Regards
>
> Pavel
>
>
>>
>>
>> .m
>>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2015-04-30 10:05:44 Re: Auditing extension for PostgreSQL (Take 2)
Previous Message Pavel Stehule 2015-04-30 08:50:56 Re: PL/pgSQL, RAISE and error context