Re: Extra functionality to createuser

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Sameer Thakur <samthakur74(at)gmail(dot)com>, PostgreSQL Mailing Lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extra functionality to createuser
Date: 2013-11-20 04:54:41
Message-ID: CAA4eK1J6A5E5xUoxyPuhv1B7YnbMXWhK0_dQ53pe86POnJ9Wrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 20, 2013 at 2:05 AM, Christopher Browne <cbbrowne(at)gmail(dot)com> wrote:
> On Mon, Nov 18, 2013 at 1:01 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> On Sat, Nov 16, 2013 at 4:57 AM, Christopher Browne <cbbrowne(at)gmail(dot)com> wrote:
>
> I picked the location of the 'g:' in the opt_long() call basically arbitrarily;

I think this is okay, the main point was to maintain consistency
with surrounding code.

> if there is any reason for it to go in a different spot, I'd be happy to
> shift it.

The only other option could be to add it at end which is generally
better unless we get any benefit by adding it in middle.

On further tests, I found inconsistency in behavior when some special
characters are used in role names.

1. Test for role name containing quotes
a. In psql, create a role containing quotes in role name.
create role amitk in role "test_ro'le_3";

b. Now if we try to make a new role member of this role using
createuser utility, it gives error
try-1
createuser.exe -g test_ro'le_3 -p 5446 amitk_2
createuser: creation of new role failed: ERROR: unterminated quoted
string at or near "'le_3;"
LINE 1: ... NOCREATEDB NOCREATEROLE INHERIT LOGIN IN ROLE test_ro'le_3;
try-2
createuser.exe -g "test_ro'le_3" -p 5446 amitk
createuser: creation of new role failed: ERROR: unterminated quoted
string at or near "'le_3;"
LINE 1: ... NOCREATEDB NOCREATEROLE INHERIT LOGIN IN ROLE test_ro'le_3;

c. If I try quoted string in new role to be created, it works fine.
createuser.exe -p 5446 am'itk_2

As quoted strings work well for role names, I think it should work
with -g option as well.

2. Test for role name containing special character ';' (semicolon)
a. create role "test;_1";

b. Now if we try to make a new role member of this role using
createuser utility, it gives error
try-1
createuser.exe -g test;_1 -p 5446 amitk_4
createuser: creation of new role failed: ERROR: syntax error at or near "_1"
LINE 1: ...RUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN IN ROLE test;_1;
try-2 ^
createuser.exe -g "test;_1" -p 5446 amitk_4
createuser: creation of new role failed: ERROR: syntax error at or near "_1"
LINE 1: ...RUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN IN ROLE test;_1;
^
try-3
createuser.exe -g 'test;_1' -p 5446 amitk_4
createuser: creation of new role failed: ERROR: syntax error at or
near "'test;_1'"
LINE 1: ...SER NOCREATEDB NOCREATEROLE INHERIT LOGIN IN ROLE 'test;_1';

c. If I try semicolon in new role to be created, it works fine.
createuser.exe -p 5446 amit;k_3

As semicolon work well for role names, I think it should work with -g
option as well.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rajeev rastogi 2013-11-20 06:20:43 Re: PostgreSQL Service on Windows does not start. ~ "is not a valid Win32 application"
Previous Message Fabrízio de Royes Mello 2013-11-20 04:35:58 Re: CREATE TABLE IF NOT EXISTS AS