From: | "M(dot) François =?iso-8859-1?b?QmVub+50LU1hcmFuZA==?=" <francois(dot)benoit-marand(at)univ-poitiers(dot)fr> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: C function :: SECOND PROBLEM SOLVED :: SPI_finish releases memory! |
Date: | 2008-07-24 15:36:21 |
Message-ID: | 1216913781.4888a1759cffb@webmail.univ-poitiers.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The second problem is now solved !
> Second problem:
> When I try to give the output table, only the first line is correctly
> returned.
> I have introduced an analyse stage which reveals that the problem comes from
> the loss of the information in my matrix data structure when the function is
> called for the second time.
>
> My matrix data structure is the following :
>
> typedef struct puissance_matrix
> {
> int nl; //number of lines
> int nc; //number of columns
> int** data; //2D integer data
> } puissance_m;
>
> I use palloc to allocate space to the element called data.
>
> At the second call of the function, the element funcctx->user_fctx (that I
> use
> to store my matrix data structure) references the good memory block.
> Moreover,
> the nl and nc element references the good memory block too. But, in the block
> pointed by nl and nc, the values stored have changed ! I dont understand
> why.
> I try to use malloc or pgport_palloc instead of palloc: it doesnt work !
>
> Example:
>
> At the first call of my function:
>
> 1: BLOCK ANALYSE
> 1: pointer value of pm [11784980]
> 1: pointer value of pm->nc [11785068] stores (4)
> 1: pointer value of pm->nl [11785064] stores (4)
> 1: pointer value of pm->data [] and stored value () ::
> [19517544] (0) ::
> [19517548] (1) ::
> [19517552] (0) ::
> [19517556] (2) ::
> [19517568] (0) ::
> [19517572] (0) ::
> [19517576] (1) ::
> [19517580] (0) ::
> etc
>
> At the second call of my function:
>
> 1: pointer value of pm [11784980]
> 1: pointer value of pm->nc [11785068] stores (0)
> 1: pointer value of pm->nl [11785064] stores (0)
>
> If you are interested to read the code:
> Look at the function called: puissance_table
> At the line containing : DBG("PROBLEMATIK at step %i\n" , call_cntr);
> --------------------
In fact, SPI_finish releases memory allocated by palloc !!!!!!
Then, by using SPI_palloc insted of palloc I solved my second problem !!!!!
I think it would be interesting to add this in the documentation of the SPI !
Thnaks for your reading.
From | Date | Subject | |
---|---|---|---|
Next Message | Ivan Sergio Borgonovo | 2008-07-24 15:40:47 | Re: php + postgresql |
Previous Message | isaiah82 | 2008-07-24 15:32:05 | PANIC: could not write to log file 0 |