Re: Error-message infrastructure: what about location in PL functions?

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org, pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: Error-message infrastructure: what about location in PL functions?
Date: 2003-03-31 16:57:05
Message-ID: 3E887361.2AA6BFFE@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces

Tom Lane wrote:
>
> I thought of something I'd overlooked in my original proposal for error-
> handling upgrades: what about reporting where an error occurs in a PL
> function?
>
> Currently, plpgsql has a hack that prints a separate WARNING giving
> the error location, but this is pretty darn ugly. It should be part of
> the error report message to begin with.
>
> I can see how to create a mechanism that gathers the data (details below
> if you care), but I'm not too sure how it should be reported to the
> client --- ie, what's the protocol message?
>
> This seems nonobvious because (a) the appropriate info might vary
> depending on the PL language involved, and (b) when there are several
> nested PL functions, we probably want to include the whole stack trace.
>
> Here is an example of what you get right now:
>
> regression=# create function foo (int, int) returns int as '
> regression'# begin
> regression'# return $1 / $2;
> regression'# end' language plpgsql;
> CREATE FUNCTION
> regression=# select foo(10,0);
> WARNING: Error occurred while executing PL/pgSQL function foo
> WARNING: line 2 at return
> ERROR: division by zero
> regression=# create function bar (int, int) returns int as '
> regression'# begin
> regression'# return foo($1,$2);
> regression'# end' language plpgsql;
> CREATE FUNCTION
> regression=# select bar(10,0);
> WARNING: Error occurred while executing PL/pgSQL function foo
> WARNING: line 2 at return
> ERROR: division by zero
> regression=#
>
> Note the lack of any info about bar() in the second case --- this seems
> like a bad omission.
>
> I am visualizing some display on the order of
>
> ERROR: division by zero
> WHERE: PL/pgSQL function foo, line 2 at return
> WHERE: PL/pgSQL function bar, line 2 at return

That omission is by me and I did it to lower the confusion a bit. If you
prefer a complete stack backtrace in your log (alas Tcl), I certainly
can live with that.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Wieck 2003-03-31 17:14:10 Re: inquiery
Previous Message Hannu Krosing 2003-03-31 16:56:54 Re: PostgreSQL and SOAP, suggestions?

Browse pgsql-interfaces by date

  From Date Subject
Next Message John Huttley 2003-03-31 22:16:46 Oracle Porting, Compiere
Previous Message Adam Witney 2003-03-31 09:28:38 Re: Release of DBD-pg 1.22