From: | amul sul <sul_amul(at)yahoo(dot)co(dot)in> |
---|---|
To: | Rohit Goyal <rhtgyl(dot)87(at)gmail(dot)com> |
Cc: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: How to allocate space to structure instance |
Date: | 2013-12-11 07:37:18 |
Message-ID: | 1386747438.63157.YahooMailNeo@web193504.mail.sg3.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
>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
From | Date | Subject | |
---|---|---|---|
Next Message | Gerald Cheves | 2013-12-12 07:22:30 | PostgreSQL Studio |
Previous Message | Rohit Goyal | 2013-12-11 06:45:26 | Re: How to allocate space to structure instance |