DEV Community

Aivars Kalvāns
Aivars Kalvāns

Posted on • Originally published at aivarsk.com on

Debugging Boolean Expressions of Fielded Buffers

I described the SIGFPE bomb of Boolean Expressions before. Going through the list of the C functions I was reminded of the Fboolpr32 function that prints the expression tree as it was parsed. Ten minutes later I had added it to the Python Tuxedo library. So let us look at the SIGFPE bomb again:

>>> import tuxedo as t
>>> t.Fboolev32({"TA_STATUS": "OK123"}, "TA_STATUS %! 'OK.*'")
Floating-point exception

Enter fullscreen mode Exit fullscreen mode

Now we can investigate and verify how it was parsed by Oracle Tuxedo:

>>> t.Fboolpr32("TA_STATUS %! 'OK.*'", sys.stdout)
( ( TA_STATUS[0] ) % ( ! ( 'OK.*' ) ) )

Enter fullscreen mode Exit fullscreen mode

Indeed, it is interpreted as the % modulo operation and ! negation. And here is what the developer intended to write:

>>> t.Fboolpr32("TA_STATUS !% 'OK.*'", sys.stdout)
( ( TA_STATUS[0] ) !% ( 'OK.*' ) )

Enter fullscreen mode Exit fullscreen mode

P.S. I have even implemented the Fboolpr32 function for my Open Source replacement of Oracle Tuxedo

Top comments (0)