Re: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tanmay Patel <tan(dot)patel(dot)may(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns
Date: 2011-11-22 04:22:09
Message-ID: 1904.1321935729@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tanmay Patel <tan(dot)patel(dot)may(at)gmail(dot)com> writes:
> 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'm sorry, but you're quite mistaken about the behavior of 8.4. Every
version of Postgres would reject this; no version has ever considered an
explicit specification of NULL to be an invitation to insert the
column's default value instead. (I have heard that mysql acts that way,
though.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2011-11-22 04:54:27 Re: Explicitly inserting NULL values into NOT NULL DEFAULT 0 columns
Previous Message Pavel Stehule 2011-11-22 04:14:03 Re: stored function data structures - difficulty