func newResult(res *C.PGresult) *driverRows { ncols := int(C.PQnfields(res)) nrows := int(C.PQntuples(res)) result := &driverRows{res: res, nrows: nrows, currRow: -1, ncols: ncols, cols: nil} runtime.SetFinalizer(result, (*driverRows).Close) return result }
func newResult(res *C.PGresult) *Result { ncols := int(C.PQnfields(res)) nrows := int(C.PQntuples(res)) result := &Result{res: res, nrows: nrows, currRow: -1, ncols: ncols, cols: nil} runtime.SetFinalizer(result, (*Result).Clear) return result }
func columns(r *PgRows) []string { nfields := int(C.PQnfields(r.result)) rv := make([]string, nfields) for i := 0; i < nfields; i++ { rv[i] = C.GoString(C.PQfname(r.result, C.int(i))) } return rv }
func (s *libpqStmt) Query(args []driver.Value) (driver.Rows, error) { // execute prepared statement cres, err := s.exec(args) if err != nil { return nil, err } // check to see if this was a "LISTEN" if C.GoString(C.PQcmdStatus(cres)) == "LISTEN" { C.PQclear(cres) return &libpqListenRows{s.c}, nil } return &libpqRows{ s: s, res: cres, ncols: int(C.PQnfields(cres)), nrows: int(C.PQntuples(cres)), currRow: 0, cols: nil, }, nil }