示例#1
0
func resultError(res *C.PGresult) error {
	status := C.PQresultStatus(res)
	if status == C.PGRES_COMMAND_OK || status == C.PGRES_TUPLES_OK {
		return nil
	}
	return errors.New("libpq: result error: " + C.GoString(C.PQresultErrorMessage(res)))
}
示例#2
0
文件: pq.go 项目: dvarrazzo/pger
func errorFromPGresult(res *C.PGresult) error {
	switch C.PQresultStatus(res) {
	case C.PGRES_EMPTY_QUERY:
		return errors.New("empty query")
	case C.PGRES_BAD_RESPONSE:
		return errors.New("bad response")
	case C.PGRES_FATAL_ERROR:
		return errors.New(C.GoString(C.PQresultErrorMessage(res)))
	}
	return nil
}