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 08:50:56
Message-ID: CAFj8pRBTBffPhyupq462UX8VC8=UewSKn0407UPEu9OCSCjTOA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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'll look on this issue.

Regards

Pavel

>
>
> .m
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-04-30 10:03:48 Re: PL/pgSQL, RAISE and error context
Previous Message Marko Tiikkaja 2015-04-30 08:24:42 Re: PL/pgSQL, RAISE and error context