Dima Pavlov <imyfess@gmail.com> writes:
> The problem was discussed on stackoverflow:
> https://stackoverflow.com/questions/45061966/index-usage-with-single-item-anyarray
Usually, we're not very happy with submissions that reference external
pages for justification; we like to have all the relevant material in our
mail archives.
> 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. That would allow the transformation to succeed
in more cases, like where the array is coming from a parameter rather
than an ARRAY[] construct. That is, you should be able to do this not
only for ARRAY[x] but for any single-element constant array.
regards, tom lane