Re: C language context
От | Tom Lane |
---|---|
Тема | Re: C language context |
Дата | |
Msg-id | 26441.1062804375@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | C language context (Andrew Dunstan <andrew@dunslane.net>) |
Список | pgsql-hackers |
Andrew Dunstan <andrew@dunslane.net> writes: > Just how transient is the memory context created for a C language > function call? Fairly. IIRC, you'll normally be running in a context that will be reset at the start of the next tuple cycle for the plan node your function is evaluated by. If you've got a heavily recursive routine, it might need to do its own cleanup per-call, but most of the time you need not bother with pfree. > I'm still trying to get to the bottom of it, but I want to know if I'm > safe in relying on the context cleanup to handle things for me. It's an > immutable text function returning text, and is intended for use in a > functional index. You might wanna check the code, but I think we force a context reset after each tuple for functional index evaluations as well. AFAIR, the only case where we really still require user-provided functions to avoid leaking memory is support functions and operators for indexes (for example, the comparison functions used by btrees). The internal memory usage in the index AMs is hairy enough to make it hard to fix that, though I'd like to do so someday. regards, tom lane
В списке pgsql-hackers по дате отправления: