Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Erik Wienhold <ewie(at)ewie(dot)name>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?
Date: 2023-03-06 15:34:52
Message-ID: CAFCRh-_9D-V61PcBKkDOZv-eitAA6h-mNtcub7LZ+o5Lm2Rz6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 6, 2023 at 3:02 PM Erik Wienhold <ewie(at)ewie(dot)name> wrote:

> > On 06/03/2023 14:19 CET Dominique Devienne <ddevienne(at)gmail(dot)com> wrote:
> > Perhaps I missed it in the doc (e.g. [1]), but are DDLs around ROLEs and
> > GRANTs transactional?
>
> Have you tried?

Nope. I thought about it, but then I could have convinced myself on an
invalid demo.
So I preferred to ask the experts.

> DDL is transactional unless stated otherwise (cf. CREATE DATABASE,
> CREATE INDEX CONCURRENTLY, CREATE TABLESPACE).
>

I now see (and fully appreciate) the Note below:
- CREATE DATABASE cannot be executed inside a transaction block.

I didn't realize the fact CREATE ROLE didn't have that note was significant.

Run the following psql script:
>

Thanks for the demo. Appreciated.

> Since I'm creating many ROLEs and making many GRANTs, based info I read
> from
> > PostgreSQL itself (in pg_catalog and elsewhere), should everything be in
> a
> > single transaction?
>
> If it should be atomic and the commands are allowed in transactions, then
> yes,
> use transactions.
>

Thanks again. --DD

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dominique Devienne 2023-03-06 15:39:25 Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?
Previous Message Tom Lane 2023-03-06 15:31:52 Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?