Documentation of pg_index.indcollation missing some info in older versions?

Started by PG Bug reporting formalmost 8 years ago2 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

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

#2Peter Eisentraut
peter_e@gmx.net
In reply to: PG Bug reporting form (#1)
Re: Documentation of pg_index.indcollation missing some info in older versions?

On 22.06.18 00:35, PG Doc comments form wrote:

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."

It's a standard convention in the PostgreSQL system catalogs that OID
zero means "none". There are likely many places where this is not
explicitly documented.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services