cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.2k stars 3.82k forks source link

sql: support record input types in plpgsql udfs #105713

Open rharding6373 opened 1 year ago

rharding6373 commented 1 year ago

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-37715

gz#22059

rharding6373 commented 1 year ago

This particular example may be blocked by https://github.com/cockroachdb/cockroach/issues/105669

mgartner commented 1 year ago

Let's determine if this is an acceptable limitation for v23.2.

michae2 commented 1 year ago

We think this is an acceptable limitation for v23.2.

blathers-crl[bot] commented 8 months ago

Hi @yuzefovich, please add branch-* labels to identify which branch(es) this GA-blocker affects.

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.