>Can you please tel me the location in code where
>I can allocate space before begin transaction call?
Its in your code. your case it may be spi_connect().
> Right now, I am using spi_palloc function to alloctae memory to my structure instance
Ohh, but spi_palloc should work as you expected. I am not sure why you losing it.
>I want to insert 10 rows in a table and want to store the corresponding transaction ID in >one link list.
I am not sure is right method or not, why dont you allocated memory of structure in top context when your code start.
spi_connect()
/*
*
* SOME CODE
*/
oldcontext = CurrentMemoryContext;
oldowner = CurrentResourceOwner;
MemoryContextSwitchTo(mycontext);
// Allocate memory for your structure.
MemoryContextSwitchTo(oldcontext);
CurrentResourceOwner = oldowner;
/*
*
* SOME CODE
*/
spi_finish();
let say, here mycontext is when main function of application called, you should store it as mycontext
= CurrentMemoryContext;
I am not sure is this best practice, but it work for me.
Regards,
Amul Sul