[FIX] XQuery: check touched databases in sub functions