PL/Python: No stack trace for an exception

Started by Sushant Sinhaalmost 15 years ago4 messageshackers
Jump to latest
#1Sushant Sinha
sushant354@gmail.com

I am using plpythonu on postgres 9.0.2. One of my python functions was
throwing a TypeError exception. However, I only see the exception in the
database and not the stack trace. It becomes difficult to debug if the
stack trace is absent in Python.

logdb=# select get_words(forminput) from fi;
ERROR: PL/Python: TypeError: an integer is required
CONTEXT: PL/Python function "get_words"

And here is the error if I run that function on the same data in python:

Traceback (most recent call last):
File "valid.py", line 215, in <module>
parse_query(result['forminput'])
File "valid.py", line 132, in parse_query
dateobj = datestr_to_obj(columnHash[column])
File "valid.py", line 37, in datestr_to_obj
dateobj = datetime.date(words[2], words[1], words[0])
TypeError: an integer is required

Is this a known problem or this needs addressing?

Thanks,
Sushant.

#2Jan Urbański
wulczer@wulczer.org
In reply to: Sushant Sinha (#1)
Re: PL/Python: No stack trace for an exception

On 21/07/11 15:27, Sushant Sinha wrote:

I am using plpythonu on postgres 9.0.2. One of my python functions was
throwing a TypeError exception. However, I only see the exception in the
database and not the stack trace. It becomes difficult to debug if the
stack trace is absent in Python.

logdb=# select get_words(forminput) from fi;
ERROR: PL/Python: TypeError: an integer is required
CONTEXT: PL/Python function "get_words"

And here is the error if I run that function on the same data in python:

[traceback]

Is this a known problem or this needs addressing?

Yes, traceback support in PL/Python has already been implemented and is
a new feature that will be available in PostgreSQL 9.1.

Cheers,
Jan

In reply to: Sushant Sinha (#1)
Re: PL/Python: No stack trace for an exception

On 21 July 2011 14:27, Sushant Sinha <sushant354@gmail.com> wrote:

I am using plpythonu on postgres 9.0.2. One of my python functions was
throwing a TypeError exception. However, I only see the exception in the
database and not the stack trace. It becomes difficult to debug if the
stack trace is absent in Python.

logdb=# select get_words(forminput) from fi;
ERROR:  PL/Python: TypeError: an integer is required
CONTEXT:  PL/Python function "get_words"

And here is the error if I run that function on the same data in python:

Traceback (most recent call last):
 File "valid.py", line 215, in <module>
   parse_query(result['forminput'])
 File "valid.py", line 132, in parse_query
   dateobj = datestr_to_obj(columnHash[column])
 File "valid.py", line 37, in datestr_to_obj
   dateobj = datetime.date(words[2], words[1], words[0])
TypeError: an integer is required

Is this a known problem or this needs addressing?

Traceback information will be added to PL/Python errors in Postgres
9.1, due out in about September.

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

#4Sushant Sinha
sushant354@gmail.com
In reply to: Jan Urbański (#2)
Re: PL/Python: No stack trace for an exception

On Thu, 2011-07-21 at 15:31 +0200, Jan Urbański wrote:

On 21/07/11 15:27, Sushant Sinha wrote:

I am using plpythonu on postgres 9.0.2. One of my python functions was
throwing a TypeError exception. However, I only see the exception in the
database and not the stack trace. It becomes difficult to debug if the
stack trace is absent in Python.

logdb=# select get_words(forminput) from fi;
ERROR: PL/Python: TypeError: an integer is required
CONTEXT: PL/Python function "get_words"

And here is the error if I run that function on the same data in python:

[traceback]

Is this a known problem or this needs addressing?

Yes, traceback support in PL/Python has already been implemented and is
a new feature that will be available in PostgreSQL 9.1.

Cheers,
Jan

Thanks Jan! Just one more reason to try 9.1.