fix issue #12192 to return {} or error message

This is the rework version for issue #12192. when query return {}, we also simply return {}