Multiple Schema and extensions

Started by Alan Nilssonover 13 years ago2 messagesgeneral
Jump to latest
#1Alan Nilsson
anilsson@apple.com

Is it the case that extensions can be added to only one schema? If so, what is the recommended practice for accessing a function from an extension in multiple schemas?

Is it *ok* to load the extension in the pg_catalog schema so functions can be accessed by unqualified names? Is it *better* to have a separate schema for functions and use qualified names to access? What is the general accepted practice?

As a side note:
ALTER EXTENSION foo ADD SCHEMA bar
What the heck does this do? AFICS, it has no effect on the visibility of an extension function in the *added* schema.

thanks
alan

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Alan Nilsson (#1)
Re: Multiple Schema and extensions

Alan Nilsson wrote:

Is it the case that extensions can be added to only one schema? If

so, what is the recommended

practice for accessing a function from an extension in multiple

schemas?

Yes, a (relocatable) extension can belong to only one schema.
There are two ways to access the functions:
1) Use qualified names.
2) Set search_path to contain the schema.

Is it *ok* to load the extension in the pg_catalog schema so functions

can be accessed by unqualified

names? Is it *better* to have a separate schema for functions and use

qualified names to access?

What is the general accepted practice?

No, that is not ok.
pg_catalog is only for system objects.
You should use schema "public" - that is in search_path by
default, and everybody can use it.

As a side note:
ALTER EXTENSION foo ADD SCHEMA bar
What the heck does this do? AFICS, it has no effect on the visibility

of an extension function in the

*added* schema.

This makes "bar" belong to extension "foo", not the other way around.
The effect is that
a) "bar" will not be dumped by pg_dump
b) "DROP EXTENSION foo" will drop schema "bar"

Yours,
Laurenz Albe