Get rid of the global variable holding the error state

Global error handling led to confusion and was hard to manage.  With
this change, errors from PostgreSQL are immediately reported to Python
as exceptions.  This requires setting a Python exception after
reporting the caught PostgreSQL error as a warning, because PLy_elog
destroys the Python exception state.

Ideally, all places where PostgreSQL errors need to be reported back
to Python should be wrapped in subtransactions, to make going back to
Python from a longjmp safe.  This will be handled in a separate patch.

Jan Urbański
This commit is contained in:
Peter Eisentraut
2011-01-22 22:08:51 +02:00
parent 37eb2cd4ad
commit 116ce2f4d0
3 changed files with 115 additions and 75 deletions

View File

@ -73,5 +73,5 @@ NOTICE: notice
CONTEXT: PL/Python function "elog_test"
WARNING: warning
CONTEXT: PL/Python function "elog_test"
ERROR: error
ERROR: PL/Python: plpy.Error: error
CONTEXT: PL/Python function "elog_test"