*: check state when creating table.
This commit is contained in:
@ -52,6 +52,7 @@ func (*testSuite) TestT(c *C) {
|
||||
Name: colName,
|
||||
Offset: 0,
|
||||
FieldType: *types.NewFieldType(mysql.TypeLonglong),
|
||||
State: model.StatePublic,
|
||||
}
|
||||
|
||||
idxInfo := &model.IndexInfo{
|
||||
@ -66,6 +67,7 @@ func (*testSuite) TestT(c *C) {
|
||||
},
|
||||
Unique: true,
|
||||
Primary: true,
|
||||
State: model.StatePublic,
|
||||
}
|
||||
|
||||
tblInfo := &model.TableInfo{
|
||||
@ -73,12 +75,14 @@ func (*testSuite) TestT(c *C) {
|
||||
Name: tbName,
|
||||
Columns: []*model.ColumnInfo{colInfo},
|
||||
Indices: []*model.IndexInfo{idxInfo},
|
||||
State: model.StatePublic,
|
||||
}
|
||||
|
||||
dbInfo := &model.DBInfo{
|
||||
ID: 1,
|
||||
Name: dbName,
|
||||
Tables: []*model.TableInfo{tblInfo},
|
||||
State: model.StatePublic,
|
||||
}
|
||||
|
||||
dbInfos := []*model.DBInfo{dbInfo}
|
||||
|
||||
@ -55,14 +55,26 @@ type Table struct {
|
||||
|
||||
// TableFromMeta creates a Table instance from model.TableInfo.
|
||||
func TableFromMeta(alloc autoid.Allocator, tblInfo *model.TableInfo) table.Table {
|
||||
if tblInfo.State == model.StateNone {
|
||||
log.Fatalf("table %s can't be in none state", tblInfo.Name)
|
||||
}
|
||||
|
||||
t := NewTable(tblInfo.ID, tblInfo.Name.O, nil, alloc)
|
||||
|
||||
for _, colInfo := range tblInfo.Columns {
|
||||
if colInfo.State == model.StateNone {
|
||||
log.Fatalf("column %s can't be in none state", colInfo.Name)
|
||||
}
|
||||
|
||||
col := &column.Col{ColumnInfo: *colInfo}
|
||||
t.Columns = append(t.Columns, col)
|
||||
}
|
||||
|
||||
for _, idxInfo := range tblInfo.Indices {
|
||||
if idxInfo.State == model.StateNone {
|
||||
log.Fatalf("index %s can't be in none state", idxInfo.Name)
|
||||
}
|
||||
|
||||
idx := &column.IndexedCol{
|
||||
IndexInfo: *idxInfo,
|
||||
X: kv.NewKVIndex(t.indexPrefix, idxInfo.Name.L, idxInfo.Unique),
|
||||
|
||||
Reference in New Issue
Block a user