Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
Signed-off-by: wjhuang2016 <[email protected]>
  • Loading branch information
wjhuang2016 committed Jul 9, 2020
1 parent dae1ecb commit 6cd1dda
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,11 +1218,9 @@ func makeupDecodeColMap(sessCtx sessionctx.Context, t table.Table, indexInfo *mo
exprCols, _ := expression.ColumnInfos2ColumnsAndNames(sessCtx, dbName, t.Meta().Name, t.Meta().Columns, t.Meta())
mockSchema := expression.NewSchema(exprCols...)

decodeColMap, err := decoder.BuildFullDecodeColMap(t, mockSchema)
if err != nil {
return nil, err
}
decodeColMap := decoder.BuildFullDecodeColMap(t, mockSchema)

var err error
for _, col := range decodeColMap {
if col.GenExpr != nil {
col.GenExpr, err = col.GenExpr.ResolveIndices(mockSchema)
Expand Down
4 changes: 3 additions & 1 deletion expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,9 @@ func ColumnInfos2ColumnsAndNames(ctx sessionctx.Context, dbName, tblName model.C
if err != nil {
terror.Log(err)
}
columns[i].VirtualExpr = e.Clone()
if e != nil {
columns[i].VirtualExpr = e.Clone()
}
}
}
return columns, names
Expand Down
3 changes: 1 addition & 2 deletions util/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,7 @@ func makeRowDecoder(t table.Table, sctx sessionctx.Context) *decoder.RowDecoder
dbName := model.NewCIStr(sctx.GetSessionVars().CurrentDB)
exprCols, _ := expression.ColumnInfos2ColumnsAndNames(sctx, dbName, t.Meta().Name, t.Meta().Columns, t.Meta())
mockSchema := expression.NewSchema(exprCols...)
decodeColsMap, ignored := decoder.BuildFullDecodeColMap(t, mockSchema)
_ = ignored
decodeColsMap := decoder.BuildFullDecodeColMap(t, mockSchema)

return decoder.NewRowDecoder(t, decodeColsMap)
}
Expand Down
4 changes: 2 additions & 2 deletions util/rowDecoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ func (rd *RowDecoder) DecodeAndEvalRowWithMap(ctx sessionctx.Context, handle kv.
}

// BuildFullDecodeColMap build a map that contains [columnID -> struct{*table.Column, expression.Expression}] from all columns.
func BuildFullDecodeColMap(t table.Table, schema *expression.Schema) (map[int64]Column, error) {
func BuildFullDecodeColMap(t table.Table, schema *expression.Schema) map[int64]Column {
decodeColMap := make(map[int64]Column, len(t.Cols()))
for _, col := range t.Cols() {
decodeColMap[col.ID] = Column{
Col: col,
GenExpr: schema.Columns[col.Offset].VirtualExpr,
}
}
return decodeColMap, nil
return decodeColMap
}

0 comments on commit 6cd1dda

Please sign in to comment.