Re: CREATE/DROP ROLE transactional? GRANT/REVOKE? - Mailing list pgsql-general

From Dominique Devienne
Subject Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?
Date
Msg-id CAFCRh-_9D-V61PcBKkDOZv-eitAA6h-mNtcub7LZ+o5Lm2Rz6Q@mail.gmail.com
Whole thread Raw
In response to Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?  (Erik Wienhold <ewie@ewie.name>)
List pgsql-general
On Mon, Mar 6, 2023 at 3:02 PM Erik Wienhold <ewie@ewie.name> wrote:
> On 06/03/2023 14:19 CET Dominique Devienne <ddevienne@gmail.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 

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?
Next
From: Dominique Devienne
Date:
Subject: Re: CREATE/DROP ROLE transactional? GRANT/REVOKE?