Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: return unimplemented error for plpgsql udfs with record input #105738

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/udf_plpgsql
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,10 @@ $$ LANGUAGE PLpgSQL;

statement error control reached end of function without RETURN
SELECT f(1, 2);

statement error PL/pgSQL functions with RECORD input arguments are not yet supported
CREATE FUNCTION f_err(p1 RECORD) RETURNS RECORD AS $$
BEGIN
RETURN p1;
END
$$ LANGUAGE PLpgSQL;
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