PqResult constructor
Implementation
PqResult(this.psql, this.res, this.query) {
if (res == nullptr) {
throw LibPqException("Result is nullptr");
}
_status = psql.pq.PQresultStatus(res);
_valid = (_status == ExecStatusType.PGRES_COMMAND_OK ||
_status == ExecStatusType.PGRES_TUPLES_OK);
_columns = psql.pq.PQnfields(res);
_rows = psql.pq.PQntuples(res);
for (int i = 0; i < _columns; i++) {
columnNames
.add(psql.pq.PQfname(res, i).asDartString(encoding: psql.encoding));
}
if (_status != ExecStatusType.PGRES_COMMAND_OK &&
_status != ExecStatusType.PGRES_TUPLES_OK) {
final message = psql.pq
.PQresultErrorMessage(res)
.asDartString(encoding: psql.encoding);
dispose();
throw LibPqException(message, sql: query);
}
}