Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-16 Thread Andrew Gierth
> "Tom" == Tom Lane writes: Tom> Ron Mayer writes: >> [1] http://archives.postgresql.org/pgsql-general/2006-11/msg01544.php Tom> FWIW, the behavior has changed from the time of that discussion --- Tom> we now track sort ordering using EquivalenceClasses, which are able Tom> to distingu

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-16 Thread Tom Lane
Ron Mayer writes: > [1] http://archives.postgresql.org/pgsql-general/2006-11/msg01544.php FWIW, the behavior has changed from the time of that discussion --- we now track sort ordering using EquivalenceClasses, which are able to distinguish different instances of textually equal() volatile expres

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-16 Thread Tom Lane
Andrew Gierth writes: > If you try it using nextval(), you'll notice that the function does > in fact get called twice per row, but one of the results is thrown > away and replaced with the other one. Yeah. The problem is that setrefs.c is generating a tlist for the hashagg node in which both ou

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-16 Thread Andrew Gierth
> "Tom" == Tom Lane writes: >> For bonus weirdness: >> select distinct random(),random() from generate_series(1,10); >> set enable_hashagg=off; >> select distinct random(),random() from generate_series(1,10); >> I think _that_ one is a bug. Tom> Hmm. I think the first one is a bug -

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-16 Thread Tom Lane
Andrew Gierth writes: > For bonus weirdness: > select distinct random(),random() from generate_series(1,10); > set enable_hashagg=off; > select distinct random(),random() from generate_series(1,10); > I think _that_ one is a bug. Hmm. I think the first one is a bug --- the two invocations of r

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-16 Thread Ron Mayer
Andrew Gierth wrote: > This query: > > select random() from generate_series(1,10) order by random(); > produces sorted output. Should it? I recall a workaround from a different thread[1] if specifically were looking for random ordering of random numbers is: select random() from foo order

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-15 Thread Andrew Gierth
> "Tom" == Tom Lane writes: >> This query: >> select random() from generate_series(1,10) order by random(); >> produces sorted output. >> Should it? Tom> It always has; we'd doubtless break some apps if we changed that. For bonus weirdness: select distinct random(),random() from gener

Re: [HACKERS] ORDER BY vs. volatile functions

2009-11-15 Thread Tom Lane
Andrew Gierth writes: > This query: > select random() from generate_series(1,10) order by random(); > produces sorted output. > Should it? It always has; we'd doubtless break some apps if we changed that. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-h

[HACKERS] ORDER BY vs. volatile functions

2009-11-15 Thread Andrew Gierth
This query: select random() from generate_series(1,10) order by random(); produces sorted output. Should it? -- Andrew (irc:RhodiumToad) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers