Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to see cause why FireBird does not see UDF? [CORE2193] #2621

Closed
firebird-automations opened this issue Nov 15, 2008 · 2 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Eugenk Konkov (kes)

Votes: 1

1. Test how firebird recognize libxxx and xxx and http://xxx.so libraries
(because of C variant of UDF works I will try gcc)

a) source file:
extern int c_test();

int c_test()

return 8;

b) home#⁠ gcc -c testudf.c
c) home#⁠ gcc testudf.o -o http://testudf.so -shared
d) home#⁠ nm http://testudf.so
00001630 A _DYNAMIC
00001704 A _GLOBAL_OFFSET_TABLE_
w _Jv_RegisterClasses
000016f4 d __CTOR_END__
000016f0 d __CTOR_LIST__
000016fc d __DTOR_END__
000016f8 d __DTOR_LIST__
0000162c r __FRAME_END__
00001700 d __JCR_END__
00001700 d __JCR_LIST__
0000171c A __bss_start
w __cxa_finalize@@FBSD_1.0
00000550 t __do_global_ctors_aux
000004a0 t __do_global_dtors_aux
00001624 d __dso_handle
00000537 t __i686.get_pc_thunk.bx
0000171c A _edata
00001720 A _end
00000584 T _fini
0000046c T _init
00000540 T c_test
0000171c b completed.4685
00000500 t frame_dummy
00001628 d p.4683

e) ls -l
-rwxr-xr-x 1 root wheel 4520 15 ноя 21:29 http://testudf.so
f) cp http://testudf.so /usr/local/libexec/firebird/udf
g) Because of FireBird is started from inetd:
home#⁠ /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.
h)
DECLARE EXTERNAL FUNCTION FNTEST
RETURNS INTEGER BY VALUE
ENTRY_POINT 'c_test'
MODULE_NAME 'testudf'
i) select fntest() from rdb$database
result 8

2. Now I test different names for UDF
a) home#⁠ cd /usr/local/libexec/firebird/udf
b) home#⁠ mv http://testudf.so http://libtestudf.so
c) home#⁠ /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

d) select fntest() from rdb$database
result 8

e) home#⁠ mv http://libtestudf.so testudf
f) home#⁠ /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

g) select fntest() from rdb$database
result 8

h) home#⁠ mv testudf libtestudf
i) home#⁠ /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.

j) select fntest() from rdb$database
k) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

So when I write:
... MODULE_NAME 'testudf'
firebird will see http://testudf.so/libtestudf.so/testudf and do not see libtestudf

PS.
#⁠rm libtestudf
#⁠cd to my directory with sources

3. Now I try to compile by FPC:
a) home#⁠ cat testudf.pp
library testudf;

function pp_test(): integer; cdecl; export;
begin
pp_test:= 7;
end;

exports
pp_test name 'pp_test2';
begin
end.

b) home#⁠ fpc testudf.pp
Target OS: FreeBSD/ELF for i386
Compiling testudf.pp
Linking http://libtestudf.so
11 lines compiled, 0.1 sec

c) nm http://libtestudf.so > libtestudf.txt see in attached file
libtestudf.txt
d) home#⁠ cp http://libtestudf.so /usr/local/libexec/firebird/udf
e) home#⁠ /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.
f) Change definition in SQL. So now it looks like:
DECLARE EXTERNAL FUNCTION FNTEST
RETURNS INTEGER BY VALUE
ENTRY_POINT 'pp_test'
MODULE_NAME 'testudf'
g) select fntest() from rdb$database
h) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

i) change definition in SQL. So now it looks like:
DECLARE EXTERNAL FUNCTION FNTEST
RETURNS INTEGER BY VALUE
ENTRY_POINT 'pp_test2'
MODULE_NAME 'testudf'
j) select fntest() from rdb$database
k) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

4. Compiling with fpc -Xc
a) nm testudf.o
home#⁠ nm testudf.o
U FPC_INITIALIZEUNITS
00000020 D FPC_RESOURCESTRINGTABLES
00000014 D FPC_THREADVARTABLES
U INIT$_SYSTEM
00000004 D INITFINAL
00000000 T P$TESTUDF_PP_TEST$$SMALLINT
00000014 T P$TESTUDF_main
00000014 T PASCALMAIN
00000000 D THREADVARLIST_P$TESTUDF
U THREADVARLIST_SYSTEM
0000002c D __fpc_valgrind
00000028 D __heapsize
00000024 D __stklen
00000000 T pp_test
00000020 T pp_test2

b) home#⁠ cp http://libtestudf.so /usr/local/libexec/firebird/udf
c) home#⁠ /etc/rc.d/inetd restart
Stopping inetd.
Starting inetd.
d) DECLARE EXTERNAL FUNCTION FNTEST
RETURNS INTEGER BY VALUE
ENTRY_POINT 'pp_test2'
MODULE_NAME 'testudf'
e) select fntest() from rdb$database
f) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

g) DECLARE EXTERNAL FUNCTION FNTEST
RETURNS INTEGER BY VALUE
ENTRY_POINT 'pp_test'
MODULE_NAME 'testudf'
h) select fntest() from rdb$database
i) invalid requiest BLR at offset 60
function FNTEST is not defined
module name or entrypoint could not be found

CONCLUSION: FPC generate wrong object file???

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

Component: UDF [ 10002 ]

@dyemanov
Copy link
Member

This ticket is old and UDFs are deprecated now, thus closed.

@dyemanov dyemanov closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants