alter column type (from timestamp to date) violates not null - Mailing list pgsql-bugs

From psmith
Subject alter column type (from timestamp to date) violates not null
Date
Msg-id 1173444959.644833.20220@c51g2000cwc.googlegroups.com
Whole thread Raw
Responses Re: alter column type (from timestamp to date) violates not null
List pgsql-bugs
Hi!

When change a column type from timestamp to date, the 'infinity' and '-
infinity' values will be NULL. Even if the column has a not null
constraint.
Sorry, if it is a duplicated bug report.

Regards,
psmith

Here is the test procedure:

proba2=3D# create table a(t timestamp not null);
CREATE TABLE
proba2=3D# insert into a values ('infinity');
INSERT 0 1
proba2=3D# SELECT * from a;
    t
----------
 infinity
(1 sor)

proba2=3D# alter table a alter t type date;
ALTER TABLE
proba2=3D# SELECT *, t is null as is_null from a;
 t | is_null
---+---------
   | t
(1 sor)

proba2=3D# \d a
     T=E1bla "public.a"
 Oszlop | T=EDpus | M=F3dos=EDt=F3
--------+-------+----------
 t      | date  | not null

proba2=3D# select version();
                                                   version
---------------------------------------------------------------------------=
-----------------------------------
 PostgreSQL 8.1.0 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.0.3
20051023 (prerelease) (Debian 4.0.2-3)
(1 sor)

proba2=3D# select 'infinity'::timestamp::date is null;
 ?column?
----------
 t
(1 sor)

pgsql-bugs by date:

Previous
From: "Abbas Ansaripoor"
Date:
Subject: BUG #3127: Error IN initdb On Installation
Next
From: "dall"
Date:
Subject: BUG #3131: on win pg_connect() is very slow