| From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
|---|---|
| To: | Nicolai Petri <lists(at)petri(dot)cc> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Adding callback support. |
| Date: | 2005-05-11 21:32:18 |
| Message-ID: | 20050511213217.GA15877@dcc.uchile.cl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, May 10, 2005 at 09:36:59AM +0200, Nicolai Petri wrote:
> I'm currently building some stored procedures in C that uses some internal
> hash tables - It could be really nice to be able to deallocate those
> correctly when e.g. a memctx is destroyed. Would it be possible to add this
> as a postgresql feature and how should it be done.
Why don't you just create the hash table inside a context that has the
right longevity? For example, TopTransactionContext. So at transaction
end the hash table is automatically freed.
> I also have some other tasks where I would like to do specific actions when a
> transaction completes or aborts. This could be used for maintaining a
> pgmemcache correctly and many other cases. Could this be combined with the
> above feature so a generic callback framework was added ?
Hmm, is there anything the following functions don't do for you:
extern void RegisterXactCallback(XactCallback callback, void *arg);
extern void UnregisterXactCallback(XactCallback callback, void *arg);
extern void RegisterSubXactCallback(SubXactCallback callback, void *arg);
extern void UnregisterSubXactCallback(SubXactCallback callback, void *arg);
See src/backend/access/transam/xact.c
--
Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
"Ni aun el genio muy grande llegaría muy lejos
si tuviera que sacarlo todo de su propio interior" (Goethe)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joshua D. Drake | 2005-05-11 21:34:21 | Re: New Contrib Build? |
| Previous Message | Tom Lane | 2005-05-11 21:28:22 | Re: Oracle Style packages on postgres |