]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix one-off issue with cache ID in objectaddress.c
authorMichael Paquier <michael@paquier.xyz>
Tue, 17 Feb 2026 23:47:58 +0000 (08:47 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 17 Feb 2026 23:47:58 +0000 (08:47 +0900)
get_catalog_object_by_oid_extended() has been doing a syscache lookup
when given a cache ID strictly higher than 0, which is wrong because the
first valid value of SysCacheIdentifier is 0.

This issue had no consequences, as the first value assigned in the
enum SysCacheIdentifier is AGGFNOID, which is not used in the object
type properties listed in objectaddress.c.  Even if an ID of 0 was
hypotherically given, the code would still work with a less efficient
heap-or-index scan.

Discussion: https://postgr.es/m/aZTr_R6JGmqokUBb@paquier.xyz

src/backend/catalog/objectaddress.c

index 02af64b82c688071921f06fbaf9a26036b9a55fc..198caf641a5e0998dd11874a1f0d0a556f94ef4e 100644 (file)
@@ -2808,7 +2808,7 @@ get_catalog_object_by_oid_extended(Relation catalog,
        Oid                     classId = RelationGetRelid(catalog);
        int                     oidCacheId = get_object_catcache_oid(classId);
 
-       if (oidCacheId > 0)
+       if (oidCacheId >= 0)
        {
                if (locktup)
                        tuple = SearchSysCacheLockedCopy1(oidCacheId,