From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joonas Makkonen <joonas.makkonen@infosto.fi>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: SPI_connect problems
Date: Tue, 22 Aug 2000 10:32:28 -0400
Message-ID: <5776.966954748@sss.pgh.pa.us> (raw)
In-Reply-To: <024201c00c17$d5f66610$e62689c2@infosto.fi>
References: <024201c00c17$d5f66610$e62689c2@infosto.fi>
"Joonas Makkonen" <joonas.makkonen@infosto.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, joonas.makkonen@infosto.fi
Subject: Re: SPI_connect problems
In-Reply-To: <5776.966954748@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox