cockroachdb / cockroachdb/cockroach

sql: support record input types in plpgsql udfs

Open
#105,713 6 comments 0 reactions 1 assignee Claimed by @DrewKimball View on GitHub
A-sql-plpgsql A-sql-routine C-bug docs-done docs-known-limitation T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We are currently unable to support RECORD input arguments in UDFs using the PLpgSQL language. The underlying types in the RECORD need to be determined at assignment time, but in UDFs we currently determine parameter types from what is provided at function creation time. This could probably be fixed by using the resolved type of the argument after argument resolution when building the UDF. In addition, we have some issues with casting to type RECORD that may prevent the usefulness of this feature.

An example query:

```
CREATE FUNCTION f_105120(p1 RECORD)
RETURNS RECORD
STABLE
LANGUAGE PLPGSQL AS $$
BEGIN
RETURN p1;
END $$;

SELECT
col
FROM
(VALUES (f_105120(('hello':::STRING,)::RECORD)), (())) AS t (col)
ORDER BY col;
```

Jira issue: CRDB-29157
Epic CRDB-49018

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.