From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | David Gardner <dgardner(at)creatureshop(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #5232: plpythonu s=s.op() raises an exception |
Date: | 2009-12-03 23:57:10 |
Message-ID: | 1259884630.30348.3.camel@vanquo.pezone.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On tor, 2009-12-03 at 14:46 -0800, David Gardner wrote:
> Not sure about the try block being related, I included it in my
> example mostly because the example is a simplified version of some
> code I was working on that had a try/except block.
> I tried the function without the try block and it raised the same
> exception (just uncaught):
>
> CREATE OR REPLACE FUNCTION pyreplacenotry(src text, s text)
> RETURNS text AS
> $BODY$
> src=src.replace(s,'')
> return src
> $BODY$
> LANGUAGE 'plpythonu' VOLATILE
> COST 100;
> ALTER FUNCTION pyreplacenotry(text, text) OWNER TO dgardner;
>
> gives me:
> ERROR: PL/Python: PL/Python function "pyreplacenotry" failed
> DETAIL: <type 'exceptions.UnboundLocalError'>: local variable 'src'
> referenced before assignment
What is going on internally is something like this:
src = 'xyz'
def pyreplacenotry():
src=src.replace('x', 'y')
return src
pyreplacenotry()
which fails with that same error. So you should not try to assign to
the parameters of a function.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-12-04 00:02:31 | Re: BUG #5232: plpythonu s=s.op() raises an exception |
Previous Message | David Gardner | 2009-12-03 22:46:31 | Re: BUG #5232: plpythonu s=s.op() raises an exception |