Re: pl/pythonu

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: C G <csgcsg39(at)hotmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: pl/pythonu
Date: 2004-02-11 18:19:51
Message-ID: Pine.LNX.4.33.0402111119080.343-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 11 Feb 2004, 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;
> >
> >Perhaps the plpy.execute is inserting into the same table as the trigger
> >is on? If that's the case, then the trigger will be recursively called
> >over and over until the "maximum recursion depth" is "exceeded".
>
> Yes, that is what is happening. My question is now, if I have a trigger on
> table t1, how should I write my function to insert 'blah' into my table when
> it is triggered?

You're likely looking for the new/old row set thing. I'm not sure how the
struct is put together in plpython. It holds the old row before the
insert, and the new row, which your trigger will actually insert in its
place.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2004-02-11 18:25:06 Re: DB cache size strategies
Previous Message Jim C. Nasby 2004-02-11 18:16:34 Re: sybase->postgresql