From: | Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | SELECT * in a CREATE VIEW statement doesn't update column set automatically |
Date: | 2010-05-06 19:01:12 |
Message-ID: | u2ze7e5fefd1005061201w162c0a9bye445e0ca1377a0d9@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
This isn't exactly a bug, but it could be considered unintuitive
behavior. Consider this:
CREATE VIEW foo AS SELECT * FROM a;
CREATE VIEW foo_v AS SELECT * FROM foo;
ALTER TABLE foo ADD COLUMN b INT;
The ALTER TABLE statement affects VIEW foo, but the column addition
does not propagate to VIEW foo_v. Thus, it makes this deceptive:
... AS SELECT * FROM foo;
I ran into this with an application where a real table is accessed if
the user is an "admin", while regular users access a view instead. I
considered "AS SELECT * FROM foo" to be a promise that all columns
from foo would be included in the view, but the promise is broken when
ADD COLUMN is applied later on.
Would it be a desirable feature to make `CREATE VIEW foo_v AS SELECT *
FROM foo;` automatically update the column set when foo's columns
change? Instead of the wildcard * being expanded once at CREATE VIEW
time, it would (semantically) be expanded every time foo_v is selected
on.
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2010-05-06 19:03:21 | Re: max_standby_delay considered harmful |
Previous Message | Robert Haas | 2010-05-06 18:59:07 | Re: max_standby_delay considered harmful |