From: | Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>, Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>, Joshua Tolley <eggyknap(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_execute_from_file review |
Date: | 2010-12-07 10:59:44 |
Message-ID: | m28w01u9un.fsf@2ndQuadrant.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> There's a difference between whether an extension as such is considered
> to belong to a schema and whether its contained objects do. We can't
> really avoid the fact that functions, operators, etc must be assigned to
> some particular schema. It seems not particularly important that
> extension names be schema-qualified, though --- the use-case for having
> two different extensions named "foo" installed simultaneously seems
> pretty darn small. On the other hand, if we were enforcing that all
> objects contained in an extension belong to the same schema, it'd make
> logistical sense to consider that the extension itself belongs to that
> schema as well. But last I heard we didn't want to enforce such a
> restriction.
Very good summary, thank you, that's exactly the ideas I've been working
with. Which ain't surprising, after all we've been talking about this
for 18 months already :)
So in the current patch, extensions are not schema qualified.
> I believe what the search_path substitution is actually about is to
> provide a convenient shorthand for the case that all the contained
> objects do indeed live in one schema, and you'd like to be able to
> select that schema at CREATE EXTENSION time. Which seems like a useful
> feature for a common case. We've certainly heard multiple complaints
> about the fact that you can't do that easily now.
Exactly. It's just a useful little thing, but given that it depends on
how the script is written, maybe the right interface would be a 2-steps
process, so that either it does what you want or you get an error.
Current patch:
CREATE EXTENSION foo WITH SCHEMA bar;
If foo's script isn't using @extschema@ or if it is using more than
one schema, executing the script will not do anything like what you
want to --- currently that's extension's author problem.
Other idea:
CREATE EXTENSION foo;
ALTER EXTENSION foo SET SCHEMA utils;
CREATE EXTENSION bar;
ALTER EXTENSION bar SET SCHEMA utils;
ERROR: the extension "bar" has installed objects in more than one schema
DETAIL: extension depends on schema "public" and "baz"
HINT: use pg_extension_objects() to list bar's objects
> BTW, I did think of a case where substitution solves a problem we don't
> presently have any other solution for: referring to the target schema
> within the definition of a contained object. As an example, you might
> wish to attach "SET search_path = @target_schema@" to the definition of
> a SQL function in an extension, to prevent search-path-related security
> issues in the use of the function. Without substitution you'll be
> reduced to hard-wiring the name of the target schema.
Right.
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr
From | Date | Subject | |
---|---|---|---|
Next Message | Dimitri Fontaine | 2010-12-07 11:07:14 | Re: FK's to refer to rows in inheritance child |
Previous Message | KaiGai Kohei | 2010-12-07 09:14:08 | Re: Label switcher function |