Jeff Davis <pgsql@j-davis.com> writes:
> We certainly want attnames for tables to keep it working reasonably
> well for cases where the user might be doing something more interesting
> than a binary upgrade, as you point out. But attribute numbers for
> indexes seem much more reliable: an index with a different attribute
> order is a fundamentally different index.
Right. We went through pretty much this reasoning, as I recall,
when we invented ALTER INDEX ... SET STATISTICS. The original
version used a column name like ALTER TABLE did, and we ran into
exactly the present problem that the names aren't too stable across
dump/restore, and we decided that index column numbers would do
instead. You can't add or drop a column of an index, nor redefine it
meaningfully, except by dropping the whole index which will make any
associated stats go away.
The draft patch I posted allows callers to use attname or attnum
at their option, because I didn't see a reason to restrict that.
But I envisioned that pg_dump would always use attname for table
columns and attnum for index columns.
regards, tom lane