C G wrote:

Dear All,

Could anyone explain why this function does will not work? The error message is
DETAIL: exceptions.RuntimeError: maximum recursion depth exceeded.


CREATE FUNCTION testing() RETURNS trigger AS'

plan=plpy.prepare(''INSERT INTO t1 values ($1)'',[''text''])
plpy.execute(plan,[''blah''])
return ''MODIFY''

'LANGUAGE plpythonu;


Do you have a trigger on 't1' which invokes testing()?

Mike Mascari

I do have a trigger on t1. The function loads into the database OK, but when I insert anything into the database I get the error, relating to the function.

I don't see anything that will stop the recursion:


a) You insert into t1
b) testing() gets invoked
c) testing inserts into t1
d) testing() gets invoked
e) testing inserts into t1
f) testing() gets invoked

..etc..

If all you are trying to do is modify the value that gets inserted into t1 when an INSERT occurs, just modify the TD[''new''] record:

CREATE FUNCTION testing() RETURNS trigger AS '

TD[''new''][''field1''] = ''foo''
return ''MODIFY''

' LANGUAGE plpythonu;

where 'field1' is the field to be modified and 'foo' is the value.

HTH,

Mike Mascari











---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to