Hi
While reivew
https://www.postgresql.org/message-id/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS%3DL7%3DxdhTw%40mail.gmail.com
I accidentally made Claude discover this issue. (At that time, I was
asking Claude about a collation-related issue.)
In RelationInitIndexAccessInfo, we have
```
relation->rd_indcollation = (Oid *)
MemoryContextAllocZero(indexcxt, indnkeyatts * sizeof(Oid));
```
rd_indcollation is corresponds to indnkeyatts, *not* indnatts.
Therefore any rd_indcollation related places loop using indnatts if
is there is wrong.
For example, below infer_collation_opclass_match is wrong.
```
for (natt = 1; natt <= idxRel->rd_att->natts; natt++)
```
Some index type does not support INCLUDE index, but to be
future-proof, if somewhere rd_indcollation related, loop should using
indnkeyatts.
--
jian
https://www.enterprisedb.com/