Fix signed/unsigned integer handling in pg_restore_relation_stats()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix signed/unsigned integer handling in pg_restore_relation_stats()
Date: 2026-08-18 08:36:32
Message-ID: db993f34-e3e1-4e6e-85c3-4f248d2ff29b@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The pg_class fields relpages, relallvisible, and relallfrozen are of
type int32, but the statistics restoration code internally dealt with
them as uint32 for a little bit, after which they would turn back into
int32. This all happens to work, but it doesn't make sense, so I
propose the attached fix.

While researching this, I noticed that we don't appear to document how
page/block counts larger than INT32_MAX are represented in the catalogs.
A C programmer would have a certain expectation, but we shouldn't
expect everyone to guess that. So I'm proposing a small addition to the
catalog documentation to clarify this.

Attachment Content-Type Size
0001-Fix-signed-unsigned-integer-handling-in-pg_restore_r.patch text/plain 5.2 KB
0002-doc-Document-overflow-handling-of-pg_class.relpages-.patch text/plain 2.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message wenhui qiu 2026-08-18 08:39:53 Re: Reduce LEFT/FULL JOIN to ANTI JOIN in more cases
Previous Message Amit Langote 2026-08-18 08:34:32 Re: Re-read conindid under the referenced table's lock in the RI fast path