Обсуждение: set search_path command

Поиск
Список
Период
Сортировка

set search_path command

От
Radovan Jablonovsky
Дата:
Hello,

When we compared behaviour of "set search_path" between 9.1.9 and 9.3.4, there is difference. On 9.1.9 the command "set search_path to schema1,public" checks if the schema exists and if not it return error. Example:
set search_path to "schema123",public;
ERROR:  invalid value for parameter "search_path": "schema123, public"
DETAIL:  schema "schema123" does not exist

On 9.3.4 the same command silently ignore the schema does not exists. Example:
set search_path to "schema123",public;
SET
 select * from pg_namespace where nspname ilike '%schema123%';
 nspname | nspowner | nspacl
---------+----------+--------
(0 rows)

Is this new behaviour intentional? 

Sincerely,
--

Radovan Jablonovsky | SaaS DBA | Phone 1-403-262-6519 (ext. 256) | Fax 1-403-233-8046


Replicon | Hassle-Free Time & Expense Management Software - 7,300 Customers - 70 Countries
www.replicon.com | facebook | twitter | blog | contact us

We are hiring! | search jobs

Re: set search_path command

От
Vibhor Kumar
Дата:

On Monday, June 2, 2014 at 5:50 PM, Radovan Jablonovsky wrote:

> When we compared behaviour of "set search_path" between 9.1.9 and 9.3.4, there is difference. On 9.1.9 the command
"setsearch_path to schema1,public" checks if the schema exists and if not it return error. Example: 
> set search_path to "schema123",public;
> ERROR: invalid value for parameter "search_path": "schema123, public"
> DETAIL: schema "schema123" does not exist
>
>
> On 9.3.4 the same command silently ignore the schema does not exists. Example:
> set search_path to "schema123",public;
> SET
>
> select * from pg_namespace where nspname ilike '%schema123%';
> nspname | nspowner | nspacl
> ---------+----------+--------
> (0 rows)

I think so. It was fixed in 9.2.

E.14.3.1.7. Server Settings

Silently ignore nonexistent schemas specified in search_path (Tom Lane) :
This makes it more convenient to use generic path settings, which might include some schemas that don't exist in all
databases.


Thanks & Regards,
Vibhor Kumar
Blogs:http://vibhork.blogspot.com
http://vibhorkumar.wordpress.com





Re: set search_path command

От
David G Johnston
Дата:
Radovan Jablonovsky wrote
> Hello,
>
> When we compared behaviour of "set search_path" between 9.1.9 and 9.3.4,
> there is difference. On 9.1.9 the command "set search_path to
> schema1,public" checks if the schema exists and if not it return error.
> Example:
> set search_path to "schema123",public;
> ERROR:  invalid value for parameter "search_path": "schema123, public"
> DETAIL:  schema "schema123" does not exist
>
> On 9.3.4 the same command silently ignore the schema does not exists.
> Example:
> set search_path to "schema123",public;
> SET
>  select * from pg_namespace where nspname ilike '%schema123%';
>  nspname | nspowner | nspacl
> ---------+----------+--------
> (0 rows)
>
> Is this new behaviour intentional?

Yes. It was felt the 9.1 behavior was too punishing.  I do not recall the
specifics at the moment but I believe 9.0- and 9.2+ simply ignore the
missing schema while 9.1 has the obnoxious behavior that you see.  Though if
any version other than 9.1 and 9.3 matter you should confirm this for
yourself.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/set-search-path-command-tp5805807p5805809.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.


Re: set search_path command

От
Tom Lane
Дата:
David G Johnston <david.g.johnston@gmail.com> writes:
> Radovan Jablonovsky wrote
>> Is this new behaviour intentional?

> Yes. It was felt the 9.1 behavior was too punishing.  I do not recall the
> specifics at the moment but I believe 9.0- and 9.2+ simply ignore the
> missing schema while 9.1 has the obnoxious behavior that you see.  Though if
> any version other than 9.1 and 9.3 matter you should confirm this for
> yourself.

A quick check says that an interactive "SET search_path = nosuchschema"
command fails in previous versions as well as 9.1.  However, I believe that
noninteractive settings (eg, from postgresql.conf or ALTER DATABASE SET)
have always accepted paths including nonexistent schemas.  This was felt
to be inconsistent; and also, IIRC, in 9.1 or 9.2 we had made some code
refactorings that made it difficult to sustain such inconsistent behavior.
So we decided to go for the laxer behavior in all cases rather than the
stricter behavior in all cases.

Another rationale for this change was the analogy between search_path
and Unix PATH settings.  AFAIK, no Unix-oid platform anywhere will
complain if your PATH mentions a nonexistent directory.

            regards, tom lane