]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add a syscache on pg_extension.oid.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 9 Feb 2026 15:02:23 +0000 (10:02 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 9 Feb 2026 15:02:23 +0000 (10:02 -0500)
An upcoming patch requires this cache so that it can track updates
in the pg_extension catalog.  So far though, the EXTENSIONOID cache
only exists in v18 and up (see 490f869d9).  We can add it in older
branches without an ABI break, if we are careful not to disturb the
numbering of existing syscache IDs.

In v16 and before, that just requires adding the new ID at the end
of the hand-assigned enum list, ignoring our convention about
alphabetizing the IDs.  But in v17, genbki.pl enforces alphabetical
order of the IDs listed in MAKE_SYSCACHE macros.  We can fake it
out by calling the new cache ZEXTENSIONOID.

Note that adding a syscache does change the required contents of the
relcache init file (pg_internal.init).  But that isn't problematic
since we blow those away at postmaster start for other reasons.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Noah Misch <noah@leadboat.com>
Security: CVE-2026-2004
Backpatch-through: 14-17

src/backend/utils/cache/syscache.c
src/include/utils/syscache.h

index d55277e90e9d0055c5afa64a88c6ffb037c7f8e8..5d1653b82c7c56cab2121c66c12180a3d4294d2e 100644 (file)
@@ -39,6 +39,7 @@
 #include "catalog/pg_description.h"
 #include "catalog/pg_enum.h"
 #include "catalog/pg_event_trigger.h"
+#include "catalog/pg_extension.h"
 #include "catalog/pg_foreign_data_wrapper.h"
 #include "catalog/pg_foreign_server.h"
 #include "catalog/pg_foreign_table.h"
@@ -679,6 +680,13 @@ static const struct cachedesc cacheinfo[] = {
                KEY(Anum_pg_user_mapping_umuser,
                        Anum_pg_user_mapping_umserver),
                2
+       },
+       /* intentionally out of alphabetical order, to avoid an ABI break: */
+       [EXTENSIONOID] = {
+               ExtensionRelationId,
+               ExtensionOidIndexId,
+               KEY(Anum_pg_extension_oid),
+               2
        }
 };
 
index 1395497e1989adf274d741d0675a6baff420bdc9..34b3b76aa5c9c797eeb7f4c27cd6869d6c3ae2fd 100644 (file)
@@ -113,9 +113,11 @@ enum SysCacheIdentifier
        TYPENAMENSP,
        TYPEOID,
        USERMAPPINGOID,
-       USERMAPPINGUSERSERVER
+       USERMAPPINGUSERSERVER,
+       /* intentionally out of alphabetical order, to avoid an ABI break: */
+       EXTENSIONOID
 
-#define SysCacheSize (USERMAPPINGUSERSERVER + 1)
+#define SysCacheSize (EXTENSIONOID + 1)
 };
 
 extern void InitCatalogCache(void);