pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: spam_eater@gmx.net <spam_eater@gmx.net>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Cc: Jaime Casanova <jaime@2ndquadrant.com>
Subject: Re: Re: BUG #7748: "drop owned by" fails with error message: "unrecognized object class: 1262"
Date: Fri, 25 Jan 2013 16:57:16 -0300
Message-ID: <20130125195716.GI5584@alvh.no-ip.org> (raw)
In-Reply-To: <CAMkU=1xbchvew5g2qqRjFy_hEkYFFgGXQE3cjEcV3eWCCsO3eQ@mail.gmail.com>
References: <E1ThhcE-0001nJ-1v@wrigleys.postgresql.org>
	<11629.1355071394@sss.pgh.pa.us>
	<20121210041307.GA13156@alvh.no-ip.org>
	<CAMkU=1xbchvew5g2qqRjFy_hEkYFFgGXQE3cjEcV3eWCCsO3eQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Jeff Janes escribió:

> Since back-branch releases are coming up, I think fe3b5eb08 and it's
> analogues in all branches should be reverted.
> 
> The issue it was intended to solve was not really a bug in the first place,
> and this patch didn't solve it anyway. But it introduced new behavior (into
> 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.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, 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

Attachments:

fix-drop-reassign-owned.patch (text/x-diff, 1.6K) download 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;

view thread (17+ messages)  latest in thread

Message-ID: <20130125195716.GI5584@alvh.no-ip.org>
Permalink:  ../20130125195716.GI5584@alvh.no-ip.org/
Also on:    postgresql.org/message-id/20130125195716.GI5584@alvh.no-ip.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@2ndquadrant.com, jeff.janes@gmail.com, tgl@sss.pgh.pa.us, spam_eater@gmx.net, jaime@2ndquadrant.com
  Subject: Re: BUG #7748: "drop owned by" fails with error message: "unrecognized object class: 1262"
  In-Reply-To: <20130125195716.GI5584@alvh.no-ip.org>
  References: <E1ThhcE-0001nJ-1v@wrigleys.postgresql.org> <11629.1355071394@sss.pgh.pa.us> <20121210041307.GA13156@alvh.no-ip.org> <CAMkU=1xbchvew5g2qqRjFy_hEkYFFgGXQE3cjEcV3eWCCsO3eQ@mail.gmail.com> <20130125195716.GI5584@alvh.no-ip.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox