| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Greg Mitchell <gmitchell(at)atdesk(dot)com> |
| Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Custom Data Type Question |
| Date: | 2006-11-16 18:43:26 |
| Message-ID: | 19969.1163702606@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Greg Mitchell <gmitchell(at)atdesk(dot)com> writes:
> As far as memory management goes, do I just use hash_create() and assign
> that pointer to fn_extra and at the end of the query it will be freed?
> Or will it not be freed until this end of the transaction? I'm really
> having trouble understanding the memory management issues with Postgres.
You have to be careful that the hashtable is created in the correct
"memory context" --- in this case you want it to be in a query-lifespan
context, not the short-term (per-tuple-lifespan) context that your
function will be called in. The usual procedure for cases like this is
to use the context identified by fn_mcxt. src/backend/utils/mmgr/README
might make useful reading for you.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jerry Sievers | 2006-11-16 18:44:03 | Re: statement_timeout |
| Previous Message | Casey Duncan | 2006-11-16 18:38:56 | Re: statement_timeout |