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

Re: BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "" <vegard(dot)bones(at)met(dot)no>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple
Date: 2011-02-14 16:39:07
Message-ID: 25635.1297701547@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"" <vegard(dot)bones(at)met(dot)no> writes:
> When creating a server-side C function, things go wrong when I (in the same
> function) return some results via SPI_returntuple, and other results by
> manually creating HeapTuples. This applies even if the source for both
> returns are the same data in the same table. 

I think the part of this example that doesn't work is returning from the
function without having exited your SPI context.  If you need to produce
multiple rows from a single SPI query, the best solution is to collect
them all during a single call and return them in a tuplestore.  You can
*not* return without having called SPI_finish to balance your
SPI_connect.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Pavel StehuleDate: 2011-02-14 17:43:47
Subject: Re: BUG #5884: i cant select entire array values
Previous:From: Kevin GrittnerDate: 2011-02-14 15:55:33
Subject: Re: BUG #5884: i cant select entire array values

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