The C code returns 2 when there is no result coming back from the db server. The docs are misleading or are not sync'ed with the code. There is a db result coming back in this case which includes the columns, just no rows.
For now, you can check if the `$xavp(ra)` is null or not.
We have to make the docs and code coherent in a way or another.