compile_kb: Fix bug in iquery function