pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Cramer <pg@fastcrypt.com>
Cc: Andre Rothe <phosco@gmx.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Wrong column default values
Date: Fri, 18 Sep 2009 16:15:06 -0400
Message-ID: <5562.1253304906@sss.pgh.pa.us> (raw)
In-Reply-To: <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com>
References: <db420c9c-2345-4c06-add7-10ea404e4008@g6g2000vbr.googlegroups.com>
	<491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com>

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



view thread (9+ messages)  latest in thread

Message-ID: <5562.1253304906@sss.pgh.pa.us>
Permalink:  ../5562.1253304906@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5562.1253304906@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pg@fastcrypt.com, phosco@gmx.de
  Subject: Re: Wrong column default values
  In-Reply-To: <5562.1253304906@sss.pgh.pa.us>
  References: <db420c9c-2345-4c06-add7-10ea404e4008@g6g2000vbr.googlegroups.com> <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com> <5562.1253304906@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox