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: support record input types in plpgsql udfs #105713

Open
rharding6373 opened this issue Jun 28, 2023 · 4 comments
Open

sql: support record input types in plpgsql udfs #105713

rharding6373 opened this issue Jun 28, 2023 · 4 comments
Labels
A-sql-plpgsql PL/pgSQL language A-sql-routine UDFs and Stored Procedures C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation T-sql-queries SQL Queries Team

Comments

@rharding6373
Copy link
Collaborator

rharding6373 commented Jun 28, 2023

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 rharding6373 added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-routine UDFs and Stored Procedures labels Jun 28, 2023
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Jun 28, 2023
rharding6373 added a commit to rharding6373/cockroach that referenced this issue Jun 28, 2023
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
rharding6373 added a commit to rharding6373/cockroach that referenced this issue Jun 28, 2023
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
@rharding6373
Copy link
Collaborator Author

This particular example may be blocked by #105669

craig bot pushed a commit that referenced this issue Jun 29, 2023
105738: sql: return unimplemented error for plpgsql udfs with record input r=rharding6373 a=rharding6373

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: #105713

Release note: None

Co-authored-by: rharding6373 <[email protected]>
@mgartner
Copy link
Collaborator

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

@mgartner mgartner moved this to 23.2 Release in SQL Queries Jul 24, 2023
@michae2
Copy link
Collaborator

michae2 commented Sep 12, 2023

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

@michae2 michae2 moved this from 23.2 Release to 24.1 Release in SQL Queries Sep 12, 2023
@rharding6373 rharding6373 removed their assignment Jan 30, 2024
Copy link

blathers-crl bot commented Mar 7, 2024

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

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

@yuzefovich yuzefovich added the branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 label Mar 7, 2024
@michae2 michae2 removed the GA-blocker label Apr 9, 2024
@michae2 michae2 moved this from 24.1 Release to 24.2 Release in SQL Queries Apr 9, 2024
@yuzefovich yuzefovich removed the branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 label Apr 9, 2024
@yuzefovich yuzefovich removed their assignment Jul 12, 2024
@mgartner mgartner moved this from 24.2 Release to 24.3 Release in SQL Queries Jul 18, 2024
@DrewKimball DrewKimball added the A-sql-plpgsql PL/pgSQL language label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-plpgsql PL/pgSQL language A-sql-routine UDFs and Stored Procedures C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation T-sql-queries SQL Queries Team
Projects
Status: 25.1 Release
Development

No branches or pull requests

6 participants