From: | Dmitry Ivanov <d(dot)ivanov(at)postgrespro(dot)ru> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Vladimir Borodin <root(at)simply(dot)name>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Subject: | Re: [WIP] ALTER ... OWNER TO ... CASCADE |
Date: | 2016-02-16 15:19:23 |
Message-ID: | 8931073.l16gR1AAdi@abook |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> Sometimes I hit the following. You have created a database and schema inside
> it from the superuser (i.e. postgres). Than you want to change ownership of
> whole database to another user (i.e. alice), but only this database, not
> all other objects in all other databases.
Actually, it skips all files that belong to irrelevant databases:
/*
* We only operate on shared objects and objects in the current
* database
*/
if (sdepForm->dbid != MyDatabaseId &&
sdepForm->dbid != InvalidOid)
continue;
> It seems that REASSIGN OWNED doesn’t solve this already.
Yes, it doesn't solve this case. This is due to the fact that if the superuser
that created the database is 'pinned' (e.g. postgres), it is impossible to
track any object which depends on him, since such a dependency is not present
in the pg_shdepend (pay attention to the comment below):
if (isSharedObjectPinned(AuthIdRelationId, roleid, sdepRel))
{
.....
ereport(ERROR,
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
errmsg("cannot reassign ownership....
/*
* There's no need to tell the whole truth, which is that we
* didn't track these dependencies at all ...
*/
}
This prevents you from doing something like:
test=# reassign owned by postgres to test;
ERROR: cannot reassign ownership of objects owned by role postgres because
they are required by the database system
I think that my solution might fit better.
--
Dmitry Ivanov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2016-02-16 15:20:26 | Re: [WIP] ALTER ... OWNER TO ... CASCADE |
Previous Message | Artur Zakirov | 2016-02-16 15:14:19 | Re: [PROPOSAL] Improvements of Hunspell dictionaries support |