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

From Marko Tiikkaja
Subject PL/pgSQL, RAISE and error context
Date
Msg-id 5214B268.3070303@joh.to
Whole thread Raw
Responses Re: PL/pgSQL, RAISE and error context
Re: PL/pgSQL, RAISE and error context
Re: PL/pgSQL, RAISE and error context
List pgsql-hackers
Hi,

By default, PL/pgSQL does not print the error context of a RAISE 
statement, for example:

=# create function foof() returns void as $$ begin raise exception 
'foo'; end $$ language plpgsql;
CREATE FUNCTION

=# create function bar() returns void as $$ begin perform foof(); end $$ 
language plpgsql;
CREATE FUNCTION

=# select bar();
ERROR:  foo
CONTEXT:  SQL statement "SELECT foof()"
PL/pgSQL function "bar" line 1 at PERFORM


I find this extremely surprising, since if you raise the same exception 
(or a DEBUG/NOTICE message) in multiple places, the error context is 
missing valuable information.  With a trivial change the last error 
could be:

=# select bar();
ERROR:  foo
CONTEXT:  PL/pgSQL function "foof" line 1 RAISE
SQL statement "SELECT foof()"
PL/pgSQL function "bar" line 1 at PERFORM

which I find a lot better.

Thoughts?


Regards,
Marko Tiikkaja



pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: CAST Within EXCLUSION constraint
Next
From: Stephen Frost
Date:
Subject: Re: Back-patch change in hashed DISTINCT estimation?