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

2015-03-13 Thread Jeff Janes
On Mon, Jan 5, 2015 at 7:12 AM, Atri Sharma atri.j...@gmail.com wrote: Hi All, Please forgive if this is a repost. Please find attached patch for supporting ORDER BY clause in CREATE FUNCTION for SRFs. Hi Atri, From the discussion, I don't know if this patch is still being proposed. If

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

2015-01-06 Thread Amit Langote
On 06-01-2015 PM 04:26, Atri Sharma wrote: On Tue, Jan 6, 2015 at 12:43 PM, Amit Langote langote_amit...@lab.ntt.co.jp wrote: Though, I have no strong opinion on whether one thing is good or the other or whether they cover some particular use case all the same. Perhaps you can say that

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

2015-01-06 Thread Jim Nasby
On 1/6/15, 1:00 AM, Ashutosh Bapat wrote: Even checking whether the output of the function is in the right order or not, has its cost. I am suggesting that we can eliminate this cost as well. For example, PostgreSQL does not check whether a function is really immutable or not. Actually, it

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

2015-01-06 Thread Amit Langote
On 07-01-2015 AM 08:33, Jim Nasby wrote: On 1/6/15, 1:00 AM, Ashutosh Bapat wrote: Even checking whether the output of the function is in the right order or not, has its cost. I am suggesting that we can eliminate this cost as well. For example, PostgreSQL does not check whether a function is

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

2015-01-06 Thread Michael Paquier
On Tue, Jan 6, 2015 at 12:12 AM, Atri Sharma atri.j...@gmail.com wrote: I will add the patch to current commitfest. It has been indeed added to the commit fest 2014-12. That's a bit late, moving it to upcoming one 2015-02. Thanks, -- Michael -- Sent via pgsql-hackers mailing list

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

2015-01-06 Thread Ashutosh Bapat
Not in all cases postgres=# create function non_im_immutable_function() returns float as $$ begin return *random()*; end; $$ language plpgsql *immutable*; CREATE FUNCTION postgres=# select proname, provolatile from pg_proc where proname = 'random' or proname = 'non_im_immutable_function';

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

2015-01-05 Thread Ashutosh Bapat
On Mon, Jan 5, 2015 at 8:42 PM, Atri Sharma atri.j...@gmail.com wrote: Hi All, Please forgive if this is a repost. Please find attached patch for supporting ORDER BY clause in CREATE FUNCTION for SRFs. Specifically: CREATE OR REPLACE FUNCTION func1(OUT e int, OUT f int) returns setof

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

2015-01-05 Thread Atri Sharma
The overhead of this patch is small. A new path is added for the preorder keys, and OrderCheck node's additional cost is pretty low, given that it only compares two rows and stores only a single row (previous row seen), hence the memory footprint is minuscule. We can eliminate the new

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

2015-01-05 Thread Ashutosh Bapat
On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma atri.j...@gmail.com wrote: The overhead of this patch is small. A new path is added for the preorder keys, and OrderCheck node's additional cost is pretty low, given that it only compares two rows and stores only a single row (previous row seen),

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

2015-01-05 Thread Atri Sharma
On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote langote_amit...@lab.ntt.co.jp wrote: On 06-01-2015 PM 04:00, Ashutosh Bapat wrote: On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma atri.j...@gmail.com wrote: We can eliminate the new node and put onus or having the right order on the user like

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

2015-01-05 Thread Amit Langote
On 06-01-2015 PM 04:00, Ashutosh Bapat wrote: On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma atri.j...@gmail.com wrote: We can eliminate the new node and put onus or having the right order on the user like we do with volatile setting of the function. That is exactly what the new node does,

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

2015-01-05 Thread Atri Sharma
On Tue, Jan 6, 2015 at 12:30 PM, Ashutosh Bapat ashutosh.ba...@enterprisedb.com wrote: On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma atri.j...@gmail.com wrote: Even checking whether the output of the function is in the right order or not, has its cost. I am suggesting that we can

[HACKERS] Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs

2015-01-05 Thread Atri Sharma
Hi All, Please forgive if this is a repost. Please find attached patch for supporting ORDER BY clause in CREATE FUNCTION for SRFs. Specifically: CREATE OR REPLACE FUNCTION func1(OUT e int, OUT f int) returns setof record as ' SELECT a,b FROM table1 ORDER BY a; ' language 'sql' ORDER BY e; This