Subject Re: [firebird-support] UDF Unloaded
Author Helen Borrie
At 10:08 AM 14/12/2006, you wrote:
>Hi,
>
>I wanted to know when are UDF's unloaded? I'm doing something "risky"
>where I have a internal variable counter in the udf and I noticed the
>UDF is unloaded when the user disconnects,

UDFs live in libraries. A library is loaded *by the server* the
first time a client calls a function in that library. It is not
loaded by the client and it is not unloaded "when the user
disconnects" - unless, of course, the "user" is the embedded server client.

A UDF is a *function*. It takes inputs from the caller and returns a
scalar result. A UDF must not be used as though it were a process or
procedure. If you are using a UDF to maintain some value that's
intended to be altered there by successive function calls then you
are asking for trouble, i.e. corrupted memory, leakage, server crash, etc.

>but I wanted to know what
>if I had a UDF function that is doing something that isn't completed
>yet when the user disconnects?

A UDF wouldn't be "doing something that isn't completed yet". A lost
client connection is an issue (separate) for the server but not for a
UDF. The UDF itself has no awareness of the client. The client has
made a request to the server that causes the server to invoke the
external function. The server waits for the result, sends the result
to an output buffer and frees any memory it had allocated for the
function call.

./heLen