0

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
Community
  • 1
  • 1
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
  • I don't think `strace`ing the client will help you debug the server. – mustaccio Dec 02 '13 at 14:48
  • What's the output of `ls -l /usr/local/lib/libmyfoo` (and please stop using bogus names, noone is going to steal your intellectual property by knowing the actual file name). – mustaccio Dec 03 '13 at 12:56

2 Answers2

1

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())")
AngocA
  • 7,655
  • 6
  • 39
  • 55
  • Hi Ancgoca. Thanks for your help. I can see the result assigned to $VALUE, but how can I use strace with that? I am struggling a bit (tough I am still searching for ways to use your call) – Abruzzo Forte e Gentile Dec 03 '13 at 09:03
0

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.

mustaccio
  • 18,234
  • 16
  • 48
  • 57