]> granicus.if.org Git - postgresql/commit
Allow CURRENT/SESSION_USER to be used in certain commands
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 9 Mar 2015 18:41:54 +0000 (15:41 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 9 Mar 2015 18:41:54 +0000 (15:41 -0300)
commit31eae6028eca4365e7165f5f33fee1ed0486aee0
tree388807d83f4aecda050e5f98f880752fbe773b16
parentfa83f809458a966dff225d3d266399d48e7b5e6e
Allow CURRENT/SESSION_USER to be used in certain commands

Commands such as ALTER USER, ALTER GROUP, ALTER ROLE, GRANT, and the
various ALTER OBJECT / OWNER TO, as well as ad-hoc clauses related to
roles such as the AUTHORIZATION clause of CREATE SCHEMA, the FOR clause
of CREATE USER MAPPING, and the FOR ROLE clause of ALTER DEFAULT
PRIVILEGES can now take the keywords CURRENT_USER and SESSION_USER as
user specifiers in place of an explicit user name.

This commit also fixes some quite ugly handling of special standards-
mandated syntax in CREATE USER MAPPING, which in particular would fail
to work in presence of a role named "current_user".

The special role specifiers PUBLIC and NONE also have more consistent
handling now.

Also take the opportunity to add location tracking to user specifiers.

Authors: Kyotaro Horiguchi.  Heavily reworked by Álvaro Herrera.
Reviewed by: Rushabh Lathia, Adam Brightwell, Marti Raudsepp.
52 files changed:
doc/src/sgml/ref/alter_aggregate.sgml
doc/src/sgml/ref/alter_collation.sgml
doc/src/sgml/ref/alter_conversion.sgml
doc/src/sgml/ref/alter_database.sgml
doc/src/sgml/ref/alter_domain.sgml
doc/src/sgml/ref/alter_event_trigger.sgml
doc/src/sgml/ref/alter_foreign_data_wrapper.sgml
doc/src/sgml/ref/alter_foreign_table.sgml
doc/src/sgml/ref/alter_function.sgml
doc/src/sgml/ref/alter_group.sgml
doc/src/sgml/ref/alter_language.sgml
doc/src/sgml/ref/alter_large_object.sgml
doc/src/sgml/ref/alter_materialized_view.sgml
doc/src/sgml/ref/alter_opclass.sgml
doc/src/sgml/ref/alter_operator.sgml
doc/src/sgml/ref/alter_opfamily.sgml
doc/src/sgml/ref/alter_role.sgml
doc/src/sgml/ref/alter_schema.sgml
doc/src/sgml/ref/alter_sequence.sgml
doc/src/sgml/ref/alter_server.sgml
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/alter_tablespace.sgml
doc/src/sgml/ref/alter_tsconfig.sgml
doc/src/sgml/ref/alter_tsdictionary.sgml
doc/src/sgml/ref/alter_type.sgml
doc/src/sgml/ref/alter_user.sgml
doc/src/sgml/ref/alter_user_mapping.sgml
doc/src/sgml/ref/alter_view.sgml
doc/src/sgml/ref/create_schema.sgml
doc/src/sgml/ref/grant.sgml
src/backend/catalog/aclchk.c
src/backend/commands/alter.c
src/backend/commands/extension.c
src/backend/commands/foreigncmds.c
src/backend/commands/policy.c
src/backend/commands/schemacmds.c
src/backend/commands/tablecmds.c
src/backend/commands/tablespace.c
src/backend/commands/user.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/backend/parser/parse_utilcmd.c
src/backend/utils/adt/acl.c
src/include/commands/user.h
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/utils/acl.h
src/test/regress/expected/rolenames.out [new file with mode: 0644]
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/rolenames.sql [new file with mode: 0644]