aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pl/plpython/plpython.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 332927013a5..80b60a4777f 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.41.2.1 2004/01/04 00:14:55 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.41.2.2 2005/09/25 03:18:16 momjian Exp $
*
*********************************************************************
*/
@@ -561,6 +561,8 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
if (plval != Py_None && !tupdesc->attrs[atti]->attisdropped)
{
plstr = PyObject_Str(plval);
+ if (!plstr)
+ PLy_elog(ERROR, "function \"%s\" could not modify tuple", proc->proname);
src = PyString_AsString(plstr);
modvalues[i] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc,
@@ -847,6 +849,8 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
{
fcinfo->isnull = false;
plrv_so = PyObject_Str(plrv);
+ if (!plrv_so)
+ PLy_elog(ERROR, "function \"%s\" could not create return value", proc->proname);
plrv_sc = PyString_AsString(plrv_so);
rv = FunctionCall3(&proc->result.out.d.typfunc,
PointerGetDatum(plrv_sc),
@@ -2117,7 +2121,9 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
char *sv;
PyObject *so = PyObject_Str(list);
-
+ if (!so)
+ PLy_elog(ERROR, "function \"%s\" could not execute plan",
+ PLy_procedure_name(PLy_last_procedure));
sv = PyString_AsString(so);
PLy_exception_set(PLy_exc_spi_error,
"Expected sequence of %d arguments, got %d. %s",
@@ -2166,6 +2172,9 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
if (elem != Py_None)
{
so = PyObject_Str(elem);
+ if (!so)
+ PLy_elog(ERROR, "function \"%s\" could not execute plan",
+ PLy_procedure_name(PLy_last_procedure));
sv = PyString_AsString(so);
/*
@@ -2693,7 +2702,13 @@ PLy_traceback(int *xlevel)
else
vstr = "Unknown";
- estr = PyString_AsString(eob);
+ /*
+ * I'm not sure what to do if eob is NULL here -- we can't call
+ * PLy_elog because that function calls us, so we could end up
+ * with infinite recursion. I'm not even sure if eob could be
+ * NULL here -- would an Assert() be more appropriate?
+ */
+ estr = eob ? PyString_AsString(eob) : "Unknown Exception";
xstr = PLy_printf("%s: %s", estr, vstr);
Py_DECREF(eob);