Can't load rfunc UDF on FB3.0

299 views
Skip to first unread message

Simone Chierichetti

unread,
Apr 6, 2024, 8:47:52 AM4/6/24
to firebird-support
I need to open a FB DB instance that uses rfunc UDF.
I can't get this working.

I installed firebird 3.0.11.33703_0_Win32 on windows 10 x64.
I put rfunc.dll in UDF folder under installation folder of FB.

i set in firebird.conf:
UdfAccess = UDF

Then i restarted the service.

When I try to connect using
dbeaver 24.0.1
firebird jdbc driver Jaybird 5.0.2

it opens up the db, but when I try to access a specific table that uses LTRIM(), it says:
invalid request BLR at offset 2: function LTRIM is not defined module name or entrypoint could not be found


I also checked that UDF is accessible by any user but I can't get this working.

Any advice?


Thanks
 

Mark Rotteveel

unread,
Apr 6, 2024, 9:18:13 AM4/6/24
to firebird...@googlegroups.com
On 06/04/2024 14:46, Simone Chierichetti wrote:
> I need to open a FB DB instance that uses rfunc UDF.
> I can't get this working.
>
> I installed firebird 3.0.11.33703_0_Win32 on windows 10 x64.
> I put rfunc.dll in UDF folder under installation folder of FB.
>
> i set in firebird.conf:
> UdfAccess = UDF

That is the wrong value, it should be

UdfAccess = Restrict UDF

> Then i restarted the service.
>
> When I try to connect using
> dbeaver 24.0.1
> firebird jdbc driver Jaybird 5.0.2
>
> it opens up the db, but when I try to access a specific table that uses
> LTRIM(), it says:
> invalid request BLR at offset 2: function LTRIM is not defined module > name or entrypoint could not be found

Why not just use the built-in TRIM function, that is, TRIM(LEADING FROM
...)? See
https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref30/fblangref30-functions-string.html#fblangref30-scalarfuncs-trim

> I also checked that UDF is accessible by any user but I can't get this
> working.
>
> Any advice?

Also make sure the UDF is actually 32-bit, given you're using Firebird
32-bit.

Mark
--
Mark Rotteveel

Simone Chierichetti

unread,
Apr 6, 2024, 1:07:50 PM4/6/24
to firebird-support
I'm sorry i miss typed, of course in config file I wrote:
UdfAccess = Restrict UDF

I'm using LTRIM because I'm importing this DB from a fbk, so I want to restore it with the original functions.

I download the UDF from here https://rfunc.sourceforge.net/
I suppose it was 32bit; also the previous owner of the db suggests me that.

I still can't get it working. I'm going crazy!

Mário Reis

unread,
Apr 6, 2024, 1:23:18 PM4/6/24
to firebird...@googlegroups.com
You need to install/registre external rfunc Dll  on Firebird.
By the message you report i beleave you misses this step.
I hope this helps
Best regards

--
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/d95c2cbd-462c-4dd8-b237-09ba78de5639n%40googlegroups.com.

Simone Chierichetti

unread,
Apr 6, 2024, 1:43:07 PM4/6/24
to firebird-support
How can i do this?
I'm totally new to Firebird...

I tryed to run:
DECLARE EXTERNAL FUNCTION LTRIM
   CSTRING(255)
   RETURNS CSTRING(255)
  ENTRY_POINT 'fn_ltrim'  MODULE_NAME 'rfunc';

But it returns:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE FUNCTION LTRIM failed
-Function LTRIM already exists


I didn't create the DB, i'm only restoring it from a fbk, so I run:
SQL> show function LTRIM;
External function LTRIM:
Function library is rfunc
Entry point is fn_ltrim
Returns  CSTRING(256) CHARACTER SET NONE
Argument 1: CSTRING(256) CHARACTER SET NONE


It seems right, but still not working:
Statement failed, SQLSTATE = 39000

invalid request BLR at offset 2
-function LTRIM is not defined
-module name or entrypoint could not be found

Mark Rotteveel

unread,
Apr 6, 2024, 1:54:13 PM4/6/24
to firebird...@googlegroups.com
On 06/04/2024 19:23, Mário Reis wrote:
> You need to install/registre external rfunc Dll  on Firebird.
> By the message you report i beleave you misses this step.

No, the error message means that a UDF called LTRIM has been defined,
but it can't find the native method. Which means that either the library
is not present in the UDF directory of Firebird, or it failed to load
because its missing a dependency or some other reason.

Mark
--
Mark Rotteveel

Simone Chierichetti

unread,
Apr 6, 2024, 4:27:05 PM4/6/24
to firebird-support
Is possible to have a debug log in order to address where the problem is? 

Dimitry Sibiryakov

unread,
Apr 6, 2024, 5:38:44 PM4/6/24
to firebird...@googlegroups.com
Simone Chierichetti wrote 06.04.2024 22:27:
> Is possible to have a debug log in order to address where the problem is?

Process Monitor on Windows and ldd on Linux are useful tools to investigate
such problems.

--
WBR, SD.

Mário Reis

unread,
Apr 7, 2024, 4:47:11 PM4/7/24
to firebird...@googlegroups.com
I beleave ltrim funciona now adays is parte of FB3.0

Mark Rotteveel

unread,
Apr 8, 2024, 3:57:27 AM4/8/24
to firebird...@googlegroups.com
On 07/04/2024 22:46, Mário Reis wrote:
> I beleave ltrim funciona now adays is parte of FB3.0

Not exactly, there is TRIM[1], which can behave the same as LTRIM, when
you use `TRIM(LEADING FROM ...)`.

Mark

[1]:
https://www.firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref30/fblangref30-functions-string.html#fblangref30-scalarfuncs-trim
--
Mark Rotteveel

Simone Chierichetti

unread,
Apr 8, 2024, 10:27:41 AM4/8/24
to firebird-support
I attach the logs from procmon.
Seems that it loads rfunc.dll correctly, i can't understand where the error is.
Logfile.PML
Logfile.CSV

Dimitry Sibiryakov

unread,
Apr 8, 2024, 10:51:11 AM4/8/24
to firebird...@googlegroups.com
Simone Chierichetti wrote 08.04.2024 16:27:
> Seems that it loads rfunc.dll correctly, i can't understand where the error is.

No, it just shows that the file is found and it doesn't try to load
non-existing dependencies.
Now use other tools (such as PE Explorer or DLL Export viewer) to check that
this file is 32 bits executable and exports necessary symbols.
If you have MSVC or Delphi they also have tools for that.

--
WBR, SD.

Simone Chierichetti

unread,
Apr 8, 2024, 10:58:49 AM4/8/24
to firebird-support
here it is. It exports the function that i need 
fn_ltrim
Exported Functions List.html

Dimitry Sibiryakov

unread,
Apr 8, 2024, 11:11:09 AM4/8/24
to firebird...@googlegroups.com
Simone Chierichetti wrote 08.04.2024 16:58:
> here it is. It exports the function that i need
> fn_ltrim

> fn_ltrim 0x00000001800064f0

Judging by number of digits in the address this library is 64 bits. It cannot
be used by 32 bits processes.

--
WBR, SD.

Simone Chierichetti

unread,
Apr 8, 2024, 11:32:55 AM4/8/24
to firebird-support
You're right!
I installed FB3.0 x64 and it worked.
The previous owner of DB assured me that it was x86...

Thanks for the support!

Reply all
Reply to author
Forward
0 new messages