OSDN Git Service

Allow non-superusers to create (some) extensions.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Mar 2011 21:08:24 +0000 (16:08 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Mar 2011 21:08:53 +0000 (16:08 -0500)
commit8d3b421f5f7b955e7ac7d156aa74ee6a6fe4e9f6
tree7c39d9ea30b748ea92b25b020dc0187ee3cf154c
parent4442e1975d3c4c96a0b573b7abd864b0cbe26f9d
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.
20 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/extend.sgml
doc/src/sgml/ref/alter_extension.sgml
doc/src/sgml/ref/create_extension.sgml
doc/src/sgml/ref/drop_extension.sgml
src/backend/catalog/aclchk.c
src/backend/catalog/objectaddress.c
src/backend/catalog/system_views.sql
src/backend/commands/comment.c
src/backend/commands/extension.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/bin/pg_dump/pg_dump.c
src/include/catalog/catversion.h
src/include/catalog/objectaddress.h
src/include/catalog/pg_proc.h
src/include/nodes/parsenodes.h
src/include/utils/acl.h
src/test/regress/expected/rules.out