Possible to inline setof SQL UDFs? - Mailing list pgsql-hackers

From richard@bowmansystems.com
Subject Possible to inline setof SQL UDFs?
Date
Msg-id 23000993.221161179959613737.JavaMail.root@zimbra
Whole thread Raw
Responses Re: Possible to inline setof SQL UDFs?
List 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 WHEREnsec.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 WHEREnsec.foo = 1 AND nsec.bar = 5000
) ns ON n.uid = ns.uid;

?


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: GIT patch review
Next
From: Tom Lane
Date:
Subject: Re: Possible to inline setof SQL UDFs?