The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/9.6/static/catalog-pg-index.html
Description:
Hi, all.
While working on some scripts to identify missing indexes and add them to a
given table, I was a little confused by some entries in pg_index's
"indcollation" column like:
indexrelid | 659423
indrelid | 44520
indnatts | 2
indisunique | t
indisprimary | f
indisexclusion | f
indimmediate | t
indisclustered | f
indisvalid | t
indcheckxmin | f
indisready | t
indislive | t
indisreplident | f
indkey | 5 3
indcollation | 0 0
[...]
because 0::OID does not reference a valid pg_collation.oid.
In the IRC, Zr40 helpfully pointed out that the latest documentation readily
clarifies: "For each column in the index key, this contains the OID of the
collation to use for the index, or zero if the column is not of a collatable
data type."
However, I'm using 9.6 and was looking at the matching documentation at
https://www.postgresql.org/docs/9.6/static/catalog-pg-index.html
That page doesn't currently include this note; for 9.6, it only says "For
each column in the index key, this contains the OID of the collation to use
for the index" which had me confused about what I was seeing.
I believe the use of OID 0 in this form has been in place for a long time,
but only the current 9.10 docs say anything about it.
Since I currently run 9.6, I can confirm that the behavior reaches back at
least that far.
For those who generally look at the matching documentation-version as the
database they're running, it would be helpful if the note found in 9.10's
pg_index doc could be included on the relevant previous versions as well.
Thanks!
- Patrick O'Toole
Application Developer
Wyoming Natural Diversity Database
UW Berry Biodiversity Conservation Center
Department 3381, 1000 E. University Av.
Laramie, WY 82071
P: 307-766-3018