table

package
v0.0.0-...-08a93fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrIndexOutBound returns for index column offset out of bound.
	ErrIndexOutBound = terror.ClassTable.New(codeIndexOutBound, "index column offset out of bound")
	// ErrUnsupportedOp returns for unsupported operation.
	ErrUnsupportedOp = terror.ClassTable.New(codeUnsupportedOp, "operation not supported")
	// ErrRowNotFound returns for row not found.
	ErrRowNotFound = terror.ClassTable.New(codeRowNotFound, "can not find the row")
	// ErrTableStateCantNone returns for table none state.
	ErrTableStateCantNone = terror.ClassTable.New(codeTableStateCantNone, "table can not be in none state")
	// ErrColumnStateCantNone returns for column none state.
	ErrColumnStateCantNone = terror.ClassTable.New(codeColumnStateCantNone, "column can not be in none state")
	// ErrColumnStateNonPublic returns for column non-public state.
	ErrColumnStateNonPublic = terror.ClassTable.New(codeColumnStateNonPublic, "can not use non-public column")
	// ErrIndexStateCantNone returns for index none state.
	ErrIndexStateCantNone = terror.ClassTable.New(codeIndexStateCantNone, "index can not be in none state")
	// ErrInvalidRecordKey returns for invalid record key.
	ErrInvalidRecordKey = terror.ClassTable.New(codeInvalidRecordKey, "invalid record key")
)
View Source
var MockTableFromMeta func(tableInfo *model.TableInfo) Table

MockTableFromMeta only serves for test.

Functions

func CastValue

func CastValue(ctx context.Context, val types.Datum, col *model.ColumnInfo) (casted types.Datum, err error)

CastValue casts a value based on column type.

func CastValues

func CastValues(ctx context.Context, rec []types.Datum, cols []*Column, ignoreErr bool) (err error)

CastValues casts values based on columns type.

func CheckNotNull

func CheckNotNull(cols []*Column, row []types.Datum) error

CheckNotNull checks if row has nil value set to a column with NotNull flag set.

func CheckOnce

func CheckOnce(cols []*Column) error

CheckOnce checks if there are duplicated column names in cols.

func ColDescFieldNames

func ColDescFieldNames(full bool) []string

ColDescFieldNames returns the fields name in result set for desc and show columns.

func GetColDefaultValue

func GetColDefaultValue(ctx context.Context, col *model.ColumnInfo) (types.Datum, bool, error)

GetColDefaultValue gets default value of the column.

func GetZeroValue

func GetZeroValue(col *model.ColumnInfo) types.Datum

GetZeroValue gets zero value for given column type.

Types

type ColDesc

type ColDesc struct {
	Field        string
	Type         string
	Collation    string
	Null         string
	Key          string
	DefaultValue interface{}
	Extra        string
	Privileges   string
	Comment      string
}

ColDesc describes column information like MySQL desc and show columns do.

func NewColDesc

func NewColDesc(col *Column) *ColDesc

NewColDesc returns a new ColDesc for a column.

type Column

type Column model.ColumnInfo

Column provides meta data describing a table column.

func FindCol

func FindCol(cols []*Column, name string) *Column

FindCol finds column in cols by name.

func FindCols

func FindCols(cols []*Column, names []string) ([]*Column, error)

FindCols finds columns in cols by names.

func FindOnUpdateCols

func FindOnUpdateCols(cols []*Column) []*Column

FindOnUpdateCols finds columns which have OnUpdateNow flag.

func ToColumn

func ToColumn(col *model.ColumnInfo) *Column

ToColumn converts a *model.ColumnInfo to *Column.

func (*Column) CheckNotNull

func (c *Column) CheckNotNull(data types.Datum) error

CheckNotNull checks if nil value set to a column with NotNull flag is set.

func (*Column) GetTypeDesc

func (c *Column) GetTypeDesc() string

GetTypeDesc gets the description for column type.

func (*Column) IsPKHandleColumn

func (c *Column) IsPKHandleColumn(tbInfo *model.TableInfo) bool

IsPKHandleColumn checks if the column is primary key handle column.

func (*Column) String

func (c *Column) String() string

String implements fmt.Stringer interface.

func (*Column) ToInfo

func (c *Column) ToInfo() *model.ColumnInfo

ToInfo casts Column to model.ColumnInfo

type Table

type Table interface {

	// Meta returns TableInfo.
	Meta() *model.TableInfo
}

Table is used to retrieve and modify rows in table.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL