I wrote:
> Dima Pavlov <imyfess(at)gmail(dot)com> writes:
>> That's my first patch so I will be grateful for constructive criticism.
> I think it would be better to do this in the planner, see specifically
> eval_const_expressions.
BTW, currently eval_const_expressions doesn't know anything about
ScalarArrayOpExpr, but there's a patch pending to improve that:
https://commitfest.postgresql.org/14/1136/
You should probably build your revised patch as a follow-on to that
one, else we're going to have merge conflicts.
regards, tom lane