pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16374: I can't directly change owner from my created database to my created user.
2+ messages / 2 participants
[nested] [flat]

* BUG #16374: I can't directly change owner from my created database to my created user.
@ 2020-04-17 12:50  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-04-17 12:50 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: 369358123@qq.com

The following bug has been logged on the website:

Bug reference:      16374
Logged by:          wang yakun
Email address:      369358123@qq.com
PostgreSQL version: 10.10
Operating system:   centos
Description:        

> [postgres10@pgcore-split-0001 ~]$ psql -Upostgres
> psql (10.10)
> Type "help" for help.
>
> postgres=# create user root with login nosuperuser inherit createdb
createrole replication;
> CREATE ROLE
> postgres=# create role rdsgroup with nologin nosuperuser inherit
nocreatedb nocreaterole noreplication;
> CREATE ROLE
> postgres=# grant pg_monitor, pg_read_all_stats, pg_signal_backend,
pg_stat_scan_tables, rdsgroup to root;
> GRANT ROLE
> postgres=# \c postgres root
> You are now connected to database "postgres" as user "root".
> postgres=> CREATE DATABASE db1 WITH ENCODING = 'UTF8';
> CREATE DATABASE
> postgres=> create user user1 password '';
> NOTICE:  empty string is not a valid password, clearing password
> CREATE ROLE
> postgres=> alter user user1 with login;
> ALTER ROLE
> **postgres=> alter database db1 owner to user1;**
> **2020-04-17 16:37:04.328 CST [4712] ERROR:  must be member of role
"user1"**
> **2020-04-17 16:37:04.328 CST [4712] STATEMENT:  alter database db1 owner
to user1;**
> **ERROR:  must be member of role "user1"**

My user is "root".I know that before execute "alter database" stmt, I can
login with user1 and execute "grant user1 to db1", so this "alter database"
stmt will work.

However, "user1" is my created, and "db1" is my created too. Why couldn't I
chenge owner of "db1" to "user1" directly?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16374: I can't directly change owner from my created database to my created user.
@ 2020-04-17 13:29  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2020-04-17 13:29 UTC (permalink / raw)
  To: 369358123@qq.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
>> **postgres=> alter database db1 owner to user1;**
>> **2020-04-17 16:37:04.328 CST [4712] ERROR:  must be member of role
> "user1"**

> However, "user1" is my created, and "db1" is my created too. Why couldn't I
> chenge owner of "db1" to "user1" directly?

Like it says, you're not a member of role user1.  Since you have
createrole privilege, you could make yourself a member:

regression=> grant user1 to root;
GRANT ROLE

and then it'd work.  But you didn't.  (This is one of the ways that
createrole is less powerful, and less dangerous, than superuser.)

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-04-17 13:29 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17 12:50 BUG #16374: I can't directly change owner from my created database to my created user. PG Bug reporting form <noreply@postgresql.org>
2020-04-17 13:29 ` Tom Lane <tgl@sss.pgh.pa.us>

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