pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <JanWieck@Yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgreSQL.org
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: Error-message infrastructure: what about location in PL functions?
Date: Mon, 31 Mar 2003 11:57:05 -0500
Message-ID: <3E887361.2AA6BFFE@Yahoo.com> (raw)
References: <6819.1047919215@sss.pgh.pa.us>

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@Yahoo.com #




view thread (2+ messages)

Message-ID: <3E887361.2AA6BFFE@Yahoo.com>
Permalink:  ../3E887361.2AA6BFFE@Yahoo.com/
Also on:    postgresql.org/message-id/3E887361.2AA6BFFE@Yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: JanWieck@Yahoo.com, tgl@sss.pgh.pa.us, pgsql-hackers@postgreSQL.org
  Subject: Re: Error-message infrastructure: what about location in PL functions?
  In-Reply-To: <3E887361.2AA6BFFE@Yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox