• Tom Lane's avatar
    Invent "trusted" extensions, and remove the pg_pltemplate catalog. · 50fc694e
    Tom Lane authored
    This patch creates a new extension property, "trusted".  An extension
    that's marked that way in its control file can be installed by a
    non-superuser who has the CREATE privilege on the current database,
    even if the extension contains objects that normally would have to be
    created by a superuser.  The objects within the extension will (by
    default) be owned by the bootstrap superuser, but the extension itself
    will be owned by the calling user.  This allows replicating the old
    behavior around trusted procedural languages, without all the
    special-case logic in CREATE LANGUAGE.  We have, however, chosen to
    loosen the rules slightly: formerly, only a database owner could take
    advantage of the special case that allowed installation of a trusted
    language, but now anyone who has CREATE privilege can do so.
    
    Having done that, we can delete the pg_pltemplate catalog, moving the
    knowledge it contained into the extension script files for the various
    PLs.  This ends up being no change at all for the in-core PLs, but it is
    a large step forward for external PLs: they can now have the same ease
    of installation as core PLs do.  The old "trusted PL" behavior was only
    available to PLs that had entries in pg_pltemplate, but now any
    extension can be marked trusted if appropriate.
    
    This also removes one of the stumbling blocks for our Python 2 -> 3
    migration, since the association of "plpythonu" with Python 2 is no
    longer hard-wired into pg_pltemplate's initial contents.  Exactly where
    we go from here on that front remains to be settled, but one problem
    is fixed.
    
    Patch by me, reviewed by Peter Eisentraut, Stephen Frost, and others.
    
    Discussion: https://postgr.es/m/5889.1566415762@sss.pgh.pa.us
    50fc694e
create_extension.sgml 9.14 KB