Skip site navigation (1) Skip section navigation (2)

Recursion and SPI

From: Ian Lance Taylor <ian(at)airs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Recursion and SPI
Date: 2001-01-05 19:39:16
Message-ID: 20010105193916.614.qmail@daffy.airs.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Does the SPI interface support recursion?  That is, can a function
use SPI to make a query which involves calling another function which
uses SPI?

The documentation suggests not, saying that if a function which uses
SPI calls another function which uses SPI, it won't work, and calling
that ``bad practice.''

However, in spi.c I note that there is a stack, and a variable
_SPI_curid, and the undocumented functions SPI_push and SPI_pop.  If
that works to support recursion, then why does the documentation
recommend against it?


Are there any restrictions on when SPI_connect may be called?  The
executor can presumably call a function at any time during the
execution of a plan if the function is used in a WHERE clause.  If
that function turns around and calls the executor via SPI, are there
any possibilities for deadlock?

Ian

Responses

pgsql-hackers by date

Next:From: Dave VanAukenDate: 2001-01-05 20:08:57
Subject: RE: running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2
Previous:From: Tom LaneDate: 2001-01-05 19:14:29
Subject: Re: Well, we seem to be proof against cache-inval problems now

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group