示例#1
0
func readResult(rs ast.RecordSet, count int) {
	for count > 0 {
		x, err := rs.Next()
		if err != nil {
			log.Fatal(err)
		}
		if x == nil {
			log.Fatal(count)
		}
		count--
	}
	rs.Close()
}
示例#2
0
文件: tidb.go 项目: astaxie/tidb
// GetRows gets all the rows from a RecordSet.
func GetRows(rs ast.RecordSet) ([][]types.Datum, error) {
	if rs == nil {
		return nil, nil
	}
	var rows [][]types.Datum
	defer rs.Close()
	// Negative limit means no limit.
	for {
		row, err := rs.Next()
		if err != nil {
			return nil, errors.Trace(err)
		}
		if row == nil {
			break
		}
		rows = append(rows, row.Data)
	}
	return rows, nil
}