/*
* call-seq:
* res.ftype( column_number )
*
* Returns the data type associated with _column_number_.
*
* The integer returned is the internal +OID+ number (in PostgreSQL)
* of the type. To get a human-readable value for the type, use the
* returned OID and the field's #fmod value with the format_type() SQL
* function:
*
* # Get the type of the second column of the result 'res'
* typename = conn.
* exec( "SELECT format_type($1,$2)", [res.ftype(1), res.fmod(1)] ).
* getvalue( 0, 0 )
*
* Raises an ArgumentError if _column_number_ is out of range.
*/
static VALUE
pgresult_ftype(VALUE self, VALUE index)
{
PGresult* result = get_pgresult(self);
int i = NUM2INT(index);
if (i < 0 || i >= PQnfields(result)) {
rb_raise(rb_eArgError, "invalid field number %d", i);
}
return INT2NUM(PQftype(result, i));
}