Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] I think this is a BUG?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] I think this is a BUG?
Date: 2008-04-24 16:57:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-hackers
I wrote:
> I think the bug here is that ADD COLUMN NOT NULL has to fail if
> there's not a default expression supplied (except maybe we could
> allow it if the table contains no rows).  ISTM we got this right
> in the past, wonder why it's not working now ...

Hm, we do get it right if PRIMARY KEY isn't in the picture:

regression=# create table t1 (f1 int);
regression=# insert into t1 values(1);
regression=# alter table t1 add column f2 int not null;
ERROR:  column "f2" contains null values

The above is correct, but if I now try

regression=# alter table t1 add column f2 int primary key;
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
regression=# \d t1
      Table "public.t1"
 Column |  Type   | Modifiers 
 f1     | integer | 
 f2     | integer | not null
    "t1_pkey" PRIMARY KEY, btree (f2)

So somehow the constraint-validation code isn't getting applied in
this case.  I suspect you'll find it's a pretty localized fix.

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: Bruce MomjianDate: 2008-04-24 17:32:55
Subject: Re: 8.3 / 8.2.6 restore comparison
Previous:From: Brendan JurdDate: 2008-04-24 16:47:39
Subject: Re: [GENERAL] I think this is a BUG?

pgsql-general by date

Next:From: Harald Armin MassaDate: 2008-04-24 16:59:32
Subject: Re: Which Python library - psycopg2 or pygresql?
Previous:From: Emiliano MoscatoDate: 2008-04-24 16:56:27
Subject: Re: Stored procedures in C

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group