Skip to content

Commit

Permalink
expression: fix panic while call Column.VecEvalInt (pingcap#13401)
Browse files Browse the repository at this point in the history
Signed-off-by: Lonng <heng@lonng.org>
  • Loading branch information
lonng authored and XiaTianliang committed Dec 21, 2019
1 parent 144fb87 commit 4f042d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion expression/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (col *Column) Equal(_ sessionctx.Context, expr Expression) bool {
func (col *Column) VecEvalInt(ctx sessionctx.Context, input *chunk.Chunk, result *chunk.Column) error {
if col.RetType.Hybrid() {
it := chunk.NewIterator4Chunk(input)
result.Reset()
result.ResizeInt64(0, false)
for row := it.Begin(); row != it.End(); row = it.Next() {
v, null, err := col.EvalInt(ctx, row)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions expression/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ func (s *testEvaluatorSuite) TestColHybird(c *C) {
c.Assert(v, Equals, result.GetInt64(i))
}

// use a container which has the different field type with bit
result, err = newBuffer(types.ETString, 1024)
c.Assert(err, IsNil)
c.Assert(col.VecEvalInt(ctx, input, result), IsNil)
for row, i := it.Begin(), 0; row != it.End(); row, i = it.Next(), i+1 {
v, _, err := col.EvalInt(ctx, row)
c.Assert(err, IsNil)
c.Assert(v, Equals, result.GetInt64(i))
}

// enum
ft = types.NewFieldType(mysql.TypeEnum)
col.RetType = ft
Expand Down

0 comments on commit 4f042d7

Please sign in to comment.