// Row implements table.Table Row interface.
962758
func (t *tableCommon) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error) {
	r, err := t.RowWithCols(ctx, h, t.Cols())
	if err != nil {
		return nil, err
	}
	return r, nil
}
1071986
func (row *Row) Init() {
	// Initial values
	row.insertColumnLength = len(row.PK) + len(row.Fields)
	row.updateColumnLength = len(row.PK) + len(row.Fields)
	row.pkColumns = make([]string, 0)
	row.pkValues = make([]interface{}, 0)
	row.insertColumns = make([]string, 0)
	row.updateColumns = make([]string, 0)
	row.insertValues = make([]interface{}, 0)
	row.updateValues = make([]interface{}, 0)

	// Get and sort map keys
	var i int
	pkKeys := make([]string, len(row.PK))
	i = 0
	for pkKey := range row.PK {
		pkKeys[i] = pkKey
		i++
	}
	sort.Strings(pkKeys)
	fieldKeys := make([]string, len(row.Fields))
	i = 0
	for fieldKey := range row.Fields {
		fieldKeys[i] = fieldKey
		i++
	}
	sort.Strings(fieldKeys)

	// Primary keys
	for _, pkKey := range pkKeys {
		row.pkColumns = append(row.pkColumns, pkKey)
		row.pkValues = append(row.pkValues, row.PK[pkKey])
		row.insertColumns = append(row.insertColumns, pkKey)
		row.updateColumns = append(row.updateColumns, pkKey)
		row.insertValues = append(row.insertValues, row.PK[pkKey])
		row.updateValues = append(row.updateValues, row.PK[pkKey])
	}

	// Rest of the fields
	for _, fieldKey := range fieldKeys {
		sv, ok := row.Fields[fieldKey].(string)
		if ok && sv == onInsertNow {
			row.insertColumns = append(row.insertColumns, fieldKey)
			row.insertValues = append(row.insertValues, time.Now())
			row.updateColumnLength--
			continue
		}
		if ok && sv == onUpdateNow {
			row.updateColumns = append(row.updateColumns, fieldKey)
			row.updateValues = append(row.updateValues, time.Now())
			row.insertColumnLength--
			continue
		}
		row.insertColumns = append(row.insertColumns, fieldKey)
		row.updateColumns = append(row.updateColumns, fieldKey)
		row.insertValues = append(row.insertValues, row.Fields[fieldKey])
		row.updateValues = append(row.updateValues, row.Fields[fieldKey])
	}
}
833160
func (d *Dataset) Row(index int) (map[string]interface{}, error) {
	if index < 0 || index >= d.rows {
		return nil, ErrInvalidRowIndex
	}

	row := make(map[string]interface{})
	for i, e := range d.data[index] {
		switch e.(type) {
		case DynamicColumn:
			row[d.headers[i]] = e.(DynamicColumn)(d.data[index])
		default:
			row[d.headers[i]] = e
		}
	}
	return row, nil
}
342195
func (t *Table) Select(row, column int) *Table {
	t.selectedRow, t.selectedColumn = row, column
	return t
}
191186
func (d *Database) ScanRow(rows *sql.Rows, dst interface{}) error {
	// make sure we always close rows, even if there is a scan error
	defer rows.Close()

	if err := d.Scan(rows, dst); err != nil {
		return err
	}

	return rows.Close()
}
638864
func (f *fragment) row(rowID uint64) *Row {
	f.mu.Lock()
	defer f.mu.Unlock()
	return f.unprotectedRow(rowID)
}
1016742
func ScanRow(rows *sql.Rows, dst interface{}) error {
	return Default.ScanRow(rows, dst)
}
531850
func (m Mat4x2) Rows() (row0, row1, row2, row3 Vec2) {
	return m.Row(0), m.Row(1), m.Row(2), m.Row(3)
}
777595
func (t *Table) AddRow(data ...interface{}) *Table {
	t.mtx.Lock()
	defer t.mtx.Unlock()
	r := NewRow(data...)
	t.Rows = append(t.Rows, r)
	return t
}
592754
func (t *Tabulate) padRow(arr []string, padding int) []string {
	if len(arr) < 1 {
		return arr
	}
	padded := make([]string, len(arr))
	for index, el := range arr {
		b := createBuffer()
		b.Write(" ", padding)
		b.Write(el, 1)
		b.Write(" ", padding)
		padded[index] = b.String()
	}
	return padded
}
1113042
func (r *Rows) row(a ...interface{}) error {
	defer r.Close()

	for _, dp := range a {
		if _, ok := dp.(*sql.RawBytes); ok {
			return VarTypeError("RawBytes isn't allowed on Row()")
		}
	}

	if !r.Next() {
		if err := r.Err(); err != nil {
			return err
		}
		return sql.ErrNoRows
	}
	if err := r.Scan(a...); err != nil {
		return err
	}

	return r.Close()
}
457053
func (t *Tabulate) buildRow(elements []string, padded_widths []int, paddings []int, d Row) string {

	var buffer bytes.Buffer
	buffer.WriteString(d.begin)
	padFunc := t.getAlignFunc()
	// Print contents
	for i := 0; i < len(padded_widths); i++ {
		output := ""
		if len(elements) <= i || (len(elements) > i && elements[i] == " nil ") {
			output = padFunc(padded_widths[i], t.EmptyVar)
		} else if len(elements) > i {
			output = padFunc(padded_widths[i], elements[i])
		}
		buffer.WriteString(output)
		if i != len(padded_widths)-1 {
			buffer.WriteString(d.sep)
		}
	}

	buffer.WriteString(d.end)
	return buffer.String()
}
693139
func (b *UpdateBuilder) Table(table string) *UpdateBuilder {
	b.table = table
	return b
}
1018137
func (m Mat4x3) Row(row int) Vec3 {
	return Vec3{m[row+0], m[row+4], m[row+8]}
}
679816
func (m Mat2x3) Rows() (row0, row1 Vec3) {
	return m.Row(0), m.Row(1)
}
1109606
func (t *TextTable) AddRow(strs ...string) error {
	if len(strs) == 0 {
		return errors.New("no rows")
	}

	if len(strs) > t.width {
		return errors.New("row width should be less than header width")
	}

	padded := make([]string, t.width)
	copy(padded, strs)
	rows := stringsToTableRow(padded)
	t.rows = append(t.rows, rows...)

	t.updateColumnWidth(rows)

	return nil
}
249703
func (it *infoschemaTable) Row(ctx sessionctx.Context, h int64) ([]types.Datum, error) {
	return nil, table.ErrUnsupportedOp
}