pqftypename method

String pqftypename(
  1. int ftype
)

Returns the field type as a string

Implementation

String pqftypename(int ftype) {
  final queryP = "select typname from pg_catalog.pg_type where oid = $ftype"
      .toNativeUtf8();
  final res = pq.PQexec(conn, queryP.cast());
  final status = pq.PQresultStatus(res);
  if (status != ExecStatusType.PGRES_COMMAND_OK &&
      status != ExecStatusType.PGRES_TUPLES_OK) {
    final message =
        pq.PQresultErrorMessage(res).asDartString(encoding: encoding);
    pq.PQclear(res);
    throw LibPqException(message);
  }
  final name = pq.PQgetvalue(res, 0, 0).asDartString(encoding: encoding);
  pq.PQclear(res);
  return name;
}