pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedgathering ownership and grant permissions
5+ messages / 2 participants
[nested] [flat]
* gathering ownership and grant permissions
@ 2018-02-16 19:47 chris <chrisk@pgsqlrocket.com>
0 siblings, 1 reply; 5+ messages in thread
From: chris @ 2018-02-16 19:47 UTC (permalink / raw)
To: pgsql-general
HI,
I would like to know if there is a better way to grab the grant
permissions as well as the "owner to" of a table.
I can currently do this through a pg_dumb with greps for "^grant" and
"^alter" but than I need to do a word search of those lines looking for
the specific answers which gets much more involved.
I essentially need to know what grant command was ran and use that grant
permission to set to a variable for a script.
Ex: GRANT ALL ON TABLE testing TO bob; then set only the "all" to a
variable.
And then same for the ALTER .... OWNER TO bob.
This is on postgresl 9.6.
Thank you,
Chris
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: gathering ownership and grant permissions
@ 2018-02-16 20:05 Melvin Davidson <melvin6925@gmail.com>
parent: chris <chrisk@pgsqlrocket.com>
0 siblings, 1 reply; 5+ messages in thread
From: Melvin Davidson @ 2018-02-16 20:05 UTC (permalink / raw)
To: chris <chrisk@pgsqlrocket.com>; +Cc: pgsql-general
On Fri, Feb 16, 2018 at 2:47 PM, chris <chrisk@pgsqlrocket.com> wrote:
> HI,
>
> I would like to know if there is a better way to grab the grant
> permissions as well as the "owner to" of a table.
>
> I can currently do this through a pg_dumb with greps for "^grant" and
> "^alter" but than I need to do a word search of those lines looking for the
> specific answers which gets much more involved.
>
> I essentially need to know what grant command was ran and use that grant
> permission to set to a variable for a script.
>
> Ex: GRANT ALL ON TABLE testing TO bob; then set only the "all" to a
> variable.
>
> And then same for the ALTER .... OWNER TO bob.
>
> This is on postgresl 9.6.
>
> Thank you,
>
> Chris
>
>
>
*>... is a better way to grab the grant permissions as well as the "owner
to" of a table. *
*Chris, see if the query below will help. Note, you need to execute as a
superuser.SELECT n.nspname, c.relname,
o.rolname AS owner, array_to_string(ARRAY[c.relacl], '|') as
permits FROM pg_class c JOIN pg_namespace n ON (n.oid =
c.relnamespace) JOIN pg_authid o ON (o.oid = c.relowner)WHERE n.nspname
not like 'pg_%' AND n.nspname not like 'inform_%' AND relkind =
'r'ORDER BY 1;*
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: gathering ownership and grant permissions
@ 2018-02-16 20:13 chris <chrisk@pgsqlrocket.com>
parent: Melvin Davidson <melvin6925@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: chris @ 2018-02-16 20:13 UTC (permalink / raw)
To: Melvin Davidson <melvin6925@gmail.com>; +Cc: pgsql-general
Thanks for the quick response.
That does not work for what I need because I only need the owner and
permissions of one table, I need the grant to look like the output that
pg_dump displays.
ex:
GRANT ALL ON TABLE testing_cdc TO bob;
--
-- PostgreSQL database dump complete
--
I need a way which my script can isolate the owner's name and set it to
a variable on its own. Same with grant.
Thanks
On 02/16/2018 01:05 PM, Melvin Davidson wrote:
>
>
> On Fri, Feb 16, 2018 at 2:47 PM, chris <chrisk@pgsqlrocket.com
> <mailto:chrisk@pgsqlrocket.com>> wrote:
>
> HI,
>
> I would like to know if there is a better way to grab the grant
> permissions as well as the "owner to" of a table.
>
> I can currently do this through a pg_dumb with greps for "^grant"
> and "^alter" but than I need to do a word search of those lines
> looking for the specific answers which gets much more involved.
>
> I essentially need to know what grant command was ran and use that
> grant permission to set to a variable for a script.
>
> Ex: GRANT ALL ON TABLE testing TO bob; then set only the "all" to
> a variable.
>
> And then same for the ALTER .... OWNER TO bob.
>
> This is on postgresl 9.6.
>
> Thank you,
>
> Chris
>
>
>
> *>... is a better way to grab the grant permissions as well as the
> "owner to" of a table.
>
> *
> *Chris, see if the query below will help. Note, you need to execute as
> a superuser.
>
> SELECT n.nspname,
> c.relname,
> o.rolname AS owner,
> array_to_string(ARRAY[c.relacl], '|') as permits
> FROM pg_class c
> JOIN pg_namespace n ON (n.oid = c.relnamespace)
> JOIN pg_authid o ON (o.oid = c.relowner)
> WHERE n.nspname not like 'pg_%'
> AND n.nspname not like 'inform_%'
> AND relkind = 'r'
> ORDER BY 1;*
>
>
>
>
> --
> *Melvin Davidson*
> I reserve the right to fantasize. Whether or not you
> wish to share my fantasy is entirely up to you.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: gathering ownership and grant permissions
@ 2018-02-16 20:50 chris <chrisk@pgsqlrocket.com>
parent: chris <chrisk@pgsqlrocket.com>
0 siblings, 1 reply; 5+ messages in thread
From: chris @ 2018-02-16 20:50 UTC (permalink / raw)
To: Melvin Davidson <melvin6925@gmail.com>; +Cc: pgsql-general
I'm sorry I realized that I only need to know which users have
permissions to the table which I can do through
$ psql -t
SELECT grantee
FROM information_schema.role_table_grants
WHERE table_name='table_name'
GROUP BY grantee;
thanks!
On 02/16/2018 01:13 PM, chris wrote:
>
> Thanks for the quick response.
>
> That does not work for what I need because I only need the owner and
> permissions of one table, I need the grant to look like the output
> that pg_dump displays.
>
> ex:
>
> GRANT ALL ON TABLE testing_cdc TO bob;
>
>
> --
> -- PostgreSQL database dump complete
> --
>
> I need a way which my script can isolate the owner's name and set it
> to a variable on its own. Same with grant.
>
> Thanks
>
>
> On 02/16/2018 01:05 PM, Melvin Davidson wrote:
>>
>>
>> On Fri, Feb 16, 2018 at 2:47 PM, chris <chrisk@pgsqlrocket.com
>> <mailto:chrisk@pgsqlrocket.com>> wrote:
>>
>> HI,
>>
>> I would like to know if there is a better way to grab the grant
>> permissions as well as the "owner to" of a table.
>>
>> I can currently do this through a pg_dumb with greps for "^grant"
>> and "^alter" but than I need to do a word search of those lines
>> looking for the specific answers which gets much more involved.
>>
>> I essentially need to know what grant command was ran and use
>> that grant permission to set to a variable for a script.
>>
>> Ex: GRANT ALL ON TABLE testing TO bob; then set only the "all" to
>> a variable.
>>
>> And then same for the ALTER .... OWNER TO bob.
>>
>> This is on postgresl 9.6.
>>
>> Thank you,
>>
>> Chris
>>
>>
>>
>> *>... is a better way to grab the grant permissions as well as the
>> "owner to" of a table.
>>
>> *
>> *Chris, see if the query below will help. Note, you need to execute
>> as a superuser.
>>
>> SELECT n.nspname,
>> c.relname,
>> o.rolname AS owner,
>> array_to_string(ARRAY[c.relacl], '|') as permits
>> FROM pg_class c
>> JOIN pg_namespace n ON (n.oid = c.relnamespace)
>> JOIN pg_authid o ON (o.oid = c.relowner)
>> WHERE n.nspname not like 'pg_%'
>> AND n.nspname not like 'inform_%'
>> AND relkind = 'r'
>> ORDER BY 1;*
>>
>>
>>
>>
>> --
>> *Melvin Davidson*
>> I reserve the right to fantasize. Whether or not you
>> wish to share my fantasy is entirely up to you.
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: gathering ownership and grant permissions
@ 2018-02-16 23:44 Melvin Davidson <melvin6925@gmail.com>
parent: chris <chrisk@pgsqlrocket.com>
0 siblings, 0 replies; 5+ messages in thread
From: Melvin Davidson @ 2018-02-16 23:44 UTC (permalink / raw)
To: chris <chrisk@pgsqlrocket.com>; +Cc: pgsql-general
On Fri, Feb 16, 2018 at 3:50 PM, chris <chrisk@pgsqlrocket.com> wrote:
> I'm sorry I realized that I only need to know which users have permissions
> to the table which I can do through
>
> $ psql -t
>
> SELECT grantee
> FROM information_schema.role_table_grants
> WHERE table_name='table_name'
> GROUP BY grantee;
>
> thanks!
>
>
>
> On 02/16/2018 01:13 PM, chris wrote:
>
> Thanks for the quick response.
>
> That does not work for what I need because I only need the owner and
> permissions of one table, I need the grant to look like the output that
> pg_dump displays.
>
> ex:
>
> GRANT ALL ON TABLE testing_cdc TO bob;
>
>
> --
> -- PostgreSQL database dump complete
> --
>
> I need a way which my script can isolate the owner's name and set it to a
> variable on its own. Same with grant.
>
> Thanks
>
> On 02/16/2018 01:05 PM, Melvin Davidson wrote:
>
>
>
> On Fri, Feb 16, 2018 at 2:47 PM, chris <chrisk@pgsqlrocket.com> wrote:
>
>> HI,
>>
>> I would like to know if there is a better way to grab the grant
>> permissions as well as the "owner to" of a table.
>>
>> I can currently do this through a pg_dumb with greps for "^grant" and
>> "^alter" but than I need to do a word search of those lines looking for the
>> specific answers which gets much more involved.
>>
>> I essentially need to know what grant command was ran and use that grant
>> permission to set to a variable for a script.
>>
>> Ex: GRANT ALL ON TABLE testing TO bob; then set only the "all" to a
>> variable.
>>
>> And then same for the ALTER .... OWNER TO bob.
>>
>> This is on postgresl 9.6.
>>
>> Thank you,
>>
>> Chris
>>
>>
>>
>
>
> *>... is a better way to grab the grant permissions as well as the "owner
> to" of a table. *
>
>
>
>
>
>
>
>
>
>
>
>
> *Chris, see if the query below will help. Note, you need to execute as a
> superuser. SELECT n.nspname, c.relname,
> o.rolname AS owner, array_to_string(ARRAY[c.relacl], '|') as
> permits FROM pg_class c JOIN pg_namespace n ON (n.oid =
> c.relnamespace) JOIN pg_authid o ON (o.oid = c.relowner) WHERE
> n.nspname not like 'pg_%' AND n.nspname not like 'inform_%' AND
> relkind = 'r' ORDER BY 1;*
>
>
>
>
> --
> *Melvin Davidson*
> I reserve the right to fantasize. Whether or not you
> wish to share my fantasy is entirely up to you.
>
>
>
>
*>I'm sorry I realized that I only need to know which users have
permissions to the table *
*No need to apologize. No hurt, no foul. Thank you for your query.*
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-02-16 23:44 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-16 19:47 gathering ownership and grant permissions chris <chrisk@pgsqlrocket.com>
2018-02-16 20:05 ` Melvin Davidson <melvin6925@gmail.com>
2018-02-16 20:13 ` chris <chrisk@pgsqlrocket.com>
2018-02-16 20:50 ` chris <chrisk@pgsqlrocket.com>
2018-02-16 23:44 ` Melvin Davidson <melvin6925@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox