Possible to inline setof SQL UDFs?

From: richard(at)bowmansystems(dot)com
To: pgsql-hackers(at)postgresql(dot)org
Subject: Possible to inline setof SQL UDFs?
Date: 2007-05-23 22:33:33
Message-ID: 23000993.221161179959613737.JavaMail.root@zimbra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm curious if there is a reason that SQL setof UDFs couldn't be inlined?

For example, given a sable setof SQL UDF like
CREATE TYPE uids AS (uid integer);

CREATE FUNCTION needs_secure(integer, integer) RETURNS SETOF uids AS $_$
SELECT uid FROM needs nsec WHERE
nsec.foo = $1 AND nsec.bar = $2
$_$ LANGUAGE SQL STABLE;

Couldn't any call to this function
SELECT * FROM needs n JOIN needs_secure( 1, 5000 ) ns ON n.uid = ns.uid;

Become
SELECT * FROM needs n JOIN (
SELECT uid FROM needs nsec WHERE
nsec.foo = 1 AND nsec.bar = 5000
) ns ON n.uid = ns.uid;

?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-05-23 23:27:13 Re: Possible to inline setof SQL UDFs?
Previous Message Heikki Linnakangas 2007-05-23 20:41:52 Re: [HACKERS] GIT patch review