Re: pl/pythonu

Поиск
Список
Период
Сортировка
От Mike Mascari
Тема Re: pl/pythonu
Дата
Msg-id 402A5F8C.8040104@mascari.com
обсуждение исходный текст
Ответ на pl/pythonu  ("C G" <csgcsg39@hotmail.com>)
Список pgsql-general
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











В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: DB cache size strategies
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: sybase->postgresql