Schema search_path and views - Mailing list pgsql-general

From Just Someone
Subject Schema search_path and views
Date
Msg-id 36932f270611060748o1842f88ief4026600ddf7a34@mail.gmail.com
Whole thread Raw
Responses Re: Schema search_path and views  ("William Leite Araújo" <william.bh@gmail.com>)
Re: Schema search_path and views  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-general
I have a database with multiple schemas all with the same structure
(but of course different data...).

I want to create a view that will be created in a shared schema, and
when executed will be executed against the current schema. Whenever I
try it, it seems the view is linked to a specific schema used when
creating it, and doesn't reevaluates based on the current schema.

Here is the pseudo structure/code:

schema1:
=======
create table t1 ...

schema2:
=======
create table t1 ...

shared_schema:
============
create table t3 ...

create the view:
===========
set search_path to shared_schema, schema1;
create view view1 as select * from t1;

try the view:
========
set search_path to shared_schema, schema1;
select * from view1;
set search_path to shared_schema, schema2;
select * from view1;

Results:
======
In the above, both select * from view1; will return the same data,
though the search path changed.

Is there a way to make the view use the current search_path?



--
Family management on rails: http://www.famundo.com - coming soon!
My development related blog: http://devblog.famundo.com

pgsql-general by date:

Previous
From: "Sandeep Kumar Jakkaraju"
Date:
Subject: Re: PostGIS Binary RPM for Red Hat Linux
Next
From: "Joshua D. Drake"
Date:
Subject: Re: PostGIS Binary RPM for Red Hat Linux