Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a7WDd-0001ss-No for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Dec 2015 22:31:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a7WDd-0002fg-49 for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Dec 2015 22:31:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a7WD0-0001yi-OE for pgsql-bugs@postgresql.org; Fri, 11 Dec 2015 22:30:38 +0000 Received: from out.smtp-auth.no-ip.com ([8.23.224.60]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a7WCw-00014F-5I for pgsql-bugs@postgresql.org; Fri, 11 Dec 2015 22:30:38 +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 85EA7400AFA; Fri, 11 Dec 2015 14:30:27 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 9B02626DD; Fri, 11 Dec 2015 19:30:25 -0300 (CLT) Date: Fri, 11 Dec 2015 19:30:25 -0300 From: Alvaro Herrera To: cpacejo@clearskydata.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type Message-ID: <20151211223025.GX2763@alvherre.pgsql> References: <20151007142530.8425.57690@wrigleys.postgresql.org> <20151007170154.GB4405@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20151007170154.GB4405@alvherre.pgsql> 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 Alvaro Herrera wrote: > cpacejo@clearskydata.com wrote: > > =# REASSIGN OWNED BY user1 TO user2; > > > > =# SELECT typowner, relowner FROM pg_type JOIN pg_class ON typrelid = > > relfilenode WHERE typname = 'foo'; > > -[ RECORD 1 ]--- > > typowner | 8713825 > > relowner | 16384 > > Hmm. I guess we're missing a recursion step somewhere. I would have > assumed that the pg_class entry would also have a dependency on the > owner and should would have been visited in the initial loop. Strange. I think I see what's going on here: in AlterTypeOwner the code calls ATExecChangeOwner when it detects a composite type to start the modification starting from the type relation's, from where it cascades onto the type itself. However, AlterTypeOwnerInternal hasn't heard of this trick and just changes itself and the array entry, so the pg_class entry is not modified. I think the bug is that shdepReassignOwned shouldn't be calling AlterTypeOwnerInternal directly, because that routine is not of a high enough level. We need another routine sitting between AlterTypeOwner and AlterTypeOwnerInternal which does the real work for the former (including calling ATExecChangeOwner for composites), after looking up the type OID from the name list; then shdepReassignOwned should call that new intermediate function. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs