RE: Re: function crashes backend - Mailing list pgsql-hackers

From Mikheev, Vadim
Subject RE: Re: function crashes backend
Date
Msg-id 8F4C99C66D04D4118F580090272A7A23018D1C@SECTORBASE1
Whole thread Raw
In response to function crashes backend  (Louis-David Mitterrand <cunctator@apartia.ch>)
List pgsql-hackers
> Following up to myself, I finally understood my problem: I 
> was trying to
> re-use SPI_tuptable->vals[i] after calling SPI_exec() on another,
> unrelated query. So the backend crash makes perfect sense now.
> 
> What is the best strategy: 
> - store the result of a SELECT returning multiple tuples into a local
>   SPITupleTable? How do I allocate memory for that?

You can just save SPITupleTable pointer somewhere before running another
query. SPI doesn't free tuple table between queries but creates new one
for each select query.

Vadim


pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: Recovery from hard drive failure ... the hard way ...
Next
From: "Mikheev, Vadim"
Date:
Subject: RE: pgsql is 75 times faster with my new index scan