> 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