postgresql/src
Michael Paquier ae39bd23c6 pg_restore: Use dependency-based matching for STATISTICS DATA
The previous approach introduced by 0dd93de69e was weak in terms of
name matching, as an --index=foo could match with a table with the same
name but from a different schema, pulling in more data than necessary.

For example, imagine the following case:
CREATE SCHEMA s1;
CREATE SCHEMA s2;
CREATE TABLE s1.foo (id int);
INSERT INTO s1.foo SELECT generate_series(1,100);
ANALYZE s1.foo;
CREATE TABLE s2.bar (id int);
CREATE INDEX foo ON s2.bar(id);
INSERT INTO s2.bar SELECT generate_series(1,100);
ANALYZE s2.bar;

A targetted pg_restore --index=foo would grab the relation and attribute
stats of s1.foo on top of the index s2.foo, which is incorrect.  This
commit fixes this scenario by relying on a lookup of the dependencies of
a STATISTICS DATA TOC entry, checking if a TOC entry depends on an index
or another relkind before matching with the names of the objects wanted
for the restore.

Discussion: https://postgr.es/m/ajDBwpxs-otl585H@paquier.xyz
Backpatch-through: 18
2026-06-16 15:58:12 +09:00
..
backend Reject oversized MCV lists in pg_restore_extended_stats() 2026-06-16 15:14:58 +09:00
bin pg_restore: Use dependency-based matching for STATISTICS DATA 2026-06-16 15:58:12 +09:00
common Fix off-by-one with NFC recomposition for Hangul U+11A7 (TBASE) 2026-06-05 07:50:08 +09:00
fe_utils psql: Fix expanded aligned output 2026-06-08 14:37:51 +09:00
include Fix various query jumble comments 2026-06-16 13:42:21 +12:00
interfaces Fix PQdescribePrepared with more than 7498 params 2026-06-15 11:28:45 +03:00
makefiles Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
pl Translation updates 2026-06-01 12:13:54 +02:00
port pg_test_timing: Show additional TSC clock source debug info 2026-05-16 11:51:34 -04:00
template Switch the semaphore API on Solaris to unnamed POSIX. 2026-03-14 14:10:32 -04:00
test Reject oversized MCV lists in pg_restore_extended_stats() 2026-06-16 15:14:58 +09:00
timezone Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
tools Modernize pg_bsd_indent's error/warning reporting code. 2026-06-15 12:22:55 -04:00
tutorial Pre-beta mechanical code beautification, step 1: run pgindent. 2026-05-13 10:34:17 -04:00
.gitignore
DEVELOPERS
Makefile Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
Makefile.global.in Update Unicode data to CLDR 48.2 2026-04-13 11:13:36 +02:00
Makefile.shlib Restore AIX support. 2026-02-23 13:34:22 -05:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00