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 1wB6jT-000k5f-2o for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Apr 2026 07:56:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wB6jR-00AU42-0G for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Apr 2026 07:56:49 +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 1wB6jQ-00AU3t-0r for pgsql-hackers@lists.postgresql.org; Fri, 10 Apr 2026 07:56:49 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wB6jK-00000000Jig-1VJw for pgsql-hackers@postgresql.org; Fri, 10 Apr 2026 07:56:48 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 5CFFFEC0070; Fri, 10 Apr 2026 03:56:39 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 10 Apr 2026 03:56:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1775807799; x=1775894199; bh=4iLRBCh5Gn EC/FabJPiJ4mEmFDMZPM6vuCsf8K5AdwM=; b=dAMNAFGJBiH+gmaWkdfLMYOdsB GujdE7iDBXvw9Zyobrx6dTkRpGgfYK0ebc1yqpnBoBFGcWyeb3EpUJvYHZBUzeK/ XkwzbaNZwVoh5fc6f08mgzeiwLdjsdiv27oklwWdhSSuQhytbZ1IFDwFJR/QDVco SoINxhdOLF1Q+4AQ9XsbaX+R1Buh1hlaCQ/jX5kGlma+Xkgi3zbQmOYrc2SnNF3K SmgJiXyhPPHuhTne11EeRnHmDUm2JTORd6Ikj/gOlMKb+j6rWH6lQDuhVl+Dq+k1 BBj3twezP9uwbMp1aAlOgR5mDG+XaUiqaxFtPZZijOTBCG1QqR3uFwfdxOGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1775807799; x=1775894199; bh=4iLRBCh5GnEC/FabJPiJ4mEmFDMZPM6vuCs f8K5AdwM=; b=sHHGdSUK29ALLD7Khdnju8Y2gdI+NPDOUrpesoRg4tRVAjN3jPZ EJmwtDHj1Y3gWBjU1yAl/7SrcwxYJ+GBub+sRp3FgS10dcY3E/2VBrAUtIlTtZlL 2pHCHEjepC+7QTe7WhqKkcB7f2M3O5cehkdKFVmUQ/iRk1IJ3tGA4KYs3r43tDK1 poN/5SHQbO9YFDh3R26X6Z/GFKoBK+330NyqDnVWTCBYOiCtRjT52Tw/0AvF9qdK 6zEM5/z6j2938nHw/jHhnRRn2jBtfgdgbPX7CRjE0kWbbB0ZsdEaASCyU9yv1qtH 4yPXUqM6tZCESO5zSqm2x7qOGgPRrJvCvOQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddvkeekiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhepfffhvfevuf fkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgv rhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpe egffejvefgveduvdejtddvtdeijeehudeuledvudeftdfgfeejvdekveekiedvvdenucff ohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih iidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheplh hirdgvvhgrnhdrtghhrghosehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdq hhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Apr 2026 03:56:38 -0400 (EDT) Date: Fri, 10 Apr 2026 16:56:33 +0900 From: Michael Paquier To: Chao Li Cc: PostgreSQL-development Subject: Re: Fix pgstat_database.c to honor passed database OIDs Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mW9BFBXd1wtjrPIe" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --mW9BFBXd1wtjrPIe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 10, 2026 at 03:12:41PM +0900, Michael Paquier wrote: > If we decide to expand pgstat_reset() in other contexts in the > back-branches, we'd be silently trapped as well. >=20 > The connect and disconnect calls are less critical, perhaps we could > remove the argument altogether, but I cannot get excited about that > either as some extensions may rely on these as currently designed. >=20 > I cannot look at that today, will do so later.. - dbref =3D pgstat_get_entry_ref_locked(PGSTAT_KIND_DATABASE, MyDatabase= Id, InvalidOid, + if (!OidIsValid(dboid)) + return; + + dbref =3D pgstat_get_entry_ref_locked(PGSTAT_KIND_DATABASE, dboid, Inv= alidOid, false); This bypass of an invalid database OID is actually incorrect in the patch. There is a stats entry with a database OID of 0, documented as such in [1] for shared objects. There is one test in the main regression test suite that triggers this case: SELECT pg_stat_reset_single_table_counters('pg_shdescription'::regclass); The short answer is to remove this check based on OidIsValid(), and allow the timestamp be reset for this entry of 0 rather than ignore the update. [1]: https://www.postgresql.org/docs/devel/monitoring-stats.html#MONITORING= -PG-STAT-DATABASE-VIEW -- Michael --mW9BFBXd1wtjrPIe Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmnYrTEACgkQnvQgOdby QH2hDQ/+L+8NYllLYiRh0BGH82ZMxWGILkJAD7F3BgFDZ2gnGAbt8dHY1hQRT59M Bt3HYACyimfcat3SeywFr3jsx4zEZFRqpPoSUeJENg1Ut7VDnB+ZKUmkBzv1Blzm 1YVaCSDhmbOWvj/49q9KddaHCTK7rnEVk1D4T7hI9Qn84DnW5+EOKm50Y6h+OMsA K/b1CYDSajQuZMteLCRQY669kUMPsttseqOkSwSWcXL5VY7nmcs/XpCsJRqOIa2/ +Ro85ttJK4BiWymi7uEHcTYv6LZz/DvScSEyUKZtc6z8EkBRUS0xNOCTO1Jgf2Q9 ujDZAMOLjjtiD/hpRYrgiqKLemkK20wkaWzdkrxCIlDdUJTDx2o/IAoghzf+7mh8 hldMr9Q1gz//Elw72UHBKDwAq9O1MYjjYDUuL+RAcqc8nUmVPSH/qngHPmsnU359 /7Jq1w2GhE3HLYD8ApULHKYa2jjVgXniX0MeWTO5cpp9OOipjgAUiVOEvQbOjvy7 GH2PqPq8Nr4qGSalTiLLvilO6eefOlbtwWcbPNzAaOuim84+5u6oKl9UDehhN/Uu hxUgL62yIdXFjavMHeWBGn4qOZtXnw1EexH03V0tL9ADJPUnve83ia/C0WE9zoD8 h9CkyxFpvOFxjV5SBEkQ21uMxdF8yYfC4p/ZxVO0OyTIowpCUho= =mx7L -----END PGP SIGNATURE----- --mW9BFBXd1wtjrPIe--