Re: Dynamic views

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Bernd Helmle" <mailings(at)oopsware(dot)de>
Cc: vivek(at)staff(dot)ownmail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Dynamic views
Date: 2006-11-29 16:49:24
Message-ID: b42b73150611290849q3df98c6cib48d1fc7b874656e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/29/06, Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
> > no, queries using * are expanded when the plan is created. for views,
> > the plan is created when you create the view (also the original query
> > string to create the view is not stored). however, you could however
> > create a function that returns setof record, because plans for
> > functions are created when they are first run in a session. this
> > isn't a perfect solution, but it might work for you.
>
> But that requires to adjust all SELECTs which uses this table function, since
>
> SETOF RECORD requires you to specify a column list. Maybe you can build
>
> something like that using a table's implicit type.

correct:

create table foo (a text, b int, c int);
insert into foo values ('1', 2, 3);
create function f() returns setof foo as $$ select * from foo; $$ language sql;
select f();
f
---------
(1,2,3)
(1 row)

alter table foo add column d int default 4;

select * from f();
a | b | c | d
---+---+---+---
1 | 2 | 3 | 4

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Poe 2006-11-29 16:56:14 Postgresql data integrity during RAID10 drive rebuild
Previous Message Richard Troy 2006-11-29 16:42:29 Re: Development of cross-platform GUI for Open Source DBs