table

package
v0.0.0-...-887f819 Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TableFromMeta func(alloc autoid.Allocator, tblInfo *model.TableInfo) (Table, error)

TableFromMeta builds a table.Table from *model.TableInfo. Currently, it is assigned to tables.TableFromMeta in tidb package's init function.

Functions

func GetColDefaultValue

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

GetColDefaultValue gets default value of the column.

Types

type RecordIterFunc

type RecordIterFunc func(h int64, rec []types.Datum, cols []*column.Col) (more bool, err error)

RecordIterFunc is used for low-level record iteration.

type Table

type Table interface {
	// IterRecords iterates records in the table and calls fn.
	IterRecords(ctx context.Context, startKey kv.Key, cols []*column.Col, fn RecordIterFunc) error

	// RowWithCols returns a row that contains the given cols.
	RowWithCols(ctx context.Context, h int64, cols []*column.Col) ([]types.Datum, error)

	// Row returns a row for all columns.
	Row(ctx context.Context, h int64) ([]types.Datum, error)

	// Cols returns the columns of the table which is used in select.
	Cols() []*column.Col

	// Indices returns the indices of the table.
	Indices() []*column.IndexedCol

	// RecordPrefix returns the record key prefix.
	RecordPrefix() kv.Key

	// IndexPrefix returns the index key prefix.
	IndexPrefix() kv.Key

	// FirstKey returns the first key.
	FirstKey() kv.Key

	// RecordKey returns the key in KV storage for the column.
	RecordKey(h int64, col *column.Col) kv.Key

	// Truncate truncates the table.
	Truncate(ctx context.Context) (err error)

	// AddRecord inserts a row into the table.
	AddRecord(ctx context.Context, r []types.Datum) (recordID int64, err error)

	// UpdateRecord updates a row in the table.
	UpdateRecord(ctx context.Context, h int64, currData []types.Datum, newData []types.Datum, touched map[int]bool) error

	// RemoveRecord removes a row in the table.
	RemoveRecord(ctx context.Context, h int64, r []types.Datum) error

	// AllocAutoID allocates an auto_increment ID for a new row.
	AllocAutoID() (int64, error)

	// RebaseAutoID rebases the auto_increment ID base.
	// If allocIDs is true, it will allocate some IDs and save to the cache.
	// If allocIDs is false, it will not allocate IDs.
	RebaseAutoID(newBase int64, allocIDs bool) error

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

	// LockRow locks a row.
	LockRow(ctx context.Context, h int64, forRead bool) error

	// Seek returns the handle greater or equal to h.
	Seek(ctx context.Context, h int64) (handle int64, found bool, err error)
}

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