Thread: Unexpected ALTER TABLE behavior

Unexpected ALTER TABLE behavior

From
Ed Loehr
Date:
This looks like a silent partial failure case in 7.1.2.  Maybe someone
can confirm or explain?  I would expect the following to succeed
completely or generate an error message with no side-effects.  Instead,
it appears to add the column but without the "not null" constraint.

    create table mytable (id integer);
    alter table mytable add column name varchar not null;

Here's what I saw:

% psql -V
psql (PostgreSQL) 7.1.2
...
% createdb testdb
CREATE DATABASE
% psql -d testdb -c "create table mytable (id integer);"
CREATE
% psql -d testdb -c "alter table mytable add column name varchar not
null;"
ALTER
% psql -d testdb -c "\d mytable"
             Table "mytable"
 Attribute |       Type        | Modifier
-----------+-------------------+----------
 id        | integer           |
 name      | character varying |


Regards,
Ed Loehr