mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 18:01:19 +02:00
Add a new option, -g, to createuser, to add membership in a role.
Chistopher Browne, reviewed by Sameer Thakur, Amit Kapila, and Peter Eisentraut.
This commit is contained in:
parent
a06af43695
commit
6bea96dd49
@ -130,6 +130,19 @@ PostgreSQL documentation
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-g <replaceable class="parameter">role</replaceable></></term>
|
||||||
|
<term><option>--role=<replaceable class="parameter">role</replaceable></></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Indicates role to which this role will be added immediately as a new
|
||||||
|
member. Multiple roles to which this role will be added as a member
|
||||||
|
can be specified by writing multiple
|
||||||
|
<option>-g</> switches.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-i</></term>
|
<term><option>-i</></term>
|
||||||
<term><option>--inherit</></term>
|
<term><option>--inherit</></term>
|
||||||
|
@ -24,6 +24,7 @@ main(int argc, char *argv[])
|
|||||||
{"host", required_argument, NULL, 'h'},
|
{"host", required_argument, NULL, 'h'},
|
||||||
{"port", required_argument, NULL, 'p'},
|
{"port", required_argument, NULL, 'p'},
|
||||||
{"username", required_argument, NULL, 'U'},
|
{"username", required_argument, NULL, 'U'},
|
||||||
|
{"role", required_argument, NULL, 'g'},
|
||||||
{"no-password", no_argument, NULL, 'w'},
|
{"no-password", no_argument, NULL, 'w'},
|
||||||
{"password", no_argument, NULL, 'W'},
|
{"password", no_argument, NULL, 'W'},
|
||||||
{"echo", no_argument, NULL, 'e'},
|
{"echo", no_argument, NULL, 'e'},
|
||||||
@ -57,6 +58,7 @@ main(int argc, char *argv[])
|
|||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
char *username = NULL;
|
char *username = NULL;
|
||||||
|
SimpleStringList roles = {NULL, NULL};
|
||||||
enum trivalue prompt_password = TRI_DEFAULT;
|
enum trivalue prompt_password = TRI_DEFAULT;
|
||||||
bool echo = false;
|
bool echo = false;
|
||||||
bool interactive = false;
|
bool interactive = false;
|
||||||
@ -83,7 +85,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
handle_help_version_opts(argc, argv, "createuser", help);
|
handle_help_version_opts(argc, argv, "createuser", help);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWedDsSaArRiIlLc:PEN",
|
while ((c = getopt_long(argc, argv, "h:p:U:g:wWedDsSaArRiIlLc:PEN",
|
||||||
long_options, &optindex)) != -1)
|
long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -97,6 +99,9 @@ main(int argc, char *argv[])
|
|||||||
case 'U':
|
case 'U':
|
||||||
username = pg_strdup(optarg);
|
username = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
simple_string_list_append(&roles, optarg);
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
prompt_password = TRI_NO;
|
prompt_password = TRI_NO;
|
||||||
break;
|
break;
|
||||||
@ -302,6 +307,19 @@ main(int argc, char *argv[])
|
|||||||
appendPQExpBufferStr(&sql, " NOREPLICATION");
|
appendPQExpBufferStr(&sql, " NOREPLICATION");
|
||||||
if (conn_limit != NULL)
|
if (conn_limit != NULL)
|
||||||
appendPQExpBuffer(&sql, " CONNECTION LIMIT %s", conn_limit);
|
appendPQExpBuffer(&sql, " CONNECTION LIMIT %s", conn_limit);
|
||||||
|
if (roles.head != NULL)
|
||||||
|
{
|
||||||
|
SimpleStringListCell *cell;
|
||||||
|
appendPQExpBufferStr(&sql, " IN ROLE ");
|
||||||
|
|
||||||
|
for (cell = roles.head; cell; cell = cell->next)
|
||||||
|
{
|
||||||
|
if (cell->next)
|
||||||
|
appendPQExpBuffer(&sql, "%s,", fmtId(cell->val));
|
||||||
|
else
|
||||||
|
appendPQExpBuffer(&sql, "%s", fmtId(cell->val));
|
||||||
|
}
|
||||||
|
}
|
||||||
appendPQExpBufferStr(&sql, ";\n");
|
appendPQExpBufferStr(&sql, ";\n");
|
||||||
|
|
||||||
if (echo)
|
if (echo)
|
||||||
@ -334,6 +352,7 @@ help(const char *progname)
|
|||||||
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(_(" -E, --encrypted encrypt stored password\n"));
|
printf(_(" -E, --encrypted encrypt stored password\n"));
|
||||||
|
printf(_(" -g, --role=ROLE new role will be a member of this 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"));
|
||||||
|
Loading…
Reference in New Issue
Block a user