alter table impact on view

Started by Marc Millasabout 3 years ago3 messagesgeneral
Jump to latest
#1Marc Millas
marc.millas@mokadb.com

Hello,

to my understanding, if I do alter table rename column, Postgres change the
name of the said column, and modify the views using that table so that they
keep working (NOT oracle behaviour..)
fine.
But if I alter table to change a column that is a varchar 20 into a varchar
21
postgres refuse saying that it cannot due to the return rule... using said
column

why ?? as the view is not a materialized object, the impact of the length
of a column of an underlying table do change the description of the view,
clearly, but I dont see where the difficulty is "hidden". Can someone
enlighten me?

thanks,

Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com

#2David Rowley
dgrowleyml@gmail.com
In reply to: Marc Millas (#1)
Re: alter table impact on view

On Tue, 31 Jan 2023 at 01:14, Marc Millas <marc.millas@mokadb.com> wrote:

But if I alter table to change a column that is a varchar 20 into a varchar 21
postgres refuse saying that it cannot due to the return rule... using said column

why ?? as the view is not a materialized object, the impact of the length of a column of an underlying table do change the description of the view, clearly, but I dont see where the difficulty is "hidden". Can someone enlighten me?

Primarily because nobody has written the required code.

In [1]/messages/by-id/603c8f070807291912x37412373q7cd7dc36dd55a8a7@mail.gmail.com, which is now quite old, there was some discussion about
various aspects of making this better. Perhaps changing the typmod is
easier than changing the type completely, but we still don't have any
code for it. So for now, you're just stuck manually dropping and
recreating your views.

David

[1]: /messages/by-id/603c8f070807291912x37412373q7cd7dc36dd55a8a7@mail.gmail.com

#3Marc Millas
marc.millas@mokadb.com
In reply to: David Rowley (#2)
Re: alter table impact on view

A bit sad

Thanks..

Le lun. 30 janv. 2023 à 13:53, David Rowley <dgrowleyml@gmail.com> a écrit :

Show quoted text

On Tue, 31 Jan 2023 at 01:14, Marc Millas <marc.millas@mokadb.com> wrote:

But if I alter table to change a column that is a varchar 20 into a

varchar 21

postgres refuse saying that it cannot due to the return rule... using

said column

why ?? as the view is not a materialized object, the impact of the

length of a column of an underlying table do change the description of the
view, clearly, but I dont see where the difficulty is "hidden". Can someone
enlighten me?

Primarily because nobody has written the required code.

In [1], which is now quite old, there was some discussion about
various aspects of making this better. Perhaps changing the typmod is
easier than changing the type completely, but we still don't have any
code for it. So for now, you're just stuck manually dropping and
recreating your views.

David

[1]
/messages/by-id/603c8f070807291912x37412373q7cd7dc36dd55a8a7@mail.gmail.com