Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a6m0c-0004Aw-8X for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Dec 2015 21:10:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a6m0b-0004uW-MD for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Dec 2015 21:10:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a6lzy-0004AN-Rn for pgsql-bugs@postgresql.org; Wed, 09 Dec 2015 21:10:07 +0000 Received: from out.smtp-auth.no-ip.com ([8.23.224.60]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a6lzu-0003Gl-G7 for pgsql-bugs@postgresql.org; Wed, 09 Dec 2015 21:10:05 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [200.104.53.52]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 99B774007F6; Wed, 9 Dec 2015 13:09:55 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 246937A5; Wed, 9 Dec 2015 18:09:51 -0300 (CLT) Date: Wed, 9 Dec 2015 18:09:51 -0300 From: Alvaro Herrera To: alexander.ashurkov@gmail.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13809: Reassign owned throws error Message-ID: <20151209210951.GJ2763@alvherre.pgsql> References: <20151209112642.876.19827@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="V0207lvV8h4k8FAm" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20151209112642.876.19827@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --V0207lvV8h4k8FAm Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit alexander.ashurkov@gmail.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 --V0207lvV8h4k8FAm Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="reassign-user-mapping.patch" diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 15fda71..bfe111e 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -43,6 +43,7 @@ #include "catalog/pg_ts_config.h" #include "catalog/pg_ts_dict.h" #include "catalog/pg_type.h" +#include "catalog/pg_user_mapping.h" #include "commands/alter.h" #include "commands/dbcommands.h" #include "commands/collationcmds.h" @@ -1367,6 +1368,7 @@ shdepReassignOwned(List *roleids, Oid newrole) break; case DefaultAclRelationId: + case UserMappingRelationId: /* * Ignore default ACLs; they should be handled by DROP --V0207lvV8h4k8FAm Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --V0207lvV8h4k8FAm--