On 06-01-2015 PM 04:08, Atri Sharma wrote: > On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp
I read what Ashutosh says as that a clause like IMMUTABLE does not entail a node execution. Reading manual for CREATE FUNCTION:
<manual> IMMUTABLE STABLE VOLATILE
These attributes inform the query optimizer about the behavior of the function. </manual>
They declare the shape of the kind of output the function produces and planner simply trusts the declaration meaning it does not add a node to check if, say, an IMMUTABLE function did not actually modify the database or that it is returning the same output for a given input.
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 better.
Personally, I think returning non ordered rows when ORDER BY clause is specifically specified by user is a gross violation of security and could lead to major user application breakdowns, since the application will trust that postgres will return the rows in order since ORDER BY was specified. Of course, what Ashutosh suggested makes the patch much simpler, but I would rather not go down that road.