Hi Hackers,
Here is a fix for finding D9 from [0].
Currently we can evaluate the expressions in FOR PORTION OF more than
once. If a function is declared STABLE but isn't really, that can
cause inconsistent results. Another way to reach the problem is by
using current_setting, and then calling set_config (for instance from
a trigger). I can't find any other avenues besides those two. I also
tried EvalPlanQual and a STABLE function reading from a table that
gets modified mid-statement by a trigger.
Arguably this is not really a bug, and the fix is somewhat involved
(using a PARAM_EXEC slot to pass the value around). But I wanted to
share a patch in case others think it needs to be fixed. It might
still be worth doing (though not in v19 IMO), since it saves an expr
evaluation every row. I skipped `Backpatch-through: 19` on this patch,
but I'll add it to future versions if we want it in this release.
[0] https://www.postgresql.org/message-id/CA%2BrenyV6QLOJYmLo3gbsg1Y%2BCrho8NqME1jJXgPbO_NgxfBaKQ%40mail.gmail.com
Yours,
--
Paul ~{:-)
pj@illuminatedcomputing.com