Add pg_get_role_ddl() function

Add a new SQL-callable function that returns the DDL statements needed
to recreate a role. It takes a regrole argument and an optional VARIADIC
text argument for options that are specified as alternating name/value
pairs. The following options are supported: pretty (boolean) for
formatted output and memberships (boolean) to include GRANT statements
for role memberships and membership options. The return is one or
multiple rows where the first row is a CREATE ROLE statement and
subsequent rows are ALTER ROLE statements to set some role properties.
Password information is never included in the output.

The caller must have SELECT privilege on pg_authid.

Author: Mario Gonzalez <[email protected]>
Author: Bryan Green <[email protected]>
Co-authored-by: Andrew Dunstan <[email protected]>
Co-authored-by: Euler Taveira <[email protected]>
Reviewed-by: Japin Li <[email protected]>
Reviewed-by: Quan Zongliang <[email protected]>
Reviewed-by: jian he <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/76e514ebb4b55f95b844e3e94e61fa64ab16fd0b

Modified Files
--------------
doc/src/sgml/func/func-info.sgml       |  56 +++++
src/backend/utils/adt/ddlutils.c       | 361 +++++++++++++++++++++++++++++++++
src/include/catalog/pg_proc.dat        |   8 +
src/test/regress/expected/role_ddl.out | 143 +++++++++++++
src/test/regress/parallel_schedule     |   2 +
src/test/regress/sql/role_ddl.sql      |  96 +++++++++
6 files changed, 666 insertions(+)

Reply via email to