Subject: pgsql: pg_dump: scope indAttNames per index in getIndexes()

From: Alexander Korotkov <[email-masked]>
Date: Wed, 03 Jun 2026 10:01:44 +0000

pg_dump: scope indAttNames per index in getIndexes()

getIndexes() declared indAttNames and nindAttNames in the outer
per-table loop, so the names collected for an index on expressions
were carried over to the next plain index in the same table.

This is an internal inconsistency rather than a user-facing bug.
dumpRelationStats_dumper() only walks indexes that have pg_statistic
rows, and ANALYZE only creates those for indexes with expressions,
so the second index in the affected pair is not visited and the stale
array is never consulted.

Fix by moving the two variables into the inner per-index loop so each
iteration starts with a clean slate.

Author: Maksim Melnikov <[email-masked]>
Reviewed-by: Alexander Korotkov <[email-masked]>
Discussion: https://postgr.es/m/[email-masked]
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/298bdd379552148f6043b4595374a7a6fbdd13c3

Modified Files
--------------
src/bin/pg_dump/pg_dump.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

---

From: Michael Paquier <[email-masked]>
Date: Fri, 5 Jun 2026 07:54:41 +0900

Hi Alexander,

> Discussion: https://postgr.es/m/[email-masked]

Regarding this commit, we have as of today:
$ git branch --contains 94c02de89c26
+ REL_18_STABLE
$ git branch --contains 298bdd379552
+ master

And there is nothing on REL_17_STABLE.  Am I missing something or
isn't this just a typo in the Backpatch-through tag?
--
Michael

---

From: Alexander Korotkov <[email-masked]>
Date: Fri, 5 Jun 2026 08:47:51 +0300

Hi, Michael!

> isn't this just a typo in the Backpatch-through tag?

Thank you for pointing.  I've rechecked.  The code that this commit is
intended to fix is introduced by 40e27d04b4f6, which appears first in
PG18.  So, yes, it's a typo in the backpatch tag.  Sorry for that.

------
Regards,
Alexander Korotkov
Supabase