From e8fd9a9c311c405b3aaa043ea3577cb059c481c5 Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Wed, 15 Mar 2023 09:13:52 -0700 Subject: [PATCH] colexecbase: fix a recently introduced bug with identity cast This commit fixes a recently introduced bug that can occur when we're randomizing `coldata.BatchSize()` (which we do in tests). In particular, we capped a global singleton at one batch size value, but later we can change it to a higher value, which could lead to index out of bounds. This is now fixed by always using the max batch size. Release note: None --- pkg/sql/colexec/colexecbase/cast.eg.go | 2 +- pkg/sql/colexec/colexecbase/cast_tmpl.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/sql/colexec/colexecbase/cast.eg.go b/pkg/sql/colexec/colexecbase/cast.eg.go index 622859f951e..43695468686 100644 --- a/pkg/sql/colexec/colexecbase/cast.eg.go +++ b/pkg/sql/colexec/colexecbase/cast.eg.go @@ -1246,7 +1246,7 @@ var _ colexecop.ClosableOperator = &castIdentityOp{} var identityOrder []int func init() { - identityOrder = make([]int, coldata.BatchSize()) + identityOrder = make([]int, coldata.MaxBatchSize) for i := range identityOrder { identityOrder[i] = i } diff --git a/pkg/sql/colexec/colexecbase/cast_tmpl.go b/pkg/sql/colexec/colexecbase/cast_tmpl.go index f8a2eabeb04..dedda403992 100644 --- a/pkg/sql/colexec/colexecbase/cast_tmpl.go +++ b/pkg/sql/colexec/colexecbase/cast_tmpl.go @@ -314,7 +314,7 @@ var _ colexecop.ClosableOperator = &castIdentityOp{} var identityOrder []int func init() { - identityOrder = make([]int, coldata.BatchSize()) + identityOrder = make([]int, coldata.MaxBatchSize) for i := range identityOrder { identityOrder[i] = i }