Create syscache entries for pg_extension
authorMichael Paquier <[email protected]>
Thu, 22 Aug 2024 01:48:25 +0000 (10:48 +0900)
committerMichael Paquier <[email protected]>
Thu, 22 Aug 2024 01:48:25 +0000 (10:48 +0900)
Two syscache identifiers are added for extension names and OIDs.

Shared libraries of extensions might want to invalidate or update their
own caches whenever a CREATE, ALTER or DROP EXTENSION command is run for
their extension (in any backend).  Right now this is non-trivial to do
correctly and efficiently, but, if an extension catalog is part of a
syscache, this could simply be done by registering an callback using
CacheRegisterSyscacheCallback for the relevant syscache.

Another case where this is useful is a loaded library where some of its
code paths rely on some objects of the extension to exist; it can be
simpler and more efficient to do an existence check directly on the
extension through the syscache.

Author: Jelte Fennema-Nio
Reviewed-by: Alexander Korotkov, Pavel Stehule
Discussion: https://postgr.es/m/CAGECzQTWm9sex719Hptbq4j56hBGUti7J9OWjeMobQ1ccRok9w@mail.gmail.com

src/include/catalog/pg_extension.h

index cdfacc09303648e92de9b4b87ac4af7447164126..673181b39aed727c53704355cb2bb0993fff2fc3 100644 (file)
@@ -56,4 +56,7 @@ 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));
 
+MAKE_SYSCACHE(EXTENSIONOID, pg_extension_oid_index, 2);
+MAKE_SYSCACHE(EXTENSIONNAME, pg_extension_name_index, 2);
+
 #endif                         /* PG_EXTENSION_H */