Re: dealing with extension dependencies that aren't quite 'e'

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dealing with extension dependencies that aren't quite 'e'
Date: 2016-03-21 10:04:33
Message-ID: CAPpHfdv8HFtkEHZOh-Z0i0o5L-dMmvHzhpybH68OaUyUSN9yQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 21, 2016 at 9:34 AM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>
wrote:

> At 2016-03-19 17:46:25 -0300, alvherre(at)2ndquadrant(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2016-03-21 10:08:32 Re: multivariate statistics v14
Previous Message Grzegorz Sampolski 2016-03-21 09:59:20 Re: pam auth - add rhost item