1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Rename some createuser options.

This change renames --admin to --with-admin, --role to --member-of,
and --member to --with-member.  Many people found the previous
names to be confusing.  The --admin and --member options are new in
v16, but --role has been there for a while, so that one has been
kept (but left undocumented) for backward compatibility.

Suggested-by: Peter Eisentraut
Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/ZFvVZvQDliIWmOwg%40momjian.us
This commit is contained in:
Nathan Bossart
2023-05-21 20:03:56 -07:00
parent de7c3fd34e
commit 2dcd1578c4
3 changed files with 30 additions and 12 deletions

View File

@ -82,10 +82,10 @@ PostgreSQL documentation
<varlistentry> <varlistentry>
<term><option>-a <replaceable class="parameter">role</replaceable></option></term> <term><option>-a <replaceable class="parameter">role</replaceable></option></term>
<term><option>--admin=<replaceable class="parameter">role</replaceable></option></term> <term><option>--with-admin=<replaceable class="parameter">role</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Indicates an existing role that will be automatically added as a member of the new Specifies an existing role that will be automatically added as a member of the new
role with admin option, giving it the right to grant membership in the role with admin option, giving it the right to grant membership in the
new role to others. Multiple existing roles can be specified by new role to others. Multiple existing roles can be specified by
writing multiple <option>-a</option> switches. writing multiple <option>-a</option> switches.
@ -149,10 +149,10 @@ PostgreSQL documentation
<varlistentry> <varlistentry>
<term><option>-g <replaceable class="parameter">role</replaceable></option></term> <term><option>-g <replaceable class="parameter">role</replaceable></option></term>
<term><option>--role=<replaceable class="parameter">role</replaceable></option></term> <term><option>--member-of=<replaceable class="parameter">role</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Indicates the new role should be automatically added as a member Specifies the new role should be automatically added as a member
of the specified existing role. Multiple existing roles can be of the specified existing role. Multiple existing roles can be
specified by writing multiple <option>-g</option> switches. specified by writing multiple <option>-g</option> switches.
</para> </para>
@ -222,10 +222,10 @@ PostgreSQL documentation
<varlistentry> <varlistentry>
<term><option>-m <replaceable class="parameter">role</replaceable></option></term> <term><option>-m <replaceable class="parameter">role</replaceable></option></term>
<term><option>--member=<replaceable class="parameter">role</replaceable></option></term> <term><option>--with-member=<replaceable class="parameter">role</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Indicates the specified existing role should be automatically Specifies an existing role that will be automatically
added as a member of the new role. Multiple existing roles can added as a member of the new role. Multiple existing roles can
be specified by writing multiple <option>-m</option> switches. be specified by writing multiple <option>-m</option> switches.
</para> </para>

View File

@ -28,19 +28,21 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
static struct option long_options[] = { static struct option long_options[] = {
{"admin", required_argument, NULL, 'a'}, {"with-admin", required_argument, NULL, 'a'},
{"connection-limit", required_argument, NULL, 'c'}, {"connection-limit", required_argument, NULL, 'c'},
{"createdb", no_argument, NULL, 'd'}, {"createdb", no_argument, NULL, 'd'},
{"no-createdb", no_argument, NULL, 'D'}, {"no-createdb", no_argument, NULL, 'D'},
{"echo", no_argument, NULL, 'e'}, {"echo", no_argument, NULL, 'e'},
{"encrypted", no_argument, NULL, 'E'}, {"encrypted", no_argument, NULL, 'E'},
{"role", required_argument, NULL, 'g'}, {"role", required_argument, NULL, 'g'}, /* kept for backward
* compatibility */
{"member-of", required_argument, NULL, 'g'},
{"host", required_argument, NULL, 'h'}, {"host", required_argument, NULL, 'h'},
{"inherit", no_argument, NULL, 'i'}, {"inherit", no_argument, NULL, 'i'},
{"no-inherit", no_argument, NULL, 'I'}, {"no-inherit", no_argument, NULL, 'I'},
{"login", no_argument, NULL, 'l'}, {"login", no_argument, NULL, 'l'},
{"no-login", no_argument, NULL, 'L'}, {"no-login", no_argument, NULL, 'L'},
{"member", required_argument, NULL, 'm'}, {"with-member", required_argument, NULL, 'm'},
{"port", required_argument, NULL, 'p'}, {"port", required_argument, NULL, 'p'},
{"pwprompt", no_argument, NULL, 'P'}, {"pwprompt", no_argument, NULL, 'P'},
{"createrole", no_argument, NULL, 'r'}, {"createrole", no_argument, NULL, 'r'},
@ -414,19 +416,19 @@ help(const char *progname)
printf(_("Usage:\n")); printf(_("Usage:\n"));
printf(_(" %s [OPTION]... [ROLENAME]\n"), progname); printf(_(" %s [OPTION]... [ROLENAME]\n"), progname);
printf(_("\nOptions:\n")); printf(_("\nOptions:\n"));
printf(_(" -a, --admin=ROLE this role will be a member of new role with admin\n" printf(_(" -a, --with-admin=ROLE ROLE will be a member of new role with admin\n"
" option\n")); " option\n"));
printf(_(" -c, --connection-limit=N connection limit for role (default: no limit)\n")); printf(_(" -c, --connection-limit=N connection limit for role (default: no limit)\n"));
printf(_(" -d, --createdb role can create new databases\n")); printf(_(" -d, --createdb role can create new databases\n"));
printf(_(" -D, --no-createdb role cannot create databases (default)\n")); printf(_(" -D, --no-createdb role cannot create databases (default)\n"));
printf(_(" -e, --echo show the commands being sent to the server\n")); printf(_(" -e, --echo show the commands being sent to the server\n"));
printf(_(" -g, --role=ROLE new role will be a member of this role\n")); printf(_(" -g, --member-of=ROLE new role will be a member of ROLE\n"));
printf(_(" -i, --inherit role inherits privileges of roles it is a\n" printf(_(" -i, --inherit role inherits privileges of roles it is a\n"
" member of (default)\n")); " member of (default)\n"));
printf(_(" -I, --no-inherit role does not inherit privileges\n")); printf(_(" -I, --no-inherit role does not inherit privileges\n"));
printf(_(" -l, --login role can login (default)\n")); printf(_(" -l, --login role can login (default)\n"));
printf(_(" -L, --no-login role cannot login\n")); printf(_(" -L, --no-login role cannot login\n"));
printf(_(" -m, --member=ROLE this role will be a member of new role\n")); printf(_(" -m, --with-member=ROLE ROLE will be a member of new role\n"));
printf(_(" -P, --pwprompt assign a password to new role\n")); printf(_(" -P, --pwprompt assign a password to new role\n"));
printf(_(" -r, --createrole role can create new roles\n")); printf(_(" -r, --createrole role can create new roles\n"));
printf(_(" -R, --no-createrole role cannot create roles (default)\n")); printf(_(" -R, --no-createrole role cannot create roles (default)\n"));

View File

@ -60,6 +60,22 @@ $node->issues_sql_like(
[ 'createuser', '--no-bypassrls', 'regress_user8' ], [ 'createuser', '--no-bypassrls', 'regress_user8' ],
qr/statement: CREATE ROLE regress_user8 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/, qr/statement: CREATE ROLE regress_user8 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/,
'create a role without BYPASSRLS'); 'create a role without BYPASSRLS');
$node->issues_sql_like(
[ 'createuser', '--with-admin', 'regress_user1', 'regress_user9' ],
qr/statement: CREATE ROLE regress_user9 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ADMIN regress_user1;/,
'--with-admin');
$node->issues_sql_like(
[ 'createuser', '--with-member', 'regress_user1', 'regress_user10' ],
qr/statement: CREATE ROLE regress_user10 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ROLE regress_user1;/,
'--with-member');
$node->issues_sql_like(
[ 'createuser', '--role', 'regress_user1', 'regress_user11' ],
qr/statement: CREATE ROLE regress_user11 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS IN ROLE regress_user1;/,
'--role (for backward compatibility)');
$node->issues_sql_like(
[ 'createuser', '--member-of', 'regress_user1', 'regress_user12' ],
qr/statement: CREATE ROLE regress_user12 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS IN ROLE regress_user1;/,
'--member-of');
$node->command_fails([ 'createuser', 'regress_user1' ], $node->command_fails([ 'createuser', 'regress_user1' ],
'fails if role already exists'); 'fails if role already exists');