From: | "David Gardner" <dgardner(at)creatureshop(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #5232: plpythonu s=s.op() raises an exception |
Date: | 2009-12-03 20:06:59 |
Message-ID: | 200912032006.nB3K6xEV074074@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 5232
Logged by: David Gardner
Email address: dgardner(at)creatureshop(dot)com
PostgreSQL version: 8.4.1
Operating system: Debian, amd64
Description: plpythonu s=s.op() raises an exception
Details:
If I create the following:
CREATE OR REPLACE FUNCTION pyreplace(src text,s text)
RETURNS text AS
$BODY$
try:
src=src.replace(s,'')
return src
except Exception,e:
return str(e)
$BODY$
LANGUAGE 'plpythonu' VOLATILE
COST 100;
ALTER FUNCTION pyreplace(src text,s text) OWNER TO dgardner;
Then:
SELECT * FROM pyreplace('this is a very long string','is');
pyreplace
---------------------------------------------------
local variable 'src' referenced before assignment
(1 row)
However in python I can do:
def pyreplace(src,s):
try:
src=src.replace(s,'')
return src
except Exception,e:
return str(e)
pyreplace('this is a very long string','is')
-----
produces:
'th a very long string'
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2009-12-03 20:20:48 | Re: Assertion failure with a subtransaction and cursor |
Previous Message | Alvaro Herrera | 2009-12-03 17:49:51 | Re: BUG #5231: SELECT DISTINCT poorly implemented vs SELECT ... GROUP BY |