On 12/05/11 04:23, Geoff Worboys wrote:
> So the power example would become:
>
> declare external function dPower
> double precision by descriptor, double precision by descriptor,
> double precision by descriptor, integer by descriptor
> returns parameter 3
> returns exception 4
> entry_point 'power' module_name 'fbudf';
>
> and the relevant part of the udf code could become:
> FBUDF_API void power(const paramdsc* v, const paramdsc* v2,
>   paramdsc* rc, paramdsc* rce)
> [...]
>         if (rct < 0 || rct2 < 0 || !d && d2 < 0)
>         {
>                 internal::setnull(rc);
>                 internal::set_int_type(rce, 1);
>                 return;
>         }
>
> Something like this could make UDFs more powerful and error
> situations easier to deal with.

On my mind much simpler way will be to have special interface (we talk
about FB3 and higher, though in 2X speical entrypoint may be easily
used) to notify engine about error condition in UDF. Something like:

if (rct < 0 || rct2 < 0 || !d && d2 < 0)
{
    fb_get_master_interface()->getUdfHelper()->signalError(FB_MATH_ERROR);
    return 0.0;
}

Certainly, UdfHelper interface name is just a sample like FB_MATH_ERROR
constant too.
This helps avoid artificial parameters passed to UDF.


------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to