Schema search_path and views

From: "Just Someone" <just(dot)some(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Schema search_path and views
Date: 2006-11-06 15:48:24
Message-ID: 36932f270611060748o1842f88ief4026600ddf7a34@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2006-11-06 16:07:27 Re: PostGIS Binary RPM for Red Hat Linux
Previous Message Sandeep Kumar Jakkaraju 2006-11-06 15:47:47 Re: PostGIS Binary RPM for Red Hat Linux