@@ -4594,6 +4594,7 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
4594
4594
}
4595
4595
}
4596
4596
}
4597
+ countCnt := len (columns ) + 1 // +1 for an extra handle column
4597
4598
ds := logicalop.DataSource {
4598
4599
DBName : dbName ,
4599
4600
TableAsName : asName ,
@@ -4604,16 +4605,16 @@ func (b *PlanBuilder) buildDataSource(ctx context.Context, tn *ast.TableName, as
4604
4605
IndexHints : b .TableHints ().IndexHintList ,
4605
4606
IndexMergeHints : indexMergeHints ,
4606
4607
PossibleAccessPaths : possiblePaths ,
4607
- Columns : make ([]* model.ColumnInfo , 0 , len ( columns ) ),
4608
+ Columns : make ([]* model.ColumnInfo , 0 , countCnt ),
4608
4609
PartitionNames : tn .PartitionNames ,
4609
- TblCols : make ([]* expression.Column , 0 , len ( columns ) ),
4610
+ TblCols : make ([]* expression.Column , 0 , countCnt ),
4610
4611
PreferPartitions : make (map [int ][]ast.CIStr ),
4611
4612
IS : b .is ,
4612
4613
IsForUpdateRead : b .isForUpdateRead ,
4613
4614
}.Init (b .ctx , b .getSelectOffset ())
4614
4615
var handleCols util.HandleCols
4615
- schema := expression .NewSchema (make ([]* expression.Column , 0 , len ( columns ) )... )
4616
- names := make ([]* types.FieldName , 0 , len ( columns ) )
4616
+ schema := expression .NewSchema (make ([]* expression.Column , 0 , countCnt )... )
4617
+ names := make ([]* types.FieldName , 0 , countCnt )
4617
4618
for i , col := range columns {
4618
4619
ds .Columns = append (ds .Columns , col .ToInfo ())
4619
4620
names = append (names , & types.FieldName {
0 commit comments