// fillRow fills generated columns, auto_increment column and empty column.
// For NOT NULL column, it will return error or use zero value based on sql_mode.
489519
func (e *InsertValues) fillRow(row []types.Datum, hasValue []bool) ([]types.Datum, error) {
	gIdx := 0
	for i, c := range e.Table.Cols() {
		var err error
		// Get the default value for all no value columns, the auto increment column is different from the others.
		row[i], err = e.fillColValue(row[i], i, c, hasValue[i])
		if err != nil {
			return nil, err
		}

		// Evaluate the generated columns.
		if c.IsGenerated() {
			var val types.Datum
			val, err = e.GenExprs[gIdx].Eval(chunk.MutRowFromDatums(row).ToRow())
			gIdx++
			if e.filterErr(err) != nil {
				return nil, err
			}
			row[i], err = table.CastValue(e.ctx, val, c.ToInfo())
			if err != nil {
				return nil, err
			}
		}

		// Handle the bad null error.
		if row[i], err = c.HandleBadNull(row[i], e.ctx.GetSessionVars().StmtCtx); err != nil {
			return nil, err
		}
	}
	return row, nil
}
28540
func (rows Rows) ReadRow() (*resource.MetaValues, error) {
	var metaValues resource.MetaValues
	columns := rows.Header()

	for index, column := range columns {
		metaValue := resource.MetaValue{
			Name:  column,
			Value: rows.records[rows.current][index],
		}
		if meta := rows.Resource.GetMeta(column); meta != nil {
			metaValue.Meta = meta
			metaValue.Name = meta.Name
		}
		metaValues.Values = append(metaValues.Values, &metaValue)
	}

	return &metaValues, nil
}
1352756
func (m *Mat2x3) SetRow(row int, v Vec3) {
	m[row+0], m[row+2], m[row+4] = v[0], v[1], v[2]
}
88789
func (b *batchChecker) getOldRow(ctx sessionctx.Context, t table.Table, handle int64) ([]types.Datum, error) {
	oldValue, ok := b.dupOldRowValues[string(t.RecordKey(handle))]
	if !ok {
		return nil, errors.NotFoundf("can not be duplicated row, due to old row not found. handle %d", handle)
	}
	cols := t.WritableCols()
	oldRow, oldRowMap, err := tables.DecodeRawRowData(ctx, t.Meta(), handle, cols, oldValue)
	if err != nil {
		return nil, err
	}
	// Fill write-only and write-reorg columns with originDefaultValue if not found in oldValue.
	for _, col := range cols {
		if col.State != model.StatePublic && oldRow[col.Offset].IsNull() {
			_, found := oldRowMap[col.ID]
			if !found {
				oldRow[col.Offset], err = table.GetColOriginDefaultValue(ctx, col.ToInfo())
				if err != nil {
					return nil, err
				}
			}
		}
	}
	return oldRow, nil
}
228389
func (d *Datum) SetRow(ds []Datum) {
	d.k = KindRow
	d.x = ds
}
349346
func (t *TextTable) AddRowLine() error {
	rowLine := &tableRow{kind: ROW_LINE}
	t.rows = append(t.rows, rowLine)

	return nil
}
524456
func (t PrettyTable) buildRow(contents ...string) (line string) {
	dots := "..."

	// totalColumns is the minimum of the number of fields config
	// and the number of contents elements.
	totalColumns := len(contents)
	if len(t.cols) < totalColumns {
		totalColumns = len(t.cols)
	}

	// Format fields and construct message
	for i := 0; i < totalColumns; i++ {
		// Default field format without pretty effect
		fieldContent := ""
		fieldFormat := "%s"
		if t.cols[i].maxLen >= 0 {
			// Override field format
			fieldFormat = fmt.Sprintf("%%-%d.%ds", t.cols[i].maxLen, t.cols[i].maxLen)
			// Cut field string and add '...' if length is greater than maxLen
			if len(contents[i]) > t.cols[i].maxLen {
				fieldContent = contents[i][:t.cols[i].maxLen-len(dots)] + dots
			} else {
				fieldContent = contents[i]
			}
		} else {
			fieldContent = contents[i]
		}

		// Add separator if this is not the last column
		if i < totalColumns-1 {
			fieldFormat += t.separator
		}

		// Add the field to the resulted message
		line += console.Colorize(t.cols[i].colorTheme, fmt.Sprintf(fieldFormat, fieldContent))
	}
	return
}
531790
func DefaultQueryHandler(rows *sql.Rows) (bool, error) {
	defer rows.Close()

	numRows := 0
	for rows.Next() {
		numRows++
	}

	return numRows == 1, nil
}
697724
func (s *Sheet) Row(idx int) *Row {
	s.maybeAddRow(idx + 1)
	return s.Rows[idx]
}
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()
}
608194
func (cwc *ColWithCmpFuncManager) CompareRow(lhs, rhs chunk.Row) int {
	for i, col := range cwc.affectedColSchema.Columns {
		ret := cwc.compareFuncs[i](lhs, col.Index, rhs, col.Index)
		if ret != 0 {
			return ret
		}
	}
	return 0
}
932576
func NewRow(data ...interface{}) *Row {
	r := &Row{Cells: make([]*Cell, len(data))}
	for i, d := range data {
		r.Cells[i] = &Cell{Data: d}
	}
	return r
}
820120
func (rows *Rows) Columns() ([]string, error) {
	if rows.token == nil {
		return []string{}, nil
	}
	startElement := rows.token.(xml.StartElement)
	r := xlsxRow{}
	_ = rows.decoder.DecodeElement(&r, &startElement)
	d := rows.f.sharedStringsReader()
	columns := make([]string, len(r.C))
	for _, colCell := range r.C {
		col, _, err := CellNameToCoordinates(colCell.R)
		if err != nil {
			return columns, err
		}
		val, _ := colCell.getValueFrom(rows.f, d)
		columns[col-1] = val
	}
	return columns, nil
}
327577
func (e *InsertValues) getRow(vals []types.Datum) ([]types.Datum, error) {
	row := make([]types.Datum, len(e.Table.Cols()))
	hasValue := make([]bool, len(e.Table.Cols()))
	for i, v := range vals {
		casted, err := table.CastValue(e.ctx, v, e.insertColumns[i].ToInfo())
		if e.filterErr(err) != nil {
			return nil, err
		}

		offset := e.insertColumns[i].Offset
		row[offset] = casted
		hasValue[offset] = true
	}

	return e.fillRow(row, hasValue)
}
1078239
func (g *Grid) AppendRow(row ...Widget) {
	g.rows++

	if len(row) > g.cols {
		g.cols = len(row)
	}

	for i, cell := range row {
		pos := image.Point{i, g.rows - 1}
		g.SetCell(pos, cell)
	}
}
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
}
248325
func (e *ElasticTable) AddRow(row []string) {
	e.rows = append(e.rows, row)
	for i, v := range row {
		l, c := runeWidth(v), &e.cols[i]
		if l < c.min {
			c.min = l
		}
		if l > c.max {
			c.max, c.width = l, l
		}
	}
}