REASSIGN OWNED doesn't know how to deal with USER MAPPINGs

Started by Jaime Casanovaabout 10 years ago3 messages
#1Jaime Casanova
jaime.casanova@2ndquadrant.com
1 attachment(s)

Hi,

We just notice $SUBJECT. Attached patch fixes it by ignoring USER
MAPPINGs in shdepReassignOwned() just like it happens with default
ACLs.

DROP OWNED manages it well.

--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación

Attachments:

fix_reassing_owned.patchtext/x-patch; charset=US-ASCII; name=fix_reassing_owned.patchDownload
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 43076c9..027bc8b 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"
@@ -1384,6 +1385,13 @@ shdepReassignOwned(List *roleids, Oid newrole)
 					AlterForeignDataWrapperOwner_oid(sdepForm->objid, newrole);
 					break;
 
+				case UserMappingRelationId:
+
+					/* Ignore USER MAPPINGs; they should be handled by DROP
+					 * OWNED, not REASSIGN OWNED.
+					 */
+					break;
+
 				case EventTriggerRelationId:
 					AlterEventTriggerOwner_oid(sdepForm->objid, newrole);
 					break;
#2Jaime Casanova
jaime.casanova@2ndquadrant.com
In reply to: Jaime Casanova (#1)
Re: REASSIGN OWNED doesn't know how to deal with USER MAPPINGs

On 10 December 2015 at 13:04, Jaime Casanova
<jaime.casanova@2ndquadrant.com> wrote:

Hi,

We just notice $SUBJECT. Attached patch fixes it by ignoring USER
MAPPINGs in shdepReassignOwned() just like it happens with default
ACLs.

BTW, shouldn't we at least give a warning on those cases instead of
asuming that the user will know that some objects were ignored?

--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Jaime Casanova (#2)
Re: REASSIGN OWNED doesn't know how to deal with USER MAPPINGs

Jaime Casanova wrote:

On 10 December 2015 at 13:04, Jaime Casanova
<jaime.casanova@2ndquadrant.com> wrote:

Hi,

We just notice $SUBJECT. Attached patch fixes it by ignoring USER
MAPPINGs in shdepReassignOwned() just like it happens with default
ACLs.

Yep, I had already posted this patch elsewhere, and I just pushed it.

BTW, shouldn't we at least give a warning on those cases instead of
asuming that the user will know that some objects were ignored?

I don't think so. This kind of thing is supposed to silent when nothing
is to be done.

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers