Question

I would like to use strace to debug a strange behaviour I have with db2. I have a SQL function myFoo() implemented in C that doesn't get called for some reason (some code access path not existing or not authorized see here). My Sql Function call a function Fooin shared library in /usr/local/lib/libmyfoo (so in db2 term /usr/local/lib/libmyfoo!Foo).

If I use strace directly with db2 and the query I have an error saying

   A database connection does not exist

so i created a script call debug.sh with the following. The idea is to have a shell with the db2 connection active and trace it.

db2 "connect to MYDB"
db2 "select * from table(myFoo())" # this calls /usr/local/lib/libmyfoo!Foo
db2 "disconnect MYDB"

It doesn't work cos I realized that strace works with binary so I have the error

Exec Format Error
Was it helpful?

Solution

Probably you are calling each DB2 command in different subshells. You can fix that problem by executing everything in just one subshell, for example

VALUE=$(. /home/db2inst1/sqllib/db2profile ; db2 connect to MYDB ; db2 "select * from table(myFoo())")

OTHER TIPS

My Sql Function call a function Foo in shared library in /usr/local/lib/libmyfoo (so in db2 term libmyfoo!Foo).

Is this really how you defined your function? libmyfoo!Foo will point to the library $INSTANCE_HOME/sqllib/function/libmyfoo. If your library is elsewhere you need to provide the absolute path to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top