Re: Question about error handling with UDF written in C - Mailing list pgsql-novice

From Tom Lane
Subject Re: Question about error handling with UDF written in C
Date
Msg-id 10878.1363723501@sss.pgh.pa.us
Whole thread Raw
In response to Question about error handling with UDF written in C  (Terry Chong <198back@gmail.com>)
List pgsql-novice
Terry Chong <198back@gmail.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


pgsql-novice by date:

Previous
From: Terry Chong
Date:
Subject: Question about error handling with UDF written in C
Next
From: simonyanderson
Date:
Subject: Re: How to Recover iPhone Contacts You Lost Somehow?