Can pg_dump make use of CURRENT/SESSION_USER

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Can pg_dump make use of CURRENT/SESSION_USER
Date: 2015-03-17 17:18:36
Message-ID: 20150317171836.GC10492@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Are there any use-cases for pg_dump to use CURRENT/SESSION_USER in its
output, so that restores will not be hard-coded to the dump user? I
didn't see any cases of that, but wanted to ask.

pg_dump doesn't have to restore into old clusters so there isn't a
problem with backward compatibility.

---------------------------------------------------------------------------

----- Forwarded message from Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> -----

Date: Mon, 09 Mar 2015 18:46:02 +0000
From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: [COMMITTERS] pgsql: Allow CURRENT/SESSION_USER to be used in certain commands

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/31eae6028eca4365e7165f5f33fee1ed0486aee0

Modified Files
--------------
doc/src/sgml/ref/alter_aggregate.sgml | 3 +-
doc/src/sgml/ref/alter_collation.sgml | 2 +-
doc/src/sgml/ref/alter_conversion.sgml | 2 +-
doc/src/sgml/ref/alter_database.sgml | 2 +-
doc/src/sgml/ref/alter_domain.sgml | 2 +-
doc/src/sgml/ref/alter_event_trigger.sgml | 2 +-
doc/src/sgml/ref/alter_foreign_data_wrapper.sgml | 2 +-
doc/src/sgml/ref/alter_foreign_table.sgml | 2 +-
doc/src/sgml/ref/alter_function.sgml | 2 +-
doc/src/sgml/ref/alter_group.sgml | 10 +-
doc/src/sgml/ref/alter_language.sgml | 2 +-
doc/src/sgml/ref/alter_large_object.sgml | 2 +-
doc/src/sgml/ref/alter_materialized_view.sgml | 2 +-
doc/src/sgml/ref/alter_opclass.sgml | 11 +-
doc/src/sgml/ref/alter_operator.sgml | 7 +-
doc/src/sgml/ref/alter_opfamily.sgml | 19 +-
doc/src/sgml/ref/alter_role.sgml | 35 +-
doc/src/sgml/ref/alter_schema.sgml | 2 +-
doc/src/sgml/ref/alter_sequence.sgml | 2 +-
doc/src/sgml/ref/alter_server.sgml | 2 +-
doc/src/sgml/ref/alter_table.sgml | 2 +-
doc/src/sgml/ref/alter_tablespace.sgml | 2 +-
doc/src/sgml/ref/alter_tsconfig.sgml | 2 +-
doc/src/sgml/ref/alter_tsdictionary.sgml | 2 +-
doc/src/sgml/ref/alter_type.sgml | 2 +-
doc/src/sgml/ref/alter_user.sgml | 16 +-
doc/src/sgml/ref/alter_user_mapping.sgml | 2 +-
doc/src/sgml/ref/alter_view.sgml | 2 +-
doc/src/sgml/ref/create_schema.sgml | 14 +-
doc/src/sgml/ref/grant.sgml | 33 +-
src/backend/catalog/aclchk.c | 54 +-
src/backend/commands/alter.c | 2 +-
src/backend/commands/extension.c | 2 +-
src/backend/commands/foreigncmds.c | 58 +-
src/backend/commands/policy.c | 18 +-
src/backend/commands/schemacmds.c | 21 +-
src/backend/commands/tablecmds.c | 4 +-
src/backend/commands/tablespace.c | 2 +-
src/backend/commands/user.c | 116 +--
src/backend/nodes/copyfuncs.c | 49 +-
src/backend/nodes/equalfuncs.c | 45 +-
src/backend/parser/gram.y | 228 ++++--
src/backend/parser/parse_utilcmd.c | 4 +-
src/backend/utils/adt/acl.c | 116 ++-
src/include/commands/user.h | 2 +-
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 50 +-
src/include/utils/acl.h | 8 +-
src/test/regress/expected/rolenames.out | 940 ++++++++++++++++++++++
src/test/regress/parallel_schedule | 2 +-
src/test/regress/serial_schedule | 1 +
src/test/regress/sql/rolenames.sql | 434 ++++++++++
52 files changed, 2000 insertions(+), 347 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

----- End forwarded message -----

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-03-17 17:22:27 Re: Strange assertion using VACOPT_FREEZE in vacuum.c
Previous Message Robert Haas 2015-03-17 17:13:47 Re: Rethinking the parameter access hooks for plpgsql's benefit