• Tom Lane's avatar
    Enforce a specific order for probing library loadability in pg_upgrade. · 83c24920
    Tom Lane authored
    pg_upgrade checks whether all the shared libraries used in the old cluster
    are also available in the new one by issuing LOAD for each library name.
    Previously, it cared not what order it did the LOADs in.  Ideally it
    should not have to care, but currently the transform modules in contrib
    fail unless both the language and datatype modules they depend on are
    loaded first.  A backend-side solution for that looks possible but
    probably not back-patchable, so as a stopgap measure, let's do the LOAD
    tests in order by library name length.  That should fix the problem for
    reasonably-named transform modules, eg "hstore_plpython" will be loaded
    after both "hstore" and "plpython".  (Yeah, it's a hack.)
    
    In a larger sense, having a predictable order of these probes is a good
    thing, since it will make upgrades predictably work or not work in the
    face of inter-library dependencies.  Also, this patch replaces O(N^2)
    de-duplication logic with O(N log N) logic, which could matter in
    installations with very many databases.  So I don't foresee reverting this
    even after we have a proper fix for the library-dependency problem.
    
    In passing, improve a couple of SQL queries used here.
    
    Per complaint from Andrew Dunstan that pg_upgrade'ing the transform contrib
    modules failed.  Back-patch to 9.5 where transform modules were introduced.
    
    Discussion: <f7ac29f3-515c-2a44-21c5-ec925053265f@dunslane.net>
    83c24920
function.c 8.12 KB