On Thu, Jan 13, 2011 at 06:57, Julien Demoor <jdem...@gmail.com> wrote:
>
> The following bug has been logged online:
>
> Bug reference:      5835
> Logged by:          Julien Demoor
> Email address:      jdem...@gmail.com
> PostgreSQL version: 9.0.2
> Operating system:   Ubuntu Linux
> Description:        PL/Python crashes
> Details:

> BEGIN;
> CREATE OR REPLACE FUNCTION test_none_3(a numeric[]) RETURNS numeric(12,4) AS
> $$
>    return 1;
> $$ LANGUAGE plpython2u;
> SELECT test_none_3('{NULL, NULL, NULL}'::numeric[]) FROM
> generate_series(1,244) ORDER BY generate_series DESC LIMIT 1;
> ROLLBACK;

It looks like we are not incrementing a reference count for NULL
entries in an array.  The attached fixes it for me.  I did look for
other places where we might have missed this and did not find any.  (
the PyDict_SetItemString() that use Py_None look fishy, but apparently
work ).

Can you see if it fixes it for you?
*** a/src/pl/plpython/plpython.c
--- b/src/pl/plpython/plpython.c
***************
*** 2043,2049 **** PLyList_FromArray(PLyDatumToOb *arg, Datum d)
--- 2043,2052 ----
  						 elm->typlen, elm->typbyval, elm->typalign,
  						 &isnull);
  		if (isnull)
+ 		{
+ 			Py_INCREF(Py_None);
  			PyList_SET_ITEM(list, i, Py_None);
+ 		}
  		else
  			PyList_SET_ITEM(list, i, elm->func(elm, elem));
  	}
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to