From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use attnum to identify index columns in pg_restore_attribute_sta
Date: Wed, 26 Feb 2025 21:36:35 +0000
Message-ID: <E1tnP4z-000F4W-2a@gemulon.postgresql.org> (raw)
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Use attnum to identify index columns in pg_restore_attribute_sta
In-Reply-To: <E1tnP4z-000F4W-2a@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox