Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B8558634389 for ; Fri, 18 Sep 2009 17:15:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 20981-07 for ; Fri, 18 Sep 2009 20:15:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id F3D2A632BE2 for ; Fri, 18 Sep 2009 17:15:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n8IKF67t005563; Fri, 18 Sep 2009 16:15:06 -0400 (EDT) To: Dave Cramer cc: Andre Rothe , pgsql-jdbc@postgresql.org Subject: Re: Wrong column default values In-reply-to: <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com> References: <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com> Comments: In-reply-to Dave Cramer message dated "Fri, 18 Sep 2009 16:07:52 -0400" Date: Fri, 18 Sep 2009 16:15:06 -0400 Message-ID: <5562.1253304906@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/29 X-Sequence-Number: 19976 Dave Cramer writes: > On Fri, Sep 18, 2009 at 4:24 AM, Andre Rothe 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