From: hubert depesz lubaczewski <depesz@depesz.com>
To: Vijaykumar Jain <vijaykumarjain.github@gmail.com>
Cc: celati Laurent <laurent.celati@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Grant select for all tables of the 12 schemas of my one db ?
Date: Wed, 13 Oct 2021 13:00:16 +0200
Message-ID: <20211013110015.GA11950@depesz.com> (raw)
In-Reply-To: <CAM+6J96q2orrAu-U8BmtSwyoSaCXW+U8v--vKi3k14a210D=vw@mail.gmail.com>
References: <CAHByMH1agdweY=x_NptB5ka2t6Sa6YOXY-2JfHr9Zbdwj-GS1Q@mail.gmail.com>
<20211013095214.GA17654@depesz.com>
<CAM+6J96q2orrAu-U8BmtSwyoSaCXW+U8v--vKi3k14a210D=vw@mail.gmail.com>
On Wed, Oct 13, 2021 at 03:33:20PM +0530, Vijaykumar Jain wrote:
> something like this ?
Like, but not exactly.
Consider what will happen if you have schema named "whatever something
else" - with spaces in it. Or "badlyNamedSchema".
Generally you'd want to use:
execute format('GRANT USAGE ON SCHEMA %I TO readonlyuser_role', sch);
and it will take care of it.
> also,
> in case you like, I have kind of liked this
> you can try running meta commands using psql -E to get the query that you
> would like to run for DO block.
while in psql, you can simply:
select format() ... from ...;
make sure that it returns list of correct sql queries, with no mistakes,
and with ; at the end of each command, and then rerun it like:
select format() ... from ... \gexec
depesz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: depesz@depesz.com, vijaykumarjain.github@gmail.com, laurent.celati@gmail.com
Subject: Re: Grant select for all tables of the 12 schemas of my one db ?
In-Reply-To: <20211013110015.GA11950@depesz.com>
References: <CAHByMH1agdweY=x_NptB5ka2t6Sa6YOXY-2JfHr9Zbdwj-GS1Q@mail.gmail.com> <20211013095214.GA17654@depesz.com> <CAM+6J96q2orrAu-U8BmtSwyoSaCXW+U8v--vKi3k14a210D=vw@mail.gmail.com> <20211013110015.GA11950@depesz.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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