Documentation ¶
Index ¶
Constants ¶
const (
Name = "INFORMATION_SCHEMA"
)
Information Schema Name.
Variables ¶
var ( // ErrDatabaseDropExists returns for dropping a non-existent database. ErrDatabaseDropExists = terror.ClassSchema.New(codeDBDropExists, "database doesn't exist") // ErrDatabaseNotExists returns for database not exists. ErrDatabaseNotExists = terror.ClassSchema.New(codeDatabaseNotExists, "database not exists") // ErrTableNotExists returns for table not exists. ErrTableNotExists = terror.ClassSchema.New(codeTableNotExists, "table not exists") // ErrColumnNotExists returns for column not exists. ErrColumnNotExists = terror.ClassSchema.New(codeColumnNotExists, "field not exists") // ErrForeignKeyNotMatch returns for foreign key not match. ErrForeignKeyNotMatch = terror.ClassSchema.New(codeCannotAddForeign, "foreign key not match") // ErrForeignKeyExists returns for foreign key exists. ErrForeignKeyExists = terror.ClassSchema.New(codeCannotAddForeign, "foreign key already exists") // ErrForeignKeyNotExists returns for foreign key not exists. ErrForeignKeyNotExists = terror.ClassSchema.New(codeForeignKeyNotExists, "foreign key not exists") // ErrDatabaseExists returns for database already exists. ErrDatabaseExists = terror.ClassSchema.New(codeDatabaseExists, "database already exists") // ErrTableExists returns for table already exists. ErrTableExists = terror.ClassSchema.New(codeTableExists, "table already exists") // ErrTableDropExists returns for dropping a non-existent table. ErrTableDropExists = terror.ClassSchema.New(codeBadTable, "unknown table") // ErrColumnExists returns for column already exists. ErrColumnExists = terror.ClassSchema.New(codeColumnExists, "Duplicate column") // ErrIndexExists returns for index already exists. ErrIndexExists = terror.ClassSchema.New(codeIndexExists, "Duplicate Index") )
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds a new InfoSchema.
func NewBuilder ¶
NewBuilder creates a new Builder with a Handle.
func (*Builder) Build ¶
func (b *Builder) Build()
Build sets new InfoSchema to the handle in the Builder.
func (*Builder) InitWithDBInfos ¶
InitWithDBInfos initializes an empty new InfoSchema with a slice of DBInfo and schema version.
func (*Builder) InitWithOldInfoSchema ¶
InitWithOldInfoSchema initializes an empty new InfoSchema by copies all the data from old InfoSchema.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle handles information schema, including getting and setting.
func (*Handle) EmptyClone ¶
EmptyClone creates a new Handle with the same store and memSchema, but the value is not set.
func (*Handle) GetPerfHandle ¶
func (h *Handle) GetPerfHandle() perfschema.PerfSchema
GetPerfHandle gets performance schema from handle.
type InfoSchema ¶
type InfoSchema interface { SchemaByName(schema model.CIStr) (*model.DBInfo, bool) SchemaExists(schema model.CIStr) bool TableByName(schema, table model.CIStr) (table.Table, error) TableExists(schema, table model.CIStr) bool SchemaByID(id int64) (*model.DBInfo, bool) TableByID(id int64) (table.Table, bool) AllocByID(id int64) (autoid.Allocator, bool) AllSchemaNames() []string AllSchemas() []*model.DBInfo Clone() (result []*model.DBInfo) SchemaTables(schema model.CIStr) []table.Table SchemaMetaVersion() int64 }
InfoSchema is the interface used to retrieve the schema information. It works as a in memory cache and doesn't handle any schema change. InfoSchema is read-only, and the returned value is a copy. TODO: add more methods to retrieve tables and columns.
func MockInfoSchema ¶
func MockInfoSchema(tbList []*model.TableInfo) InfoSchema
MockInfoSchema only serves for test.