Re: BUG #13809: Reassign owned throws error

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: alexander(dot)ashurkov(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13809: Reassign owned throws error
Date: 2015-12-09 21:09:51
Message-ID: 20151209210951.GJ2763@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

alexander(dot)ashurkov(at)gmail(dot)com wrote:

> Hello,
> when I execute "reassign owned by user to user_role" command (even with
> 'postgres' user) postgresql outputs this message:
> "ERROR: unexpected classid 1418
> SQL state: XX000"
>
> My DB has postgresql FDW (it owned by 'postgres' user as it should be), one
> foreign server (owned by 'user_role') and two user mappings for 'user' and
> 'user_role'.
>
> 'user' is member of 'user_role' ('GRANT user_role TO user').
>
> Postgresql installed from "deb http://apt.postgresql.org/pub/repos/apt/
> trusty-pgdg main" repo.

Interesting, thanks. I think this should be dealt with just like
default ACLs: REASSIGN OWNED should just ignore the USER MAPPING
objects (because they aren't "owned" as such, but they go together with
the role itself), and they would be removed by DROP OWNED. So the
attached patch would fix it.

One could instead consider that this needs to be fixed by creating a
user mapping for the receiving user instead. But this seems way too
complicated: in particular, if such a user mapping already exists, we
would have to instead do nothing. I think that would run counter to the
current simplicity of REASSIGN OWNED.

This is not a for-commit patch; I need to verify what happens with FDWs
and foreign servers and such. FDWs and servers *are* owned, so fixing
those would require a different patch.

My current assumption is that the whole FDW machinery just didn't
account for REASSIGN OWNED at all.

Also, need to put some test cases somewhere.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
reassign-user-mapping.patch text/x-diff 668 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2015-12-09 21:43:22 Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement.
Previous Message Thomas Kellerer 2015-12-09 19:40:17 Re: BUG #13808: Upsert not working