On Fri, Sep 23, 2005 at 05:03:02PM -0400, Bruce Momjian wrote:
> Michael Fuhr wrote:
> > http://archives.postgresql.org/pgsql-patches/2005-06/msg00519.php
>
> I have backpatched this to 8.0.X. It did not apply cleanly to 7.4.X so
> if you would like that version patched please submit a matching patch.
> Thanks. (I don't trust myself to adjust the patch for 7.4.X.)
Here's a patch for 7.4. I had to s/PLy_curr_procedure/PLy_last_procedure/
because 7.4 uses the latter where 8.x uses the former.
How far back do you want to backpatch? 7.3? 7.2? The patch is
pretty simple so I could make patches for older versions if necessary.
--
Michael Fuhr
Index: src/pl/plpython/plpython.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/pl/plpython/plpython.c,v
retrieving revision 1.41.2.1
diff -c -r1.41.2.1 plpython.c
*** src/pl/plpython/plpython.c 4 Jan 2004 00:14:55 -0000 1.41.2.1
--- src/pl/plpython/plpython.c 24 Sep 2005 02:47:38 -0000
***************
*** 561,566 ****
--- 561,568 ----
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,852 ****
--- 849,856 ----
{
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,2123 ****
char *sv;
PyObject *so = PyObject_Str(list);
!
sv = PyString_AsString(so);
PLy_exception_set(PLy_exc_spi_error,
"Expected sequence of %d
arguments, got %d. %s",
--- 2121,2129 ----
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,2171 ****
--- 2172,2180 ----
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,2699 ****
else
vstr = "Unknown";
! estr = PyString_AsString(eob);
xstr = PLy_printf("%s: %s", estr, vstr);
Py_DECREF(eob);
--- 2702,2714 ----
else
vstr = "Unknown";
! /*
! * 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);
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster