pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: vegard.bones@met.no
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple
Date: Mon, 14 Feb 2011 11:39:07 -0500
Message-ID: <25635.1297701547@sss.pgh.pa.us> (raw)
In-Reply-To: <201102141140.p1EBeeG8060816@wwwmaster.postgresql.org>
References: <201102141140.p1EBeeG8060816@wwwmaster.postgresql.org>

"" <vegard.bones@met.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



view thread (5+ messages)  latest in thread

Message-ID: <25635.1297701547@sss.pgh.pa.us>
Permalink:  ../25635.1297701547@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25635.1297701547@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, vegard.bones@met.no
  Subject: Re: BUG #5883: Error when mixing SPI_returntuple with returning regular HeapTuple
  In-Reply-To: <25635.1297701547@sss.pgh.pa.us>
  References: <201102141140.p1EBeeG8060816@wwwmaster.postgresql.org> <25635.1297701547@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