Re: BUG #6489: Alter table with composite type/table

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: BUG #6489: Alter table with composite type/table
Дата
Msg-id CAHyXU0z=xkwWaOv7eHiY_21PbyCnuHCjRTtBW+aqyzFD40Xckw@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #6489: Alter table with composite type/table  (rikard.pavelic@zg.htnet.hr)
Ответы Re: BUG #6489: Alter table with composite type/table  (Rikard Pavelic <rikard.pavelic@zg.htnet.hr>)
Список pgsql-bugs
On Sat, Feb 25, 2012 at 7:23 AM,  <rikard.pavelic@zg.htnet.hr> wrote:
> The following bug has been logged on the website:
>
> Bug reference: =A0 =A0 =A06489
> Logged by: =A0 =A0 =A0 =A0 =A0Rikard Pavelic
> Email address: =A0 =A0 =A0rikard.pavelic@zg.htnet.hr
> PostgreSQL version: 9.1.2
> Operating system: =A0 Windows 7
> Description:
>
> I'm trying to push types in Postgres and have run into some
> limitations/inconsistent behaviors.
>
> Currently I'm declaring types and using them in other types and tables as
> composites.
> But types don't support inheritance so I'm thinking about declaring tables
> and using it's types instead of just declaring types.
>
> I've run into problems with adding new columns:
>
> create table t1(i int, j int);
> create table t2(i int, j t1);
> insert into t2 values(1,(2,3));
>
> This works:
> alter table t1 add x float not null;
> This doesn't work:
> alter table t1 add x float not null default 0;
> It fails with ERROR: =A0cannot alter table "t1" because column "t2.j" use=
s its
> row type
>
> While first alter table will not do as someone would expect (t2.x will be
> null) I'm fine with this behavior as it is consistent with types not
> allowing not null on attributes.
>
> But I would expect second alter to pass and enforcing not null and default
> when adding this column in table and not enforcing not null and default w=
hen
> adding into composite type for another table.
>
> Is this by design, oversight or a TODO?

I personally think it's an oversight.  This was just discussed a
couple of days ago here:
http://postgresql.1045698.n5.nabble.com/Altering-a-table-with-a-rowtype-col=
umn-td5544844.html

The server is blocking the alter-not-null-with-default because it's
assuming that the default should be applied to dependent (foreign)
tables implementing the type as a field.  I think this assumption is
totally bogus because composite types defaults get applied to the
type, not to member fields and therefore a default has no meaning in
that context.   I think the TODO should read to relax the check
essentially.

merlin

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: BUG #6489: Alter table with composite type/table
Следующее
От: kontakt@sandberg-consult.dk
Дата:
Сообщение: BUG #6530: intarray documentation could do with a warning about operators