Skip to content

Commit

Permalink
Merge pull request #139867 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-25.1-123099

release-25.1: sql: link to issue for DDL inside of routines
  • Loading branch information
yuzefovich authored Feb 6, 2025
2 parents 4633169 + a8c595d commit f8ae487
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/sql/logictest/testdata/logic_test/udf_unsupported
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ subtest end
subtest ddl

# DDL is not currently supported in UDF bodies.
statement error pgcode 0A000 unimplemented: CREATE TABLE usage inside a function definition
statement error pgcode 0A000 unimplemented: CREATE TABLE usage inside a function definition.*\n.*\n.*issue-v/110080
CREATE FUNCTION err() RETURNS VOID LANGUAGE SQL AS 'CREATE TABLE t (a INT)'

statement error pgcode 0A000 unimplemented: ALTER TABLE usage inside a function definition
statement error pgcode 0A000 unimplemented: ALTER TABLE usage inside a function definition.*\n.*\n.*issue-v/110080
CREATE FUNCTION err() RETURNS VOID LANGUAGE SQL AS 'ALTER TABLE t ADD COLUMN b BOOL'

statement error pgcode 0A000 unimplemented: DROP TABLE usage inside a function definition
statement error pgcode 0A000 unimplemented: DROP TABLE usage inside a function definition.*\n.*\n.*issue-v/110080
CREATE FUNCTION err() RETURNS VOID LANGUAGE SQL AS 'DROP TABLE t'

subtest end
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/opt/optbuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ func (b *Builder) buildStmt(
panic(doBlockVersionErr)
}
default:
if tree.CanModifySchema(stmt) {
panic(unimplemented.NewWithIssuef(110080,
"%s usage inside a function definition is not supported", stmt.StatementTag(),
))
}
panic(unimplemented.Newf("user-defined functions", "%s usage inside a function definition", stmt.StatementTag()))
}
}
Expand Down

0 comments on commit f8ae487

Please sign in to comment.