| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | use indnkeyatts not indnatts in loops that read rd_indcollation |
| Date: | 2026-10-09 08:40:45 |
| Message-ID: | CACJufxGWVB6dwPaQz25eXm-sdcxOWNfbfTHUd5wG41-zDcG6OA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-using-indnkeyatts-not-using-indnatts-in-some-loops.patch | text/x-patch | 4.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Geier | 2026-10-09 09:11:39 | Re: [PATCH v1] Batch B-tree TIDs when building a bitmap |
| Previous Message | Peter Smith | 2026-10-09 08:39:30 | Re: PSQL schema "describe" \dn is not escaping quotes |