On Thu, Aug 7, 2008 at 11:17 AM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Robert Haas escribió:
>> Here's a patch that allows CREATE OR REPLACE VIEW to add new columns
>> to an existing view.
>>
>> Any feedback would be appreciated, especially if it meant that I could
>> fix any problems before the next commitfest.
>
> What happens with the columns previously defined? What happens if I
> specify a different column definition for them; does it raise an error?
Yes. CheckViewTupleDesc() errors out, same as before.
Basically, the old algorithm was:
1. Check [new # of columns] = [old # of columns]
2. For each column: check that [old definition] = [new definition]
The new algorithm is:
1. Check [new # of columns] >= [old # of columns]
2. For each column <= [old # of columns]: check that [old definition]
= [new definition]
3. For each column > [old # of columns]: add the new column to the
relation (as ALTER TABLE ADD COLUMN, except bypassing the usual
prohibition on adding columns to views)
...Robert