CREATE FUNCTION generator() RETURNS SETOF INT AS $$
VALUES (1), (2), (3);
$$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION f() RETURNS INT AS $$
BEGIN
RETURN (SELECT generator());
END
$$ LANGUAGE PLpgSQL;
Note the absence of a project-set - the set-returning UDF is being treated as a scalar UDF. This will have the effect of ignoring any values returned by the generator beyond the first. Postgres also allows this setup, but returns an error if the generator returns more than one row. We should do the same.
On current master, given the following functions:
Calling
f()
will produce a plan like this:Note the absence of a project-set - the set-returning UDF is being treated as a scalar UDF. This will have the effect of ignoring any values returned by the generator beyond the first. Postgres also allows this setup, but returns an error if the generator returns more than one row. We should do the same.
Jira issue: CRDB-37076