Skip to content

Commit 2dcd157

Browse files
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
1 parent de7c3fd commit 2dcd157

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

doc/src/sgml/ref/createuser.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ PostgreSQL documentation
8282

8383
<varlistentry>
8484
<term><option>-a <replaceable class="parameter">role</replaceable></option></term>
85-
<term><option>--admin=<replaceable class="parameter">role</replaceable></option></term>
85+
<term><option>--with-admin=<replaceable class="parameter">role</replaceable></option></term>
8686
<listitem>
8787
<para>
88-
Indicates an existing role that will be automatically added as a member of the new
88+
Specifies an existing role that will be automatically added as a member of the new
8989
role with admin option, giving it the right to grant membership in the
9090
new role to others. Multiple existing roles can be specified by
9191
writing multiple <option>-a</option> switches.
@@ -149,10 +149,10 @@ PostgreSQL documentation
149149

150150
<varlistentry>
151151
<term><option>-g <replaceable class="parameter">role</replaceable></option></term>
152-
<term><option>--role=<replaceable class="parameter">role</replaceable></option></term>
152+
<term><option>--member-of=<replaceable class="parameter">role</replaceable></option></term>
153153
<listitem>
154154
<para>
155-
Indicates the new role should be automatically added as a member
155+
Specifies the new role should be automatically added as a member
156156
of the specified existing role. Multiple existing roles can be
157157
specified by writing multiple <option>-g</option> switches.
158158
</para>
@@ -222,10 +222,10 @@ PostgreSQL documentation
222222

223223
<varlistentry>
224224
<term><option>-m <replaceable class="parameter">role</replaceable></option></term>
225-
<term><option>--member=<replaceable class="parameter">role</replaceable></option></term>
225+
<term><option>--with-member=<replaceable class="parameter">role</replaceable></option></term>
226226
<listitem>
227227
<para>
228-
Indicates the specified existing role should be automatically
228+
Specifies an existing role that will be automatically
229229
added as a member of the new role. Multiple existing roles can
230230
be specified by writing multiple <option>-m</option> switches.
231231
</para>

src/bin/scripts/createuser.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,21 @@ int
2828
main(int argc, char *argv[])
2929
{
3030
static struct option long_options[] = {
31-
{"admin", required_argument, NULL, 'a'},
31+
{"with-admin", required_argument, NULL, 'a'},
3232
{"connection-limit", required_argument, NULL, 'c'},
3333
{"createdb", no_argument, NULL, 'd'},
3434
{"no-createdb", no_argument, NULL, 'D'},
3535
{"echo", no_argument, NULL, 'e'},
3636
{"encrypted", no_argument, NULL, 'E'},
37-
{"role", required_argument, NULL, 'g'},
37+
{"role", required_argument, NULL, 'g'}, /* kept for backward
38+
* compatibility */
39+
{"member-of", required_argument, NULL, 'g'},
3840
{"host", required_argument, NULL, 'h'},
3941
{"inherit", no_argument, NULL, 'i'},
4042
{"no-inherit", no_argument, NULL, 'I'},
4143
{"login", no_argument, NULL, 'l'},
4244
{"no-login", no_argument, NULL, 'L'},
43-
{"member", required_argument, NULL, 'm'},
45+
{"with-member", required_argument, NULL, 'm'},
4446
{"port", required_argument, NULL, 'p'},
4547
{"pwprompt", no_argument, NULL, 'P'},
4648
{"createrole", no_argument, NULL, 'r'},
@@ -414,19 +416,19 @@ help(const char *progname)
414416
printf(_("Usage:\n"));
415417
printf(_(" %s [OPTION]... [ROLENAME]\n"), progname);
416418
printf(_("\nOptions:\n"));
417-
printf(_(" -a, --admin=ROLE this role will be a member of new role with admin\n"
419+
printf(_(" -a, --with-admin=ROLE ROLE will be a member of new role with admin\n"
418420
" option\n"));
419421
printf(_(" -c, --connection-limit=N connection limit for role (default: no limit)\n"));
420422
printf(_(" -d, --createdb role can create new databases\n"));
421423
printf(_(" -D, --no-createdb role cannot create databases (default)\n"));
422424
printf(_(" -e, --echo show the commands being sent to the server\n"));
423-
printf(_(" -g, --role=ROLE new role will be a member of this role\n"));
425+
printf(_(" -g, --member-of=ROLE new role will be a member of ROLE\n"));
424426
printf(_(" -i, --inherit role inherits privileges of roles it is a\n"
425427
" member of (default)\n"));
426428
printf(_(" -I, --no-inherit role does not inherit privileges\n"));
427429
printf(_(" -l, --login role can login (default)\n"));
428430
printf(_(" -L, --no-login role cannot login\n"));
429-
printf(_(" -m, --member=ROLE this role will be a member of new role\n"));
431+
printf(_(" -m, --with-member=ROLE ROLE will be a member of new role\n"));
430432
printf(_(" -P, --pwprompt assign a password to new role\n"));
431433
printf(_(" -r, --createrole role can create new roles\n"));
432434
printf(_(" -R, --no-createrole role cannot create roles (default)\n"));

src/bin/scripts/t/040_createuser.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@
6060
[ 'createuser', '--no-bypassrls', 'regress_user8' ],
6161
qr/statement: CREATE ROLE regress_user8 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS;/,
6262
'create a role without BYPASSRLS');
63+
$node->issues_sql_like(
64+
[ 'createuser', '--with-admin', 'regress_user1', 'regress_user9' ],
65+
qr/statement: CREATE ROLE regress_user9 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ADMIN regress_user1;/,
66+
'--with-admin');
67+
$node->issues_sql_like(
68+
[ 'createuser', '--with-member', 'regress_user1', 'regress_user10' ],
69+
qr/statement: CREATE ROLE regress_user10 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS ROLE regress_user1;/,
70+
'--with-member');
71+
$node->issues_sql_like(
72+
[ 'createuser', '--role', 'regress_user1', 'regress_user11' ],
73+
qr/statement: CREATE ROLE regress_user11 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS IN ROLE regress_user1;/,
74+
'--role (for backward compatibility)');
75+
$node->issues_sql_like(
76+
[ 'createuser', '--member-of', 'regress_user1', 'regress_user12' ],
77+
qr/statement: CREATE ROLE regress_user12 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOREPLICATION NOBYPASSRLS IN ROLE regress_user1;/,
78+
'--member-of');
6379

6480
$node->command_fails([ 'createuser', 'regress_user1' ],
6581
'fails if role already exists');

0 commit comments

Comments
 (0)