Subject | UDF function declaration goofyness |
---|---|
Author | Jason Dodson |
Post date | 2005-07-22T14:29:30Z |
This one has me stumped... and it shouldn't. Here is the situation.... I
simply wanted to use the ABS() funtion from the ib_udf library
(ib_udf.so, being that it is Loooooonix). I currently DO have a couple
of other functions successfully declared and used from that library:
DECLARE EXTERNAL FUNCTION STRLEN
CSTRING (32767)
RETURNS INTEGER BY VALUE
ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf';
DECLARE EXTERNAL FUNCTION SUBSTR
CSTRING (80),
SMALLINT,
SMALLINT
RETURNS CSTRING (80) FREE_IT
ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf';
Ok, so I go and get the DDL for ABS() and throw it in there:
DECLARE EXTERNAL FUNCTION abs
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';
Ok, so now it is defined, so lets try and use it:
Select ABS(-2), ABS(2)
From RDB$Database
And I get:
Invalid token.invalid request BLR at offset 59.
function ABS is not defined.
module name or entrypoint could not be found.
Ok JERK. Fine. Maybe for some reason, being that it was compiled from
source, it got missed. So we do a 'strings /opt/firebird/UDF/ib_udf.so |
grep abs' and we see:
IB_UDF_abs
So it is in there, defined, and the library is there, BEING USED, so
what could POSSIBLY be the issue here?
Jason
P.S. As a work around, I multiply my values by -1 in a case statement if
they are < 0, but this is hacky and I dont want to face this if I REALLY
need a function in there at some other time.
simply wanted to use the ABS() funtion from the ib_udf library
(ib_udf.so, being that it is Loooooonix). I currently DO have a couple
of other functions successfully declared and used from that library:
DECLARE EXTERNAL FUNCTION STRLEN
CSTRING (32767)
RETURNS INTEGER BY VALUE
ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf';
DECLARE EXTERNAL FUNCTION SUBSTR
CSTRING (80),
SMALLINT,
SMALLINT
RETURNS CSTRING (80) FREE_IT
ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf';
Ok, so I go and get the DDL for ABS() and throw it in there:
DECLARE EXTERNAL FUNCTION abs
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';
Ok, so now it is defined, so lets try and use it:
Select ABS(-2), ABS(2)
From RDB$Database
And I get:
Invalid token.invalid request BLR at offset 59.
function ABS is not defined.
module name or entrypoint could not be found.
Ok JERK. Fine. Maybe for some reason, being that it was compiled from
source, it got missed. So we do a 'strings /opt/firebird/UDF/ib_udf.so |
grep abs' and we see:
IB_UDF_abs
So it is in there, defined, and the library is there, BEING USED, so
what could POSSIBLY be the issue here?
Jason
P.S. As a work around, I multiply my values by -1 in a case statement if
they are < 0, but this is hacky and I dont want to face this if I REALLY
need a function in there at some other time.