Subject Re: [IBO] :PARAM inside function call not working!
Author Helen Borrie
At 06:49 PM 9/06/2005 +0200, you wrote:

> >
> >There is a paper on writing UDFs with descriptors here:
> >
> >http://www.cvalde.net/document/using_descriptors_with_udfs.htm
> >
> >Helen
> >
> >
>Before I got this mail (thanks anyway) i tested something. In the SQL:
>
>DECLARE EXTERNAL FUNCTION PCRE_SIMILAR CSTRING(255), CSTRING(255)
>RETURNS INT ENTRY_POINT 'ibpcre_similar' MODULE_NAME 'ibpcre';
>
>i replaced CSTRING with VARCHAR and suddenly everithing went OK!
>
>Was that supposed to work? Am I not violating some rules?

It would be expected to "work" from the POV of the engine recognising the
data type. However CSTRING is a hack that, in combination with the FREE_IT
keyword in your declaration, tells the engine that it has to free the
memory used for the string. According to my (somewhat hazy) understanding,
unless you define a varchar parameter by descriptor, you've got strings
lurking about with no destructors and so you leak memory.

Did you read Claudio's paper? You can also get the source code for fbudf
from the Firebird CVS tree to see how he works it in the code.

You're more likely to get the answers to your UDF questions by asking on
firebird-support. These days it's fairly unlikely that you will catch
Claudio's attention on this list. Another person who seems to know a lot
about UDFs is Ivan Prenosil, who doesn't hang out in this list at all...

Helen