Skip to content

Commit

Permalink
sql: return unimplemented error for plpgsql udfs with record input
Browse files Browse the repository at this point in the history
PLpgSQL UDFs should support `RECORD` argument types as input, but there
are currently issues with assignment of underlying tuple types in
`RECORD`s that prevent CRDB from supporting them. We explicitly note
this feature as unsupported until the issues are resolved.

Epic: None
Informs: cockroachdb#105713

Release note: None
  • Loading branch information
rharding6373 committed Jun 28, 2023
1 parent 99eaf3b commit d596886
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/sql/opt/optbuilder/create_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,16 @@ func (b *Builder) buildCreateFunction(cf *tree.CreateFunction, inScope *scope) (
if err != nil {
panic(err)
}
if language == tree.FunctionLangSQL && types.IsRecordType(typ) {
panic(pgerror.Newf(pgcode.InvalidFunctionDefinition,
"SQL functions cannot have arguments of type record"))
if types.IsRecordType(typ) {
if language == tree.FunctionLangSQL {
panic(pgerror.Newf(pgcode.InvalidFunctionDefinition,
"SQL functions cannot have arguments of type record"))
} else if language == tree.FunctionLangPLpgSQL {
panic(unimplemented.NewWithIssueDetail(105713,
"PL/pgSQL functions with RECORD input arguments",
"PL/pgSQL functions with RECORD input arguments are not yet supported",
))
}
}

// Add the parameter to the base scope of the body.
Expand Down

0 comments on commit d596886

Please sign in to comment.