/* * call-seq: * res.fields() -> Array * * Returns an array of Strings representing the names of the fields in the result. */ static VALUE pgresult_fields(VALUE self) { PGresult *result; VALUE ary; int n, i; result = get_pgresult(self); n = PQnfields(result); ary = rb_ary_new2(n); for (i=0;i<n;i++) { VALUE val = rb_tainted_str_new2(PQfname(result, i)); ASSOCIATE_INDEX(val, self); rb_ary_push(ary, val); } return ary; }