/*
 * call-seq:
 *    res.fields()
 *
 * Returns an array of Strings representing the names of the fields in the result.
 *
 *   res=conn.exec("SELECT foo,bar AS biggles,jim,jam FROM mytable;")
 *   res.fields => [ 'foo' , 'biggles' , 'jim' , 'jam' ]
 */
static VALUE
pgresult_fields(obj)
  VALUE obj;
{
  PGresult *result;
  VALUE ary;
  int n, i;

  result = get_pgresult(obj);
  n = PQnfields(result);
  ary = rb_ary_new2(n);
  for (i=0;i<n;i++) {
  rb_ary_push(ary, rb_tainted_str_new2(PQfname(result, i)));
  }
  return ary;
}