Alexey Klyukin <alexk@commandprompt.com> writes:
> Is there a reason why only a table free SQL functions are allowed to
> be inlined ? I wonder why a simple SQL function containing only a
> SELECT * FROM table can't be expanded inline ?
If you're thinking of just replacing the call with a sub-SELECT
construct, that's no good in general because it would change the
semantics. We can and do inline such things when the function
returns SETOF and is in the FROM list, but a regular scalar subselect
acts a bit differently than scalar SQL functions historically have.
Keep in mind also that there's not going to be a lot of benefit from
inlining other cases, since a subselect that's not in FROM is not
very optimizable.
regards, tom lane