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

Re: BUG #4324: Default value for a column is not returned in select when column has not been explicitly set

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jeff Galyan" <jeff(at)richrelevance(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4324: Default value for a column is not returned in select when column has not been explicitly set
Date: 2008-07-26 17:30:43
Message-ID: 24201.1217093443@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Jeff Galyan" <jeff(at)richrelevance(dot)com> writes:
> Take an existing table with some data in it and add a nullable column of
> type boolean with default value true.  In 8.2, 'select bool_column from
> my_table' would have returned 'true' for all rows where the column had not
> been explicitly set (which should be all of them at this point).

Works for me:

regression=# create table foo (f1 int);
CREATE TABLE
regression=# insert into foo values(1),(2);
INSERT 0 2
regression=# alter table foo add column b bool default true;
ALTER TABLE
regression=# select * from foo;
 f1 | b 
----+---
  1 | t
  2 | t
(2 rows)

Please provide a concrete test case to demonstrate what you are seeing.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Sam WongDate: 2008-07-27 08:41:36
Subject: BUG #4327: Primary key not refresh after cascaded deleted
Previous:From: Craig RingerDate: 2008-07-26 15:22:49
Subject: Re: Error while loading shared libraries

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