Fix checking of query type in plpgsql's RETURN QUERY command