Thread: createuser patch

createuser patch

From
Alvaro Herrera
Date:
Hackers,

Here is a patch to createuser, to make it handle some of the options of
CREATE ROLE.

While developing it, I noticed it takes an annoying number of options,
or ask an annoying number of questions.  I thought about producing a
version called "createrole" which would have all the options and ask
about them if not supplied, but if called with the name "createuser" (a
symlink or hardlink) it would assume defaults for some of them, like
INHERIT and LOGIN.  However I don't see this pattern applied elsewhere
in our programs, so I'm not sure we want to establish this precedent.

Also, note that the "inherit" option uses "-y" as the short option,
because all the other good letters are taken.  In particular, -i is
taken by the now obsolete SYSID.  -i is accepted but silently ignored.
I actually wondered if mantaining backwards compatibility was so
important as in SQL -- if it's not, then we can get rid of -i as SYSID,
and use it for INHERIT.

Also, note that -a/-A ("adduser") is an undocumented alias for -s/-S,
just like CREATEUSER is an alias for SUPERUSER.

There are some options for CREATE ROLE which are not supported in
createuser, like IN ROLE, ROLE, ADMIN, VALID UNTIL.  The old one didn't
handle IN GROUP nor VALID UNTIL either, so I don't see this as a big
problem.

Comments?  After things have settled I'll generate the doc patch.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
Management by consensus: I have decided; you concede.
(Leonard Liu)

Re: createuser patch

From
Alvaro Herrera
Date:
On Fri, Aug 12, 2005 at 12:37:22PM -0400, Alvaro Herrera wrote:

> Here is a patch to createuser, to make it handle some of the options of
> CREATE ROLE.

Sorry :-(

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"La principal característica humana es la tontería"
(Augusto Monterroso)

Attachment

Re: createuser patch

From
Bruce Momjian
Date:
I assume this is for 8.1 because of the new ROLE capability.

Your patch has been added to the PostgreSQL unapplied patches list at:

    http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------


Alvaro Herrera wrote:
> On Fri, Aug 12, 2005 at 12:37:22PM -0400, Alvaro Herrera wrote:
>
> > Here is a patch to createuser, to make it handle some of the options of
> > CREATE ROLE.
>
> Sorry :-(
>
> --
> Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
> "La principal caracter?stica humana es la tonter?a"
> (Augusto Monterroso)

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: createuser patch

From
Alvaro Herrera
Date:
On Fri, Aug 12, 2005 at 10:49:26PM -0400, Bruce Momjian wrote:
>
> I assume this is for 8.1 because of the new ROLE capability.

IMHO this is an integral part of the ROLE patch.


> > On Fri, Aug 12, 2005 at 12:37:22PM -0400, Alvaro Herrera wrote:
> >
> > > Here is a patch to createuser, to make it handle some of the options of
> > > CREATE ROLE.


--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"La tristeza es un muro entre dos jardines" (Khalil Gibran)

Re: createuser patch

From
Tom Lane
Date:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> Here is a patch to createuser, to make it handle some of the options of
> CREATE ROLE.

> While developing it, I noticed it takes an annoying number of options,
> or ask an annoying number of questions.  I thought about producing a
> version called "createrole" which would have all the options and ask
> about them if not supplied, but if called with the name "createuser" (a
> symlink or hardlink) it would assume defaults for some of them, like
> INHERIT and LOGIN.  However I don't see this pattern applied elsewhere
> in our programs, so I'm not sure we want to establish this precedent.

Since it is called createuser, and not creategroup or createrole, I
don't see a big problem with making it default to LOGIN and INHERIT
true rather than prompting for them.  I'll make it do that unless there
are objections.

> Also, note that the "inherit" option uses "-y" as the short option,
> because all the other good letters are taken.  In particular, -i is
> taken by the now obsolete SYSID.  -i is accepted but silently ignored.
> I actually wondered if mantaining backwards compatibility was so
> important as in SQL -- if it's not, then we can get rid of -i as SYSID,
> and use it for INHERIT.

It's really hard to believe that anyone is using -i for SYSID in
scripts, so let's just change it.

            regards, tom lane

Re: createuser patch

From
Tom Lane
Date:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> Here is a patch to createuser, to make it handle some of the options of
> CREATE ROLE.

Applied with the changes I mentioned earlier.

> Comments?  After things have settled I'll generate the doc patch.

Already done.  I left most of the instances of "user" as "user" in the
doc page, rather than changing them all to "role"; not entirely sure
about this though.

            regards, tom lane