From 12c659085a97bc56e046d0cc9d2f6c7d37f10fa9 Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Wed, 18 Jan 2023 09:33:06 -0800 Subject: [PATCH] sem/builtins: fix population of generator builtins Generator builtins are such that they should not evaluated as scalars (i.e. `Fn` and `FnWithExprs` evaluation functions should not be called on them). In order to highlight this as an assertion failure we initialize generator builtins with special functions in those two fields. However, previously the initialization was broken since we were modifying a copy of the builtin struct, and this is now fixed. There isn't much of a production impact though (if we ever tried to evaluate the generator as a scalar, it'd result in a nil pointer which would be caught by the vectorized engine panic-catcher; also, it seems very hard if possible to trigger this without the testing randomizations), so there is no release note. Release note: None --- pkg/sql/sem/builtins/all_builtins.go | 3 ++- pkg/sql/sem/builtins/geo_builtins.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/sql/sem/builtins/all_builtins.go b/pkg/sql/sem/builtins/all_builtins.go index e118100f27d2..f707eb6d660a 100644 --- a/pkg/sql/sem/builtins/all_builtins.go +++ b/pkg/sql/sem/builtins/all_builtins.go @@ -98,7 +98,8 @@ func addResolvedFuncDef( } func registerBuiltin(name string, def builtinDefinition) { - for _, overload := range def.overloads { + for i := range def.overloads { + overload := &def.overloads[i] fnCount := 0 if overload.Fn != nil { fnCount++ diff --git a/pkg/sql/sem/builtins/geo_builtins.go b/pkg/sql/sem/builtins/geo_builtins.go index f3bd40b0dfd0..e86fcd41531b 100644 --- a/pkg/sql/sem/builtins/geo_builtins.go +++ b/pkg/sql/sem/builtins/geo_builtins.go @@ -7416,7 +7416,7 @@ func appendStrArgOverloadForGeometryArgOverloads(def builtinDefinition) builtinD copy(newOverloads, def.overloads) for i := range def.overloads { - // Define independntly as it is used by a closure below. + // Define independently as it is used by a closure below. ov := def.overloads[i] paramTypes, ok := ov.Types.(tree.ParamTypes)