diff --git a/pkg/sql/logictest/testdata/logic_test/udf_params b/pkg/sql/logictest/testdata/logic_test/udf_params index 52b75370f957..2c61e8205fde 100644 --- a/pkg/sql/logictest/testdata/logic_test/udf_params +++ b/pkg/sql/logictest/testdata/logic_test/udf_params @@ -15,6 +15,9 @@ CREATE FUNCTION f(OUT param INT) RETURNS VOID AS $$ SELECT 1; $$ LANGUAGE SQL; statement error pgcode 42P13 pq: function result type must be int because of OUT parameters CREATE FUNCTION f(OUT param INT) RETURNS RECORD AS $$ SELECT 1; $$ LANGUAGE SQL; +statement error pgcode 42P13 SQL functions cannot have arguments of type VOID +CREATE FUNCTION f(param VOID) RETURNS UUID LANGUAGE SQL AS $$ SELECT NULL $$; + statement ok CREATE FUNCTION f(OUT param INT) RETURNS INT AS $$ SELECT 1; $$ LANGUAGE SQL; diff --git a/pkg/sql/opt/optbuilder/create_function.go b/pkg/sql/opt/optbuilder/create_function.go index 26eec349e66c..025bc8edbd2e 100644 --- a/pkg/sql/opt/optbuilder/create_function.go +++ b/pkg/sql/opt/optbuilder/create_function.go @@ -175,8 +175,13 @@ func (b *Builder) buildCreateFunction(cf *tree.CreateRoutine, inScope *scope) (o if param.Class == tree.RoutineParamInOut && param.Name == "" { panic(unimplemented.NewWithIssue(121251, "unnamed INOUT parameters are not yet supported")) } - if param.IsInParam() && typ.IsPolymorphicType() { - sawPolymorphicInParam = true + if param.IsInParam() { + if typ.Family() == types.VoidFamily { + panic(pgerror.Newf(pgcode.InvalidFunctionDefinition, "SQL functions cannot have arguments of type VOID")) + } + if typ.IsPolymorphicType() { + sawPolymorphicInParam = true + } } if param.IsOutParam() { outParamTypes = append(outParamTypes, typ) diff --git a/pkg/workload/schemachange/operation_generator.go b/pkg/workload/schemachange/operation_generator.go index a481f0260f5b..30dfd8ae83cb 100644 --- a/pkg/workload/schemachange/operation_generator.go +++ b/pkg/workload/schemachange/operation_generator.go @@ -3960,7 +3960,8 @@ FROM if typeVal.Identical(types.AnyTuple) || typeVal.IsWildcardType() || typeVal == types.RegClass || - typeVal.Family() == types.OidFamily { + typeVal.Family() == types.OidFamily || + typeVal.Family() == types.VoidFamily { continue } if pgVectorNotSupported && typeVal.Family() == types.PGVectorFamily {