Apparent anomaly with views and unions - Mailing list pgsql-general

From Guy Rouillier
Subject Apparent anomaly with views and unions
Date
Msg-id CC1CF380F4D70844B01D45982E671B2348E5EF@mtxexch01.add0.masergy.com
Whole thread Raw
Responses Re: Apparent anomaly with views and unions  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
I using 8.0.1.  I create 3 tables with these definitions:

create table t1 (serv_id varchar(50) not null);
create table t2 (serv_id varchar(50) not null);
create table t3 (serv_id varchar(50) not null);

Now I create a view like this:

create or replace view v1 as select * from t1;

Next, I attempt to update this view like this:
create or replace view v1 as select * from t1 union select * from t2;

I receive: ERROR:  cannot change data type of view column "serv_id"

Next, I drop view v1 and recreate it using the union above.  I am now
able to do the following without error:

create or replace view v1 as select * from t1 union select * from t2
union select * from t3;

So it looks like changing a view from a non-union to a union is
producing an error, but changing a view that  already contains a 2-way
union to one that contains a 3-way union is allowed (and I'm assuming
any n to n+1 union transition is also allowed.)

Is this intentional?  It was certainly not predictable.

--
Guy Rouillier


pgsql-general by date:

Previous
From: Sven Willenberger
Date:
Subject: Re: databases/p5-postgresql-plperl links to wrong
Next
From: "David Parker"
Date:
Subject: Re: file descriptors