plpython: fix for improperly handled NULL arguments in prepared plans

From: Andrew Bosma <bosma(at)epigenomix(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: plpython: fix for improperly handled NULL arguments in prepared plans
Date: 2003-01-29 00:16:07
Message-ID: 1043799367.6563.120.camel@dendroica
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


The attached patch fixes a bug reported by Kevin Jacobs

> When we create a function like so:
>
> CREATE OR REPLACE FUNCTION jojo (timestamp) RETURNS varchar AS '
> pln = plpy.prepare("UPDATE jtab SET jfld = $1",["timestamp"])
> rcs = plpy.execute(pln,[args[0]])
> return "YES"' LANGUAGE 'PLPYTHON';
>
> SELECT jojo(now());
> works fine but
>
> SELECT jojo(NULL);
> errors out with
> NOTICE: plpython: in function __plpython_procedure_jojo_49818349:
> plpy.Error: Unknown error in PLy_spi_execute_plan
> ERROR: Bad timestamp external representation 'None'

NULL arguments were improperly converted to the string 'None' rather than being marked
as NULLs in the third argument to SPI_execp. The patch is against CVS HEAD.

--
Andrew Bosma <bosma(at)epigenomix(dot)com>

Attachment Content-Type Size
plpython_execp_nulls.diff text/x-patch 2.0 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Marc G. Fournier 2003-01-30 02:00:03 v7.2.4 bundled ...
Previous Message Peter Eisentraut 2003-01-28 21:58:31 Re: minor doc / usage fixes