pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rikard.pavelic@zg.htnet.hr
To: pgsql-bugs@postgresql.org
Subject: BUG #6489: Alter table with composite type/table
Date: Sat, 25 Feb 2012 13:23:18 +0000
Message-ID: <E1S1Han-0001M2-WB@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      6489
Logged by:          Rikard Pavelic
Email address:      rikard.pavelic@zg.htnet.hr
PostgreSQL version: 9.1.2
Operating system:   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:  cannot alter table "t1" because column "t2.j" uses 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 when
adding into composite type for another table.

Is this by design, oversight or a TODO?

Regards,
Rikard




view thread (16+ messages)  latest in thread

Message-ID: <E1S1Han-0001M2-WB@wrigleys.postgresql.org>
Permalink:  ../E1S1Han-0001M2-WB@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1S1Han-0001M2-WB@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: rikard.pavelic@zg.htnet.hr
  Subject: Re: BUG #6489: Alter table with composite type/table
  In-Reply-To: <E1S1Han-0001M2-WB@wrigleys.postgresql.org>
  References: <E1S1Han-0001M2-WB@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox