Re: [HACKERS] Multiline privileges in \z

Lists: pgsql-hackerspgsql-patches
From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Multiline privileges in \z
Date: 2008-04-17 16:21:36
Message-ID: 37ed240d0804170921h7a6b92fev65aeb99f658f8f21@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Hi hackers,

It occurred to me that psql's \z command could benefit from the
addition of some newlines. With any more than one grantee per object,
the output of \z rapidly becomes extremely wide, and very hard to
read.

I'd like to split the output onto one line per grantee. So, instead of this:

Schema | Name | Type | Access privileges
--------+------+-------+-------------------------------------------------------------------------
public | a | table |
{brendanjurd=arwdxt/brendanjurd,foo=arwd/brendanjurd,bar=r/brendanjurd}
public | b | table | {brendanjurd=arwdxt/brendanjurd,foo=arwd/brendanjurd}
(2 rows)

You would get this:

Schema | Name | Type | Access privileges
--------+------+-------+--------------------------------
public | a | table | brendanjurd=arwdxt/brendanjurd
: foo=arwd/brendanjurd
: bar=r/brendanjurd
public | b | table | brendanjurd=arwdxt/brendanjurd
: foo=arwd/brendanjurd
(2 rows)

Because the -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ACLs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIB3kL5YBsbHkuyV0RAgWQAJ9bcl3bOFozvi9LxRAQN1OwT3t+QgCcCGVq
dcMw3wIBQVPv1nYDBCSRpDA=
=s1eD
-----END PGP SIGNATURE-----
are stored as an array, the patch to achieve this is trivial (see attached).

Looking forward to your comments.

Added to wiki.

Cheers,
BJ

Attachment Content-Type Size
multiline-privs_0.diff text/plain 3.1 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Multiline privileges in \z
Date: 2008-04-17 16:37:30
Message-ID: 21359.1208450250@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

"Brendan Jurd" <direvus(at)gmail(dot)com> writes:
> It occurred to me that psql's \z command could benefit from the
> addition of some newlines. With any more than one grantee per object,
> the output of \z rapidly becomes extremely wide, and very hard to
> read.

Seems like a good idea now that psql deals nicely with multiline output.

The function names in the patch need schema-qualification in case
pg_catalog is not first in the search path.

regards, tom lane


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Multiline privileges in \z
Date: 2008-04-17 16:51:48
Message-ID: 37ed240d0804170951m486e7ecej75c725983099716f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Apr 18, 2008 at 2:37 AM, Tom Lane wrote:
> The function names in the patch need schema-qualification in case
> pg_catalog is not first in the search path.
>

Ah, yes. I should have seen that. Thanks Tom.

New version attached with schema-qualification.

Cheers,
BJ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIB4Ae5YBsbHkuyV0RAqJVAJ9+h6wZrLT9YFRw3s2E742sg7Yr4wCgvtcq
xK7cTnbiGtfpGGYw5WP4asI=
=hf8W
-----END PGP SIGNATURE-----

Attachment Content-Type Size
multiline-privs_1.diff text/plain 3.1 KB

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Multiline privileges in \z
Date: 2008-05-03 23:57:43
Message-ID: 481CFBF7.2080701@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Brendan Jurd wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Fri, Apr 18, 2008 at 2:37 AM, Tom Lane wrote:
>
>> The function names in the patch need schema-qualification in case
>> pg_catalog is not first in the search path.
>>
>>
>
> Ah, yes. I should have seen that. Thanks Tom.
>
> New version attached with schema-qualification.
>

Wouldn't this expression:

pg_catalog.array_to_string(c.relacl, chr(10))

be better expressed as


pg_catalog.array_to_string(c.relacl, E'\n')

?

Quoted inside a C literal, the backslash would have to be doubled, of course.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Multiline privileges in \z
Date: 2008-05-04 00:55:31
Message-ID: 1741.1209862531@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Wouldn't this expression:
> pg_catalog.array_to_string(c.relacl, chr(10))
> be better expressed as
> pg_catalog.array_to_string(c.relacl, E'\n')

+1 ... it's minor, but knowing that ASCII LF is 10 is probably not
wired into too many people's brains anymore. (Besides, some of us
remember it as octal 12, anyway...)

regards, tom lane


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andrew Dunstan" <andrew(at)dunslane(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Multiline privileges in \z
Date: 2008-05-04 22:05:58
Message-ID: 37ed240d0805041505h336146b1tdcc7339a46952760@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, May 4, 2008 at 10:55 AM, Tom Lane wrote:
> Andrew Dunstan writes:
> > Wouldn't this expression:
> > pg_catalog.array_to_string(c.relacl, chr(10))
> > be better expressed as
> > pg_catalog.array_to_string(c.relacl, E'\n')
>
> +1 ... it's minor, but knowing that ASCII LF is 10 is probably not
> wired into too many people's brains anymore. (Besides, some of us
> remember it as octal 12, anyway...)
>

Fair enough. I just wanted a non-messy way of saying "1 newline,
please", and I wasn't too sure whether backslash escapes were
considered kosher for internal queries.

But you're right, readability is important. No objections to using
the escape syntax.

Please note that I used chr(10) in my \du attributes patch as well.

Cheers,
BJ

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIHjNA5YBsbHkuyV0RAuNSAJ0ZDLxhHaPj4CBsBCILnxHy+5Jf5ACfQHMH
4XZxczc+YEow3AFdayn9fGs=
=+TSV
-----END PGP SIGNATURE-----


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Multiline privileges in \z
Date: 2008-05-05 01:22:03
Message-ID: 481E613B.3020003@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Brendan Jurd wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Fri, Apr 18, 2008 at 2:37 AM, Tom Lane wrote:
>
>> The function names in the patch need schema-qualification in case
>> pg_catalog is not first in the search path.
>>
>>
>
> Ah, yes. I should have seen that. Thanks Tom.
>
> New version attached with schema-qualification.
>
>
>

Committed with slight editorialization and a consequent docs change.

cheers

andrew