Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns

From: Tanmay Patel <tan(dot)patel(dot)may(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns
Date: 2011-11-22 00:27:41
Message-ID: CAGgjfiTX+m1DKxSti7EQXdCgO-swqEF28kf=g6Jv9RK=KkWTqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If I insert a NULL value explicitly into a column declared to be NOT NULL
DEFAULT 0 in postgreSQL 8.4 the column ends up with the default value. If I
do the same in postgreSQL 9.0 I get an error about how I am inserting a
null value into a NOT NULL column.

i.e.: insert into table1 (column1, column2) values (0, NULL); where column2
is of type integer with attributes NOT NULL DEFAULT 0

In both cases if I just don't mention the column with these attributes the
value stored is the default value.

i.e.: insert into table1(column1) values (0); where column2 is of type
integer with attributes NOT NULL DEFAULT 0

I looked through all the release notes between the versions in question and
can find nothing mentioning this change. When did this change occur, and
can I choose to keep the behavior as it was in postgreSQL 8.4?

Thanks,

Tanmay <pgsql-general(at)postgresql(dot)org>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yan Chunlu 2011-11-22 00:53:21 Re: how could duplicate pkey exist in psql?
Previous Message Mike Blackwell 2011-11-22 00:23:33 Re: stored function data structures - difficulty