Subject UDF's
Author Ian A. Newby
Hi All,
I am in the middle of writing some cross platform Blob UDF's for use
on both linux and Windows (when they are complete I will release them
open source). While I have found this a "learning opportunity"
(writing in C as opposed to Java or Delphi) I have encountered a
number of annoying factors in writing and using UDF's discussed below.

1. Declaring UDF's in every database on a server.
I believe that having an ability to declare Server wide UDF's would be
a big advantage. If this could be done, then an installation of
Interbase or Firebird could include a number of verified UDF's which
would greatly enhance the product. The problem at the moment as I see
it is that the perception in the marketplace is that Interbase has a
very poor number of functions complared to its rivals.

2. Null values in fields/ Multitype UDF's.
With the current implementation of UDF's the UDF writer cannot access
a null parameter or indicate that a returned parameter is null. How
difficult would it be to implement a new interbase type (as a struct
or record) which could be passed to and from a UDF? Something
containing the following information.

struc ibParam {
pointer to data.
Data type (varchar, integer, etc)
Maximum data size
Null flag
}

Using this approach would have a number of advantages:
a) The same udf would be able to operate on multiple field types
(assuming the UDF was coded to operate on multiple types).
b) nulls could be passed and returned via udf's.
c) The memory management issues of creating strings could be bypassed
if interbase/firebird pre-allocated the return structure.
d) If the struct was passed as a variable parameter the udf's return
value could indicate an error condition.

3. Java UDF's
Cross platform UDF creation for me is a pain. I know at present that
the udf's I am writing are required on both linux and windows but I
have no idea what other platforms I will have to provide the library
on. Allowing udf's to be written in java would completetly alleviate
this problem.

Anyway, thats my thoughts for now. I've tried reading C code in the
past and I'm not very good at it, so I don't think I'm up to hacking
the source directly (or even finding out where to hack!) but I would
be a willing test case if any of this was implemented sometime in the
future.

Regards,
Ian Newby.

PS Once I finish the UDF blob library whats the best method for
getting it hosted? Could it be added to the Firebird CVS tree (If
considered good enough?)