Tom Lane wrote:
> All that this optimization might do is to further cut the fraction of
> table rows at which the volatile function actually gets checked. So
> I'm not seeing that it would break any code that worked reliably before.
Hmm; what about
SELECT min(x), min(x) FROM tab WHERE random() > 0.5;
Applying the optimization would mean the two min(x) expressions would
likely be different, which seems rather weird.
> Still, if it makes you feel at all uncomfortable, we can just refuse
> the optimization in such cases.
I'd say that's probably safest.
-Neil