From dbb09fd8e8c19c46f09a6f31b2d607239167181d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 9 Feb 2026 10:02:23 -0500 Subject: [PATCH] Add a syscache on pg_extension.oid. 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 Reviewed-by: Noah Misch Security: CVE-2026-2004 Backpatch-through: 14-17 --- src/include/catalog/pg_extension.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h index cdfacc09303..b860f40e701 100644 --- a/src/include/catalog/pg_extension.h +++ b/src/include/catalog/pg_extension.h @@ -56,4 +56,13 @@ DECLARE_TOAST(pg_extension, 4147, 4148); DECLARE_UNIQUE_INDEX_PKEY(pg_extension_oid_index, 3080, ExtensionOidIndexId, pg_extension, btree(oid oid_ops)); DECLARE_UNIQUE_INDEX(pg_extension_name_index, 3081, ExtensionNameIndexId, pg_extension, btree(extname name_ops)); +/* + * genbki.pl always emits syscache IDs in alphabetical order. To add this + * cache post-release without changing existing syscache IDs, add a Z prefix. + */ +MAKE_SYSCACHE(ZEXTENSIONOID, pg_extension_oid_index, 2); + +/* Then use this macro so that hand-written code can match other branches. */ +#define EXTENSIONOID ZEXTENSIONOID + #endif /* PG_EXTENSION_H */