Exemple #1
0
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
}
Exemple #2
0
func (r *driverRows) Columns() []string {
	if r.cols == nil {
		r.cols = make([]string, r.ncols)
		for i := 0; i < r.ncols; i++ {
			r.cols[i] = C.GoString(C.PQfname(r.res, C.int(i)))
		}
	}
	return r.cols
}
Exemple #3
0
// Names returns the list of column (field) names, in order, in the result.
func (r *Result) Names() []string {
	if r.cols == nil {
		r.cols = make([]string, r.ncols)
		for i := 0; i < r.ncols; i++ {
			r.cols[i] = C.GoString(C.PQfname(r.res, C.int(i)))
		}
	}
	return r.cols
}