Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
Date: 2015-01-05 21:14:56
Message-ID: 5741.1420492496@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> writes:
> Related... I'd like to see a way to inline a function that does something like:

> CREATE FUNCTION foo(text) RETURNS int LANGUAGE sql AS $$
> SELECT a FROM b WHERE lower(b.c) = lower($1)
> $$

The reason that's not inlined ATM is that the semantics wouldn't be the
same (ie, what happens if the SELECT returns more than one row). It's
possible they would be the same if we attached a LIMIT 1 to the function's
query, but I'm not 100% sure about that offhand. I'm also not real sure
that you'd still get good performance if there were an inserted LIMIT;
that would disable at least some optimizations.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-01-05 21:50:03 Re: event trigger test exception message
Previous Message Jim Nasby 2015-01-05 20:59:43 Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs