Re: Wrong column default values - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: Wrong column default values
Date
Msg-id 5562.1253304906@sss.pgh.pa.us
Whole thread Raw
In response to Re: Wrong column default values  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: Wrong column default values  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
Dave Cramer <pg@fastcrypt.com> writes:
> On Fri, Sep 18, 2009 at 4:24 AM, Andre Rothe <phosco@gmx.de> wrote:
>> I have installed Postgres 8.3.8 on Fedora Linux and I access it per
>> JDBC (PostgreSQL 8.1 JDBC3 with SSL (build 407)). If I create a table,
>> the default values will be set by the database to
>> NULL::timestamp without time zone
>> for a timezone column and to
>> NULL::character varying
>> for a varchar column. How I can prevent such a behaviour? Both column

> How do you create this table ?

Indeed.  In 8.3 it seems that even if you try to set the default that
way, the system will throw away the cast:

regression=# create table t1 (f1 varchar default null::varchar);
CREATE TABLE
regression=# \d t1
           Table "public.t1"
 Column |       Type        | Modifiers
--------+-------------------+-----------
 f1     | character varying |

regression=# create table t2 (f1 varchar);
CREATE TABLE
regression=# alter table t2 alter column f1 set default null::varchar;
ALTER TABLE
regression=# \d t2
           Table "public.t2"
 Column |       Type        | Modifiers
--------+-------------------+-----------
 f1     | character varying |

I'm thinking that this has less to do with what the server thinks
and more to do with whatever tool the OP is using to examine the
table ...

            regards, tom lane

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Wrong column default values
Next
From: Andre Rothe
Date:
Subject: Re: Wrong column default values