diff --git a/pkg/sql/alter_table.go b/pkg/sql/alter_table.go index 8f59047dd1bc..10cb850f01b5 100644 --- a/pkg/sql/alter_table.go +++ b/pkg/sql/alter_table.go @@ -1104,6 +1104,9 @@ func sanitizeColumnExpression( return nil, "", pgerror.WithCandidateCode(err, pgcode.DatatypeMismatch) } + if err := funcdesc.MaybeFailOnUDFUsage(typedExpr, context, p.EvalContext().Settings.Version.ActiveVersionOrEmpty(p.ctx)); err != nil { + return nil, "", err + } s := tree.Serialize(typedExpr) return typedExpr, s, nil } diff --git a/pkg/sql/logictest/testdata/logic_test/udf b/pkg/sql/logictest/testdata/logic_test/udf index b72789945a2e..0d74816297af 100644 --- a/pkg/sql/logictest/testdata/logic_test/udf +++ b/pkg/sql/logictest/testdata/logic_test/udf @@ -583,6 +583,12 @@ ALTER TABLE test_tbl_t ADD COLUMN c int DEFAULT (test_tbl_f()); statement error pq: unimplemented: usage of user-defined function from relations not supported ALTER TABLE test_tbl_t ADD COLUMN c int ON UPDATE (test_tbl_f()); +statement error pq: unimplemented: usage of user-defined function from relations not supported +ALTER TABLE test_tbl_t ALTER COLUMN b SET DEFAULT (test_tbl_f()); + +statement error pq: unimplemented: usage of user-defined function from relations not supported +ALTER TABLE test_tbl_t ALTER COLUMN b SET ON UPDATE (test_tbl_f()); + subtest disallow_udf_in_views_and_udf statement ok