Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wwsDJ-002GDK-0y for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Aug 2026 02:09:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wwsDI-006hwV-0e for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Aug 2026 02:09:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wwsDH-006hwM-2v for pgsql-hackers@lists.postgresql.org; Thu, 20 Aug 2026 02:09:03 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wwsDF-00000000E1V-2mtV for pgsql-hackers@postgresql.org; Thu, 20 Aug 2026 02:09:03 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2cee9b74ee1so12011785ad.3 for ; Wed, 19 Aug 2026 19:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787191740; x=1787796540; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=E1xBD95GdwjeeTmZKaXJor0anNuOcFa2fIe53lfguVw=; b=TQU3r+3ztB+vhQzPcoOPiYRrZhHIIh+NE+modxOTp8iJ6HkmtmvTP0qByYZ8mlcPLB tdiS25NJYcycNS/zUpAx6ER9FGUbprwtlyMkgb0Bf9GpB3YUN5rXnuoh40aH6g3dSNLH AkCJV0J8BDmygsvokjPQbzOVnAoUYcIDIEhPcXXyhKh1muT0NRA1zuExqRtk2Gm8QnuY PUaVIlDv2m9Q5EeZRIav9vdo1991171qCe3JHB6pU6OIURTY3MGxMOZqOHikfRlcAtDc 31+dZdFyZJaVejWEbFmybVCfD50BgKlPT5WCY862hdk7mxvPkgerknRfxu0ieoO6WZoY sNjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787191740; x=1787796540; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=E1xBD95GdwjeeTmZKaXJor0anNuOcFa2fIe53lfguVw=; b=d2WtpqgFPysXp8mg2w1N8/y6JUf6aZT7fNnzibsSbt0HrWWtAzo0OxS7dxw5oHlFN+ +QafEQISKdxxuPXZfTpv4khXgs2XSQeXxj8a13WmvKQAd50yHnB5LA+cxy1nZLT+150p POb9ZufBw2mR10q7Yia9CSPbZnHIoicH5Z5dj4LWrLM31XkJ2iqIwwLotyjCoXyEdwKV SUQTu3CksYrDzhPLPVJxqdl2qzppy8GxoHoQGeXNiMoIimSTpHk1EPeEIBvWJzSnwRRv ANmII80d0xT74GNWzuyaVV00WioAKht6Dpshhpnqu0eR8zrn6ooRKVFWdjeq1LPE2Dr+ ediQ== X-Gm-Message-State: AFuF++nAzsPyHvLIm5/lJJI2YzHTgFEULOYGSXPzg34Ir+T+Lrk1IWrJ qr+JKzt7rm6RIuaPJtv3sB3m6AlsiaDLIEBGmYXxnGb9clDkJnBZhGBd X-Gm-Gg: AR+sD13/fRuvwtLDgcP1ERcwhChUcpzScvY3mZMT4zJNyd0aqs3k+lXAc7HNA6w+zwr Pka5rVkomLD/DxfIf8jojHqCv/OGShbi/8m0BQGbbF6utgHH+aNyuHEV0vjUs5Z0ReqWNIakddb xVtry4n5oOHIN8S9wLJ4bkygkkLNAqbjsyXpF2ynQhwY/eYTzwQI9nzqGzMIJrmwSbUW+ZhEJYJ h4EMbiRciKyhNMq4j6Yk+lfLg9CO2QvWa4PeyHfbMVJ3ojYpDUSa9ooG1USVRMaNRQTksTCzCBt 0kpHGQs1U0t1DsJPs2BdUCJotsEZZFfzUfpd3FFILz9rXvZgNKxaVZXtX95UoFGn3ve8oSJC8Cz 07qLVffJ/JhIofVfE4x86ClmRx6efK+Jrbf8F38zpVyu1SOX+wBUo+s7GQQyLZ7I+g1H8flt3os U6l8r4+POXCdHtuu3t1hVGRoz2VWSklo2pac6ySGTC0+u73DhOPoZvFovtGdZvsJlI8LueNA== X-Received: by 2002:a17:902:fd8f:b0:2c9:df1b:e948 with SMTP id d9443c01a7336-2d5fd5cee10mr184439795ad.4.1787191739515; Wed, 19 Aug 2026 19:08:59 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.125]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d62d58a851sm947065ad.19.2026.08.19.19.08.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2026 19:08:58 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: Fix signed/unsigned integer handling in pg_restore_relation_stats() From: Chao Li In-Reply-To: Date: Thu, 20 Aug 2026 10:08:24 +0800 Cc: pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <17513C42-CBBA-463A-9E33-456E2198EC32@gmail.com> References: To: Peter Eisentraut X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Aug 18, 2026, at 16:36, Peter Eisentraut = wrote: >=20 > 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. >=20 > 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. > = <0001-Fix-signed-unsigned-integer-handling-in-pg_restore_r.patch><0002-doc= -Document-overflow-handling-of-pg_class.relpages-.patch> Overall looks good to me. Only one small comment on 0001: ``` --- a/src/backend/statistics/relation_stats.c +++ b/src/backend/statistics/relation_stats.c @@ -99,13 +99,13 @@ relation_statistics_update(FunctionCallInfo fcinfo) static bool relation_statistics_update_internal(Oid reloid, FunctionCallInfo = fcinfo) { - BlockNumber relpages =3D 0; + int32 relpages =3D 0; ``` relpages is changed to int32, so the later code of = PG_GETARG_UINT32(RELPAGES_ARG) to PG_GETARG_INT32. ``` if (!PG_ARGISNULL(RELPAGES_ARG)) { relpages =3D PG_GETARG_UINT32(RELPAGES_ARG); ``` Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/