cockroachdb / cockroach

CockroachDB - the open source, cloud-native distributed SQL database.
https://www.cockroachlabs.com
Other
29.51k stars 3.7k forks source link

plpgsql: support RECORD-returning UDFs that don't have concrete type RETURN in the root block #122945

Open yuzefovich opened 2 months ago

yuzefovich commented 2 months ago

We currently don't support cases when RECORD-returning UDF doesn't have a RETURN stmt in the root block that would restrict the wildcard type to a concrete one. For example:

CREATE FUNCTION f1() RETURNS RECORD AS $$
BEGIN
END;
$$ LANGUAGE PLpgSQL;

CREATE FUNCTION f2(b BOOL) RETURNS RECORD AS $$
BEGIN
  IF b THEN
    RETURN f1();
  ELSIF true THEN
    DECLARE
    BEGIN
    END;
  END IF;
END;
$$ LANGUAGE PLpgSQL;

Jira issue: CRDB-38131

yuzefovich commented 2 months ago

This seems similar to #120692, cc @DrewKimball