1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-19 17:02:53 +03:00

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
This commit is contained in:
Tom Lane
2025-02-26 16:36:11 -05:00
parent f734c9fc3a
commit 40e27d04b4
8 changed files with 392 additions and 158 deletions

View File

@@ -345,7 +345,7 @@ sub adjust_old_dumpfile
{
$dump =~ s/
(^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
\s+'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
[^;]*'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
[^;]*'relallvisible',)\s'\d+'::integer
/$1 ''::integer/mgx;
}
@@ -692,7 +692,7 @@ sub adjust_new_dumpfile
{
$dump =~ s/
(^SELECT\s\*\sFROM\spg_catalog\.pg_restore_relation_stats\(
\s+'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
[^;]*'relation',\s'public\.hash_[a-z0-9]*_heap'::regclass,
[^;]*'relallvisible',)\s'\d+'::integer
/$1 ''::integer/mgx;
}