Ron Mayer <rm_pg@cheapcomplexdevices.com> 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
expressions. The particular cases ofselect random() from foo order by 1;select random() from foo order by random();
still behave the same, but that's intentional for backwards
compatibility (and because SQL99 forbids the first, which would mean
there's no way to get the behavior except via deprecated syntax).
Beyond the case of order by/group by items being matched to tlist
items, I'd generally expect that the system should act as though
different textual instances of random() are evaluated separately.
regards, tom lane