Re: PL/pgSQL, RAISE and error context - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: PL/pgSQL, RAISE and error context
Date
Msg-id CAFj8pRCTRHS-o_+9Py3UJ8CjAQhD-x=jt-afnOEcbPuS=SkDdQ@mail.gmail.com
Whole thread Raw
In response to Re: PL/pgSQL, RAISE and error context  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers


2015-04-30 10:50 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:


2015-04-30 10:24 GMT+02:00 Marko Tiikkaja <marko@joh.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


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: PL/pgSQL, RAISE and error context
Next
From: Fujii Masao
Date:
Subject: Re: Auditing extension for PostgreSQL (Take 2)