From: | "Mikheev, Vadim" <vmikheev(at)SECTORBASE(dot)COM> |
---|---|
To: | "'Ian Lance Taylor'" <ian(at)airs(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | RE: Recursion and SPI |
Date: | 2001-01-05 20:44:17 |
Message-ID: | 8F4C99C66D04D4118F580090272A7A234D322A@sectorbase1.sectorbase.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
> 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?
From http://www.postgresql.org/docs/programmer/spi.htm :
"SPI procedures are always called by some (upper) Executor and the SPI
manager
uses the Executor to run your queries. Other procedures may be called by the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Executor running queries from your procedure."
> 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.''
From http://www.postgresql.org/docs/programmer/spi-spiconnect.htm :
"You may get SPI_ERROR_CONNECT error if SPI_connect is called from an
already
connected procedure - e.g. if you *directly call* one procedure from another
^^^^^^^^^^^^^^^
connected one. Actually, while the child procedure will be able to use SPI,
your parent procedure will not be able to continue to use SPI after the
child
returns (if SPI_finish is called by the child). It's bad practice."
But you are able to run queries which call SPI functions.
> 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?
Afair, there were no SPI_push & SPI_pop originally. Someone added them
but forgot to document.
Vadim
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Lance Taylor | 2001-01-05 22:13:27 | Re: Recursion and SPI |
Previous Message | Alex Pilosov | 2001-01-05 20:37:30 | SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) |
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Lance Taylor | 2001-01-05 22:13:27 | Re: Recursion and SPI |
Previous Message | Alex Perel | 2001-01-05 19:01:09 | \du in psql patch |