BUG #18411: Unable to create database with owner on AWS RDS

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: myanodress(at)gmail(dot)com
Subject: BUG #18411: Unable to create database with owner on AWS RDS
Date: 2024-03-27 17:32:16
Message-ID: 18411-fdfca450bc4e7dd8@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18411
Logged by: Myka Anold Dresser
Email address: myanodress(at)gmail(dot)com
PostgreSQL version: 16.2
Operating system: AWS RDS
Description:

Using the postgres user on AWS RDS, execution of

CREATE USER my_user WITH PASSWORD 'my-user-password';
CREATE DATABASE my_database WITH OWNER=my_user;

Results in an error:

ERROR: must be able to SET ROLE "my_user"
SQL state: 42501

However, the following succeeds
CREATE USER my_user WITH PASSWORD 'my-user-password';
CREATE DATABASE my_database;
ALTER DATABASE my_database OWNER TO my_user;

Is this intended behaviour or am I taking advantage of a bug by creating the
database and then setting the OWNER using ALTER DATABASE?

The documentation suggests that both forms should cause an error
https://www.postgresql.org/docs/current/sql-grant.html
To create an object owned by another role or give ownership of an existing
object to another role, you must have the ability to SET ROLE to that role;
otherwise, commands such as ALTER ... OWNER TO or CREATE DATABASE ... OWNER
will fail.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-03-27 18:04:04 BUG #18412: could not send data to client: Broken pipe
Previous Message Tom Lane 2024-03-27 15:21:50 Re: BUG #18410: SQL Error [XX000]: ERROR: variable not found in subplan target list