On Mon, Mar 21, 2016 at 9:34 AM, Abhijit Menon-Sen <a...@2ndquadrant.com>
wrote:

> At 2016-03-19 17:46:25 -0300, alvhe...@2ndquadrant.com wrote:
> >
> > I don't think the first patch is acceptable standalone -- we need both
> > things together.
>
> OK.
>
> > But in reality, pg_depend handling is mixed up with other changes all
> > over the place.
>
> Yes, I noticed that. :-/
>
> > Anyway I think this should be something along the lines of
> >     ALTER FUNCTION foo() DEPENDS ON EXTENSION bar;
>
> OK. That's reasonable.
>
> >     ALTER FUNCTION foo() OWNED BY EXTENSION bar;
>
> If the function is really OWNED BY EXTENSION, then the right way to
> declare it would seem to be ALTER EXTENSION … ADD FUNCTION. I prefer
> DEPENDS ON EXTENSION for this reason, there's no ambiguity about what
> we're declaring.
>

I'm not sure why we want to make new dependency type by ALTER FUNCTION
command, not ALTER EXTENSION?
Since, we already add 'e' dependencies by ALTER EXTENSION command, why it
should be different for 'x' dependencies.
The argument could be that 'x' dependency type would be used for other
objects not extensions.  But this is much more general problem and it's
unclear, that we would end up with this behaviour and this dependency type.

So, I would prefer this patch to extend ALTER EXTENSION command while it's
aimed to this particular problem.

I even think we could extend existent grammar rule

            | ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
> *************** AlterExtensionContentsStmt:
> *** 3982,3987 ****
> --- 3987,3993 ----
>                     n->objtype = OBJECT_FUNCTION;
>                     n->objname = $6->funcname;
>                     n->objargs = $6->funcargs;
> +                   n->deptype = 'e';
>                     $$ = (Node *)n;
>                 }


instead of adding another

+           | ALTER EXTENSION name add_drop DEPENDENT FUNCTION
> function_with_argtypes
> +               {
> +                   AlterExtensionContentsStmt *n =
> makeNode(AlterExtensionContentsStmt);
> +                   n->extname = $3;
> +                   n->action = $4;
> +                   n->objtype = OBJECT_FUNCTION;
> +                   n->objname = $7->funcname;
> +                   n->objargs = $7->funcargs;
> +                   n->deptype = 'x';
>                     $$ = (Node *)n;
>                 }


by introducing separate rule extension_dependency_type.

In the same way we could dependency type parameter to each ALTER EXTENSION
grammar rule.  Therefore, existent functionality would be extended in
natural way with not large changes in the code.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Reply via email to