postgres.git / summary / log / commit / refs

commit    3ecc84cce3c521894d86267df552a2d5f891a409
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Mon Feb 09 15:02:23 2026 +0000
First released in: 14.21, 15.16, 16.12, 17.8

    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 <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 | 13 +++++++++++++ src/include/utils/syscache.h | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 44a65a15f6c..da92610522a 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -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" @@ -1040,6 +1041,18 @@ static const struct cachedesc cacheinfo[] = { 0 }, 2 + }, + /* intentionally out of alphabetical order, to avoid an ABI break: */ + {ExtensionRelationId, /* EXTENSIONOID */ + ExtensionOidIndexId, + 1, + { + Anum_pg_extension_oid, + 0, + 0, + 0 + }, + 2 } }; diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 8860a72b711..e0bafb58ead 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -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); [parent: 429aeaebd16d]