pgsql: Use attnum to identify index columns in pg_restore_attribute_sta - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Use attnum to identify index columns in pg_restore_attribute_sta
Date
Msg-id E1tnP4z-000F4W-2a@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Use attnum to identify index columns in pg_restore_attribute_stats().

Previously we used attname for both table and index columns, but
that is problematic for indexes because their attnames are assigned
by internal rules that don't guarantee to preserve the names across
dump and reload.  (This is what's causing the remaining buildfarm
failures in cross-version-upgrade tests.)  Fortunately we can use
attnum instead, since there's no such thing as adding or dropping
columns in an existing index.  We met this same problem previously
with ALTER INDEX ... SET STATISTICS, and solved it the same way,
cf commit 5b6d13eec.

In pg_restore_attribute_stats() itself, we accept either attnum or
attname, but the policy used by pg_dump is to always use attname
for tables and attnum for indexes.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Author: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://postgr.es/m/1457469.1740419458@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/40e27d04b4f643cfb78af8db42a1f2e700ec9876

Modified Files
--------------
doc/src/sgml/func.sgml                         |  47 ++---
src/backend/statistics/attribute_stats.c       | 116 +++++++++--
src/bin/pg_dump/pg_dump.c                      | 273 ++++++++++++++++---------
src/bin/pg_dump/pg_dump.h                      |   7 +
src/bin/pg_dump/t/002_pg_dump.pl               |  31 ++-
src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm |   4 +-
src/test/regress/expected/stats_import.out     |  40 +++-
src/test/regress/sql/stats_import.sql          |  30 ++-
8 files changed, 391 insertions(+), 157 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: pgsql: Prepare for Python "Limited API" in PL/Python
Next
From: Jeff Davis
Date:
Subject: pgsql: Remove stray diff introduced by a5cbdeb98a.