Re: Wrong column default values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Andre Rothe <phosco(at)gmx(dot)de>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Wrong column default values
Date: 2009-09-18 20:15:06
Message-ID: 5562.1253304906@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Dave Cramer <pg(at)fastcrypt(dot)com> writes:
> On Fri, Sep 18, 2009 at 4:24 AM, Andre Rothe <phosco(at)gmx(dot)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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andre Rothe 2009-09-19 18:00:01 Re: Wrong column default values
Previous Message Dave Cramer 2009-09-18 20:07:52 Re: Wrong column default values