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 1vsTaV-00300q-2O for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 22:30:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsTaU-00CkWB-2m for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 22:30:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsTaU-00CkVx-0c for pgsql-hackers@lists.postgresql.org; Tue, 17 Feb 2026 22:30:34 +0000 Received: from fhigh-b1-smtp.messagingengine.com ([202.12.124.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vsTaR-000000017m0-31t5 for pgsql-hackers@lists.postgresql.org; Tue, 17 Feb 2026 22:30:33 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 574B67A0140 for ; Tue, 17 Feb 2026 17:30:31 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 17 Feb 2026 17:30:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1771367431; x=1771453831; bh=su+77hK3errAKsg7k+EDZE1OMoPWmDl4 KfHXK4vfloM=; b=hcHMFcj9gLIfT9vY/JkcV+UDGphh1BZGQ7w38jA/GsfNERkU JU3fNX3jGlQOcj5DRI+eQCSlUmYI/MFmLswFHm5UqhLfxP7f6NTCA20ScCw9WUyM QT/L0NF/nwXmPot4W77tSyekSxLEVTM+uvQxRQ7QKCELsgAoot90A9EZSfhtuvE9 SxTlfsLTV5kkRuYUOTy+x3a0JpwS94SNr3NdDpjLALH5UfH6LfYZqgZhkP3Tlc3b TVTSTJmnt5JIky6prQufUuSvt3LmJEjzVmPnEU6QYfjhA9tvb5ChmezfOJLyb0jj +vxhs4gvvpdhaW5MozwF4g2FNoO1XL17Ml3T0A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1771367431; x= 1771453831; bh=su+77hK3errAKsg7k+EDZE1OMoPWmDl4KfHXK4vfloM=; b=j nWQsgYea9dGAQ0MqhIQijnCeurtVgm/9VIAu2EXFvIZB3D8qYT534nUnHU7AJ5yH OJjyjH6DUFphLemnPtkl3QyX0Ffehwzy0yUZe+tew688SSIcrzWmXJmbCnk2yUEG CbN1byN2mhohZhf8wAbRNsyZF91GtmoIEpR1CDtOuTID3jsqte7SQukmuazKKxs0 T222Rpv5pzNvIc1HGrJNY/jHFqjxZ0RLf33MdinbwWpbsDpoHTd0p+tR/RijApLZ yAseiiL1qpcwtH4STMyws/lSMw/5+GiUFr7iatn8dcxR88U5t6NDWIbN14xAqtid iXHxo+J6L+ErhIKbpWEVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvvddtleeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvuffkgggtugesghdtreertddtvdenucfh rhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquhhivg hrrdighiiiqeenucggtffrrghtthgvrhhnpedvtdffteegtdfhuefgvedvtdejgfeugfeg gfejgfdvhefgfeevieektdelkefhgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggp rhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqd hhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 17 Feb 2026 17:30:28 -0500 (EST) Date: Wed, 18 Feb 2026 07:30:21 +0900 From: Michael Paquier To: Postgres hackers Subject: One-off with syscache ID in get_catalog_object_by_oid_extended() Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3MzUPYm8rwZKlN7I" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3MzUPYm8rwZKlN7I Content-Type: multipart/mixed; boundary="B/fA0dMNuo7xFKG0" Content-Disposition: inline --B/fA0dMNuo7xFKG0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, While reviewing the syscache code, I have bumped into the following funny bit in objectaddress.c: if (oidCacheId > 0) { if (locktup) tuple = SearchSysCacheLockedCopy1(oidCacheId, ObjectIdGetDatum(objectId)); else tuple = SearchSysCacheCopy1(oidCacheId, ObjectIdGetDatum(objectId)); if (!HeapTupleIsValid(tuple)) /* should not happen */ return NULL; } This is wrong, because SysCacheIdentifier starts at 0. This has no consequence currently, because the first value in the enum is AGGFNOID, something that we don't rely on for object type lookups. Even if this code had the idea to use an ID of 0, the logic would just get back to a systable lookup, that would still work, that's just less efficient. Simple patch attached, planned for a backpatch quickly as I am playing with a different patch that reworks a bit this code. Regards, -- Michael --B/fA0dMNuo7xFKG0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=cacheid-oneoff.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/obje= ctaddress.c index 02af64b82c68..198caf641a5e 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -2808,7 +2808,7 @@ get_catalog_object_by_oid_extended(Relation catalog, Oid classId =3D RelationGetRelid(catalog); int oidCacheId =3D get_object_catcache_oid(classId); =20 - if (oidCacheId > 0) + if (oidCacheId >=3D 0) { if (locktup) tuple =3D SearchSysCacheLockedCopy1(oidCacheId, --B/fA0dMNuo7xFKG0-- --3MzUPYm8rwZKlN7I Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmmU6/0ACgkQnvQgOdby QH0rpA/9GvptRuM+4/sgILq8Sj/1wBzigmLy4+id8mbQN2gxyjqgdV58y43+Zp0n WIQcArLNHsw5iP8SUMfGxsQ5/pshLCG1HKeyxEbPuw31f3ZGgtCILg1QJy6vsBDX 48sNqhH27WD9RnvJcFBKNHyq6Y95NbrEs8MhHHwuOxa5DjqkyONxbhSwiqFPocuZ 87act7OY6IjI9QxjOSBKzuyuvayzaBu4ByfC6QOar1Q3No/LC7jCNJ3ltxkh5D2K 0Cez8VpmXORYw48CxylSUiZFa/swv530uo9dhqRAtEkevJd90T/CELBwK0TRS+k5 ysdIXIkfKEMsKaTBQJpKlm1e2Q0CrYNBlBW6ol3xCIiEX4Cv5L61qODshIuWXg14 JL3GrxXHvLygJ1BNaSsGvi4tuX+iLDk+pezAQoRcbqZWZraXLG2CKuyJtZhJwzer TLmYW89I4hN+62imAOQloYJNyHsuZ1lkb9wsAAO/hSFkEnrlZwhEd97h8EfNtEN3 XYLG5OkBkdYbLYcou45tiKsQGFCQBWLBUkkh/QKtUqjqg9zpJ2lH9YB5AuIPGyGM wmn17d205RdwPXmXhA1UG36QPDKuMltXtD5KbV1RvsfsYfzVimnOL+yT0W6fhsyf 3/e372yrBbNjcRXwFlJu/4WZMpkPDdXBaqcjQl4gleBINyhNTQ8= =+Rao -----END PGP SIGNATURE----- --3MzUPYm8rwZKlN7I--