The following bug has been logged on the website:
Bug reference: 13683
Logged by: Andrey Chernyakov
Email address: a.n.d@inbox.ru
PostgreSQL version: 9.4.1
Operating system: RHEL 6.3
Description:
Exception "could not compile PL/Python function" on "create or replace
function ... language plpythonu" after recursive call plpython function.
Example:
[andrey@devbase ~]$ psql
psql (9.4.1)
Type "help" for help.
postgres=# create or replace function a(i integer) returns integer as
postgres-# $$
postgres$# if i > 42:
postgres$# return i
postgres$# return plpy.execute("select a(%s)" % (i+1))[0]['a']
postgres$# $$ language plpythonu;
CREATE FUNCTION
postgres=#
postgres=# select a(0);
a
----
43
(1 row)
postgres=# create or replace function b() returns void as
postgres-# $$
postgres$# pass
postgres$# $$ language plpythonu;
ERROR: could not compile PL/Python function "b"
DETAIL: KeyError: 'i'
I am using plpython with python2.7