On July 21, 2015 at 8:26:31 AM, Andres Freund (andres@anarazel.de(mailto:andres@anarazel.de)) wrote:
> On 2015-07-21 17:00:51 +0200, Andres Freund wrote:
> > On 2015-07-21 07:55:17 -0700, Paul Ramsey wrote:
> > > On Tue, Jul 21, 2015 at 7:45 AM, Andres Freund wrote:
> > > So, right after reading the options in postgresGetForeignRelSize,
> > > expand the extension list into a list of all ops/functions, in a
> > > sorted list, and let that carry through to the deparsing instead?
> >
> > I'd actually try to make it longer lived, i.e. permanently. And just
> > deallocate when a catcache callback says it needs to be invalidated;
> > IIRC there is a relevant cache.
>
> On second thought I'd not use a binary search but a hash table. If you
> choose the right key a single table is enough for the lookup.
>
> If you need references for invalidations you might want to look for
> CacheRegisterSyscacheCallback callers. E.g. attoptcache.c
> On 2015-07-21 08:32:34 -0700, Paul Ramsey wrote:
> > Thanks! Reading some of the syscache callback stuff, one thing I’m not
> > sure of is which SysCacheIdentifier(s) I should be registering
> > callbacks against to ensure my list of funcs/procs that reside in
> > particular extensions is kept fresh. I don’t see anything tracking the
> > dependencies there
> FOREIGNSERVEROID, and a new syscache on pg_extension.oid should suffice
> I think. pg_foreign_server will be changed upon option changes and
> pg_extension.oid on extension upgrades.
> Since dependencies won't change independently of extension versions I
> don't think we need to care otherwise. There's ALTER EXTENSION ... ADD
> but I'm rather prepared to ignore that; if that's not ok it's trivial to
> make it emit an invalidation.
This hole just keeps getting deeper :) So,
- a HASH in my own code to hold all the functions that I consider “safe to forward” (which I’ll derive by reading the
contentsof the extensions the users declare)
- callbacks in my code registered using CacheRegisterSyscacheCallback on FOREIGNSERVEROID and __see_below__ that
refreshmy cache when called
- since there is no syscache for extensions right now, a new syscache entry for pg_extension.oid (and I ape things in
syscache.hand syscache.c and Magic Occurs?)
- which means I can also CacheRegisterSyscacheCallback on the new EXTENSIONOID syscache
- and finally change my is_in_extension() to efficiently check my HASH instead of querying the system catalog
Folks are going to be OK w/ me dropping in new syscache entries so support my niche little feature?
ATB,
P