Re: Question about error handling with UDF written in C

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Terry Chong <198back(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Question about error handling with UDF written in C
Date: 2013-03-19 20:05:01
Message-ID: 10878.1363723501@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Terry Chong <198back(at)gmail(dot)com> writes:
> My question is that if we detect an error at line 15 and we get into the
> ereport code, would the memory allocated under multi_call_memory_ctx gets
> cleaned up properly?

Yes, it would. That's just the executor's query context, or maybe a
subcontext thereof, so it'll go away when the query is abandoned.

By and large, functions following ordinary coding conventions don't need
to worry about resource cleanup on error. The exception would be if you
were holding open file descriptors or some such that the core system
didn't know about.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message simonyanderson 2013-03-21 10:17:15 Re: How to Recover iPhone Contacts You Lost Somehow?
Previous Message Terry Chong 2013-03-19 19:57:36 Question about error handling with UDF written in C