Avoid using a cursor in plpgsql's RETURN QUERY statement