On Fri, Nov 15, 2013 at 3:14 PM, Peter Eisentraut <pete...@gmx.net> wrote:
> On 11/14/13, 4:35 PM, Christopher Browne wrote:> On Thu, Nov 14, 2013 at
> 5:41 AM, Sameer Thakur <samthaku...@gmail.com> wrote:
>>> So i think -g option is failing
>>
>> Right you are.
>>
>> I was missing a "g:" in the getopt_long() call.
>>
>> Attached is a revised patch that handles that.
>>
>
> src/bin/scripts/createuser.c:117: indent with spaces.
> +                       case 'g':
> src/bin/scripts/createuser.c:118: indent with spaces.
> +                               roles = pg_strdup(optarg);

OK, I ran pgindent on createuser.c, which leads to the Next Patch...

-- 
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"
diff --git a/doc/src/sgml/ref/createuser.sgml b/doc/src/sgml/ref/createuser.sgml
index 2f1ea2f..5fedc80 100644
--- a/doc/src/sgml/ref/createuser.sgml
+++ b/doc/src/sgml/ref/createuser.sgml
@@ -131,6 +131,16 @@ PostgreSQL documentation
      </varlistentry>
 
      <varlistentry>
+      <term><option>-g</></term>
+      <term><option>--roles</></term>
+      <listitem>
+       <para>
+        Indicates roles to associate with this role.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
       <term><option>-i</></term>
       <term><option>--inherit</></term>
       <listitem>
diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c
index d1542d9..e2e1134 100644
--- a/src/bin/scripts/createuser.c
+++ b/src/bin/scripts/createuser.c
@@ -47,6 +47,7 @@ main(int argc, char *argv[])
                {"pwprompt", no_argument, NULL, 'P'},
                {"encrypted", no_argument, NULL, 'E'},
                {"unencrypted", no_argument, NULL, 'N'},
+               {"roles", required_argument, NULL, 'g'},
                {NULL, 0, NULL, 0}
        };
 
@@ -57,6 +58,7 @@ main(int argc, char *argv[])
        char       *host = NULL;
        char       *port = NULL;
        char       *username = NULL;
+       char       *roles = NULL;
        enum trivalue prompt_password = TRI_DEFAULT;
        bool            echo = false;
        bool            interactive = false;
@@ -83,7 +85,7 @@ main(int argc, char *argv[])
 
        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)
        {
                switch (c)
@@ -112,6 +114,9 @@ main(int argc, char *argv[])
                        case 'D':
                                createdb = TRI_NO;
                                break;
+                       case 'g':
+                               roles = pg_strdup(optarg);
+                               break;
                        case 's':
                        case 'a':
                                superuser = TRI_YES;
@@ -302,6 +307,8 @@ main(int argc, char *argv[])
                appendPQExpBuffer(&sql, " NOREPLICATION");
        if (conn_limit != NULL)
                appendPQExpBuffer(&sql, " CONNECTION LIMIT %s", conn_limit);
+       if (roles != NULL)
+               appendPQExpBuffer(&sql, " IN ROLE %s", roles);
        appendPQExpBuffer(&sql, ";\n");
 
        if (echo)
@@ -334,6 +341,7 @@ help(const char *progname)
        printf(_("  -D, --no-createdb         role cannot create databases 
(default)\n"));
        printf(_("  -e, --echo                show the commands being sent to 
the server\n"));
        printf(_("  -E, --encrypted           encrypt stored password\n"));
+       printf(_("  -g, --roles               roles to associate with this new 
role\n"));
        printf(_("  -i, --inherit             role inherits privileges of roles 
it is a\n"
                         "                            member of (default)\n"));
        printf(_("  -I, --no-inherit          role does not inherit 
privileges\n"));
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to