Re: SPI_connect problems

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joonas Makkonen" <joonas(dot)makkonen(at)infosto(dot)fi>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: SPI_connect problems
Date: 2000-08-22 14:32:28
Message-ID: 5776.966954748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

"Joonas Makkonen" <joonas(dot)makkonen(at)infosto(dot)fi> writes:
> I have a trigger function written in C that uses SPI to fetch certain data
> from the db. The problem is that about 20% of the time SPI_connect()
> returns:

> NOTICE: SPI_connect() failed in RI_FKey_check()

> Any ideas what might be causing this?

It looks like you have some referential integrity triggers in your
database that are getting fired during the query you execute from your
SPI call. The RI triggers also use SPI. Recursive entry to SPI is
supposed to work, but evidently SPI_connect() isn't happy. After a
quick look at the code (see src/backend/executor/spi.c) it seems the
only way that could happen is if there's a mismatch of SPI_push and
SPI_pop operations, leaving _SPI_curid pointing at the wrong stack
level. This might be your error, or it might be a bug in the RI
trigger code or in SPI itself. I'd suggest tracing through the
SPI operations (use a debugger, or insert printf()s) until you
understand what's happening.

BTW, the RI code is in src/backend/utils/adt/ri_triggers.c

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message John Thorhauer 2000-08-22 14:34:03 odbc blob
Previous Message Alex Drobyish 2000-08-22 13:50:12 ODBC driver fails to change float/numeric fields