Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TypOw-0002Ib-EU for pgsql-bugs@arkaria.postgresql.org; Fri, 25 Jan 2013 19:57:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TypOv-00067j-DX for pgsql-bugs@arkaria.postgresql.org; Fri, 25 Jan 2013 19:57:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TypOu-00067e-Hs for pgsql-bugs@postgresql.org; Fri, 25 Jan 2013 19:57:24 +0000 Received: from smtprelay0131.b.hostedemail.com ([64.98.42.131] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TypOs-0005Sw-9v for pgsql-bugs@postgresql.org; Fri, 25 Jan 2013 19:57:23 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay02.b.hostedemail.com (Postfix) with SMTP id B6743D4BF9; Fri, 25 Jan 2013 19:57:19 +0000 (UTC) X-Panda: scanned! X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::::::, RULES_HIT:355:379:599:601:871:945:967:968:973:988:989:1260:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1535:1541:1575:1594:1595:1596:1711:1730:1747:1764:1777:1792:2234:2393:2525:2560:2563:2682:2685:2693:2859:2903:2933:2937:2939:2942:2945:2947:2951:2954:3022:3027:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3869:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4605:4659:5007:6261:6748:7281:7679:8957:9025:9121:10004:10394:10400:10471:10848:11256:11257:11604:11658:11914:12517:12519, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Filterd-Recvd-Size: 5065 Received: from perhan.alvh.no-ip.org (unknown [190.95.28.201]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf09.b.hostedemail.com (Postfix) with ESMTPA; Fri, 25 Jan 2013 19:57:18 +0000 (UTC) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D66AD6E0B6; Fri, 25 Jan 2013 16:57:16 -0300 (CLST) Date: Fri, 25 Jan 2013 16:57:16 -0300 From: Alvaro Herrera To: Jeff Janes Cc: Tom Lane , "spam_eater@gmx.net" , "pgsql-bugs@postgresql.org" , Jaime Casanova Subject: Re: Re: BUG #7748: "drop owned by" fails with error message: "unrecognized object class: 1262" Message-ID: <20130125195716.GI5584@alvh.no-ip.org> References: <11629.1355071394@sss.pgh.pa.us> <20121210041307.GA13156@alvh.no-ip.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.3 (/) 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 --+g7M9IMkV8truYOl Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Jeff Janes escribi=F3: > Since back-branch releases are coming up, I think fe3b5eb08 and it's > analogues in all branches should be reverted. >=20 > The issue it was intended to solve was not really a bug in the first plac= e, > and this patch didn't solve it anyway. But it introduced new behavior (in= to > all supported branches) which certainly is a bug. I disagree with this assessment, and propose the attached patch instead. The documentation for DROP OWNED says in its opening paragraph "Any privileges granted to the given roles on objects in the current database will also be revoked." So commit fe3b5eb08 was correct, though incomplete; DROP OWNED is really supposed to operate on tablespaces and databases. Not drop them, mind you --- but if the user has been granted privileges on them, those should be revoked. On the other hand, running REASSIGN OWNED means to reassign ownership of objects to some other user. There is no reason this cannot be done to shared objects as well as local objects. I note, though, that REASSIGN OWNED's documentation mentions "objects in the current database"; but in spirit, the point of it is to drop users. So applying to shared objects seems within charter to me. So what this patch does, is ensure that both REASSIGN OWNED and DROP OWNED operate on shared objects: the former changes ownership of those shared objects to the target user; and the latter removes granted privileges on those shared objects. This is the patch for the master branch; I have not tried to backpatch it yet. Conflicts are expected due to the refactoring of ALTER commands by KaiGai. --=20 =C1lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --+g7M9IMkV8truYOl Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fix-drop-reassign-owned.patch" diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 86c6183..e411372 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -1240,11 +1240,14 @@ shdepDropOwned(List *roleids, DropBehavior behavior) sdepForm->objid); break; case SHARED_DEPENDENCY_OWNER: - /* Save it for deletion below */ - obj.classId = sdepForm->classid; - obj.objectId = sdepForm->objid; - obj.objectSubId = sdepForm->objsubid; - add_exact_object_address(&obj, deleteobjs); + /* If a local object, save it for deletion below */ + if (sdepForm->dbid == MyDatabaseId) + { + obj.classId = sdepForm->classid; + obj.objectId = sdepForm->objid; + obj.objectSubId = sdepForm->objsubid; + add_exact_object_address(&obj, deleteobjs); + } break; } } @@ -1322,8 +1325,12 @@ shdepReassignOwned(List *roleids, Oid newrole) { Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple); - /* We only operate on objects in the current database */ - if (sdepForm->dbid != MyDatabaseId) + /* + * We only operate on shared objects and objects in the current + * database + */ + if (sdepForm->dbid != MyDatabaseId && + sdepForm->dbid != InvalidOid) continue; /* Unexpected because we checked for pins above */ @@ -1385,6 +1392,8 @@ shdepReassignOwned(List *roleids, Oid newrole) case OperatorFamilyRelationId: case OperatorClassRelationId: case ExtensionRelationId: + case TableSpaceRelationId: + case DatabaseRelationId: { Oid classId = sdepForm->classid; Relation catalog; --+g7M9IMkV8truYOl 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 --+g7M9IMkV8truYOl--