ddl

package
v0.0.0-...-b001c0d Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2015 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlterTableOpt int = iota + 1
	AlterAddColumn
	AlterAddConstr
	AlterDropColumn
	AlterDropPrimaryKey
	AlterDropIndex
	AlterDropForeignKey
)

AlterTableSpecification.Action types.

View Source
const (
	ColumnPositionNone int = iota
	ColumnPositionFirst
	ColumnPositionAfter
)

ColumnPosition Types

Variables

View Source
var (
	// ErrExists returned for creating an exist schema or table.
	ErrExists = errors.Errorf("DDL:exists")
	// ErrNotExists returned for dropping a not exist schema or table.
	ErrNotExists = errors.Errorf("DDL:not exists")
)

Pre-defined errors

Functions

This section is empty.

Types

type AlterSpecification

type AlterSpecification struct {
	Action     int
	Name       string
	Constraint *coldef.TableConstraint
	TableOpts  []*coldef.TableOpt
	Column     *coldef.ColumnDef
	Position   *ColumnPosition
}

AlterSpecification alter table specification

func (*AlterSpecification) String

func (as *AlterSpecification) String() string

String implements fmt.Stringer

type ColumnPosition

type ColumnPosition struct {
	// ColumnPositionNone | ColumnPositionFirst | ColumnPositionAfter
	Type int
	// RelativeColumn is the column the newly added column after if type is ColumnPositionAfter
	RelativeColumn string
}

ColumnPosition represent the position of the newly added column

func (*ColumnPosition) String

func (cp *ColumnPosition) String() string

String implements fmt.Stringer

type DDL

type DDL interface {
	CreateSchema(ctx context.Context, name model.CIStr) error
	DropSchema(ctx context.Context, schema model.CIStr) error
	CreateTable(ctx context.Context, ident table.Ident, cols []*coldef.ColumnDef, constrs []*coldef.TableConstraint) error
	DropTable(ctx context.Context, tableIdent table.Ident) (err error)
	CreateIndex(ctx context.Context, tableIdent table.Ident, unique bool, indexName model.CIStr, columnNames []*coldef.IndexColName) error
	DropIndex(ctx context.Context, schema, tableName, indexName model.CIStr) error
	GetInformationSchema() infoschema.InfoSchema
	AlterTable(ctx context.Context, tableIdent table.Ident, spec []*AlterSpecification) error
}

DDL is responsible for updating schema in data store and maintain in-memory InfoSchema cache.

func NewDDL

func NewDDL(store kv.Storage, infoHandle *infoschema.Handle) DDL

NewDDL create new DDL

Jump to

Keyboard shortcuts

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