Hi Chi,
Thanks for the clear report. I can reproduce it, but I am leaning into this
is not
a bug.
We don't promise how many times a volatile function runs, and
David made that point about Memoize in [1]. Tom recently said similar
things about volatile functions in sub-selects [2] and in WHERE [3].
[1]
https://postgr.es/m/CAApHDvopmkAOecfQczbOvkVvo=OK89rABXujVYsFevsk77Dqdw@mail.gmail.com
[2] https://postgr.es/m/3410601.1794431320@sss.pgh.pa.us
[3] https://postgr.es/m/844264.1795464073@sss.pgh.pa.us
Thanks,
Shihao