On Sat, Feb 25, 2012 at 15:23,  <rikard.pave...@zg.htnet.hr> wrote:
> 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

> 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?

Peeking at the code, currently any modifications that cause a rewrite
of the original table are disallowed.

Adding a nullable column without a default is allowed since it can be
done without a rewrite -- all rows magically get the value NULL.

I'm not sure whether it's worth complicating code for this. If you
want to store composite types in tables, I think you're better off
using CREATE TYPE/ALTER TYPE.

Regards,
Marti

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to