Skip to content

Commit cb1eed7

Browse files
committed
opt/execbuilder: fix buggy allocation of result columns
This commit fixes a subtle bug where a slice was always allocated with zero capacity, rather than the known required capacity. This bug caused no user facing issues, but did cause extra allocations when appending to the slice. Release note: None
1 parent ef369f2 commit cb1eed7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/sql/opt/exec/execbuilder/relational.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,9 @@ func (b *Builder) buildProject(prj *memo.ProjectExpr) (execPlan, error) {
10511051
}
10521052

10531053
var res execPlan
1054-
exprs := make(tree.TypedExprs, 0, len(projections)+prj.Passthrough.Len())
1055-
cols := make(colinfo.ResultColumns, 0, len(exprs))
1054+
numExprs := len(projections) + prj.Passthrough.Len()
1055+
exprs := make(tree.TypedExprs, 0, numExprs)
1056+
cols := make(colinfo.ResultColumns, 0, numExprs)
10561057
ctx := input.makeBuildScalarCtx()
10571058
for i := range projections {
10581059
item := &projections[i]

0 commit comments

Comments
 (0)