/*
 * call-seq:
 *    res.getlength( tup_num, field_num )
 *
 * Returns the (String) length of the field in bytes. If the field is +nil+, returns +0+.
 *
 * Equivalent to <tt>res.value(<i>tup_num</i>,<i>field_num</i>).length</tt>.
 */
static VALUE
pgresult_getlength(obj, tup_num, field_num)
  VALUE obj, tup_num, field_num;
{
  PGresult *result;
  int i = NUM2INT(tup_num);
  int j = NUM2INT(field_num);

  result = get_pgresult(obj);
  if (i < 0 || i >= PQntuples(result)) {
  rb_raise(rb_eArgError,"invalid tuple number %d", i);
  }
  if (j < 0 || j >= PQnfields(result)) {
  rb_raise(rb_eArgError,"invalid field number %d", j);
  }
  return INT2FIX(PQgetlength(result, i, j));
}