Re: patch: Add columns via CREATE OR REPLACE VIEW - Mailing list pgsql-hackers

From Robert Haas
Subject Re: patch: Add columns via CREATE OR REPLACE VIEW
Date
Msg-id 603c8f070808070842h2843a0fdkc283c9c5f773de2b@mail.gmail.com
Whole thread Raw
In response to Re: patch: Add columns via CREATE OR REPLACE VIEW  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Avoiding Application Re-test
Next
From: Tom Lane
Date:
Subject: Re: patch: Add columns via CREATE OR REPLACE VIEW