Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: cpacejo(at)clearskydata(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type
Date: 2015-12-11 22:30:25
Message-ID: 20151211223025.GX2763@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Alvaro Herrera wrote:
> cpacejo(at)clearskydata(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2015-12-12 02:13:35 Re: pg_rewind exiting with error code 1 when source and target are on the same timeline
Previous Message michael@sqlexec.com 2015-12-11 21:56:50 Re: BUG #13804: pg_restore returns unexpected error