mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Allow non-superusers to create (some) extensions.
Remove the unconditional superuser permissions check in CREATE EXTENSION, and instead define a "superuser" extension property, which when false (not the default) skips the superuser permissions check. In this case the calling user only needs enough permissions to execute the commands in the extension's installation script. The superuser property is also enforced in the same way for ALTER EXTENSION UPDATE cases. In other ALTER EXTENSION cases and DROP EXTENSION, test ownership of the extension rather than superuserness. ALTER EXTENSION ADD/DROP needs to insist on ownership of the target object as well; to do that without duplicating code, refactor comment.c's big switch for permissions checks into a separate function in objectaddress.c. I also removed the superuserness checks in pg_available_extensions and related functions; there's no strong reason why everybody shouldn't be able to see that info. Also invent an IF NOT EXISTS variant of CREATE EXTENSION, and use that in pg_dump, so that dumps won't fail for installed-by-default extensions. We don't have any of those yet, but we will soon. This is all per discussion of wrapping the standard procedural languages into extensions. I'll make those changes in a separate commit; this is just putting the core infrastructure in place.
This commit is contained in:
@@ -21,7 +21,7 @@ PostgreSQL documentation
|
||||
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
CREATE EXTENSION <replaceable class="parameter">extension_name</replaceable>
|
||||
CREATE EXTENSION [ IF NOT EXISTS ] <replaceable class="parameter">extension_name</replaceable>
|
||||
[ WITH ] [ SCHEMA <replaceable class="parameter">schema</replaceable> ]
|
||||
[ VERSION <replaceable class="parameter">version</replaceable> ]
|
||||
[ FROM <replaceable class="parameter">old_version</replaceable> ]
|
||||
@@ -51,7 +51,12 @@ CREATE EXTENSION <replaceable class="parameter">extension_name</replaceable>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Only superusers can execute <command>CREATE EXTENSION</command>.
|
||||
Loading an extension requires the same privileges that would be
|
||||
required to create its component objects. For most extensions this
|
||||
means superuser or database owner privileges are needed.
|
||||
The user who runs <command>CREATE EXTENSION</command> becomes the
|
||||
owner of the extension for purposes of later privilege checks, as well
|
||||
as the owner of any objects created by the extension's script.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
@@ -60,6 +65,18 @@ CREATE EXTENSION <replaceable class="parameter">extension_name</replaceable>
|
||||
<title>Parameters</title>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>IF NOT EXISTS</></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Do not throw an error if an extension with the same name already
|
||||
exists. A notice is issued in this case. Note that there is no
|
||||
guarantee that the existing extension is anything like the one that
|
||||
would have been created.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable class="parameter">extension_name</replaceable></term>
|
||||
<listitem>
|
||||
|
Reference in New Issue
Block a user