Re: function crashes backend - Mailing list pgsql-hackers

From Louis-David Mitterrand
Subject Re: function crashes backend
Date
Msg-id 20000927101315.A10137@styx
Whole thread Raw
In response to function crashes backend  (Louis-David Mitterrand <cunctator@apartia.ch>)
List pgsql-hackers
On Wed, Sep 27, 2000 at 08:53:58AM +0200, Louis-David Mitterrand wrote:
> Hello,
> 
> I am writing a SPI function to run maintenance tasks on my auction
> system but it keeps crashing the backend after running only one loop.
> Now, I am not a C programmer, nor do I have any formal training in CS. I
> thought I might run this function by you guys so that a cursory look
> might reveal some obvious coding mistake? 
> 
> Thanks in advance for your insight.

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?
- iterate over all values contained in the tuples and store _them_ into char**, int*, arrays, before re-running
SPI_exec()on the second query?
 

TIA

-- 
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org

> Any suggestions for setting up WinCVS client + (server) on NT4?
Run away screaming in terror.                --Toby.


pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: pgsql is 75 times faster with my new index scan
Next
From: devik@cdi.cz
Date:
Subject: Re: pgsql is 75 times faster with my new index scan