/*
 * call-seq:
 *    res.result()
 *
 * Returns an array of tuples (rows, which are themselves arrays) that represent the query result.
 */
static VALUE
pgresult_result(obj)
  VALUE obj;
{
  PGresult *result;
  VALUE ary;
  int nt, nf, i, j;

  result = get_pgresult(obj);
  nt = PQntuples(result);
  nf = PQnfields(result);
  ary = rb_ary_new2(nt);
  for (i=0; i<nt; i++) {
  VALUE row = rb_ary_new2(nf);
  for (j=0; j<nf; j++) {
    VALUE value = fetch_pgresult(result, i, j);
    rb_ary_push(row, value);
  }
  rb_ary_push(ary, row);
  };

  return ary;
}