On Sun, 2012-11-11 at 15:45 +0000, m-pg@8d.no wrote:
> Bug: When making an index over a function, then selecting a result that does
> not contain the function call (but orders on it), Superfluous function calls
> are made. This possibly because the plan creates a projection containing the
> function value.
It's possible that the function call may be unnecessary, but that is
more of a performance enhancement, not a bug.
Also, the example function has side effects. If you declare functions
with side effects to be IMMUTABLE, you can get all kinds of problems.
You should certainly not rely on an IMMUTABLE function to be called a
specific number of times.
Regards,
Jeff Davis