Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 828F7633EDA for ; Sat, 26 Sep 2009 11:46:39 -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 57691-10 for ; Sat, 26 Sep 2009 14:46:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail.postgresql.org (Postfix) with ESMTP id 01C7C6336AB for ; Sat, 26 Sep 2009 11:46:31 -0300 (ADT) Received: by leary.csoft.net (Postfix, from userid 1112) id 68511A1DE; Sat, 26 Sep 2009 10:46:30 -0400 (EDT) Date: Sat, 26 Sep 2009 10:46:30 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Andre Rothe cc: pgsql-jdbc@postgresql.org Subject: Re: Wrong column default values In-Reply-To: <2426021f-e049-40e1-910b-ff92c345135b@p23g2000vbl.googlegroups.com> Message-ID: References: <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com> <2426021f-e049-40e1-910b-ff92c345135b@p23g2000vbl.googlegroups.com> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed 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/51 X-Sequence-Number: 19998 On Sat, 19 Sep 2009, Andre Rothe wrote: > I have exlicitly set the default value for every column, but if I ask > the driver for the current value, it doesn't give me a simple NULL, but > the described expression. For the moment I have translated the result > with a > > private String dropAnnotations(String defValue) { > String res = defValue; > if ((res != null) && (res.contains("::"))) { > res = res.substring(0, res.lastIndexOf("::")); > } > return res; > } > > But this is an ugly way to get a clean default value from the driver. > This isn't a really safe thing to do if you consider all the possible default values, so I'm not sure there's much that the JDBC driver can do to clean this up. I think it just has to report what the server tells it. Consider: CREATE TEMP TABLE deftest ( a text default 'a::b', b timestamptz default now() + 3 * '5 minutes'::interval ); jurka=# \d deftest Table "pg_temp_1.deftest" Column | Type | Modifiers --------+--------------------------+------------------------------------------------------------------ a | text | default 'a::b'::text b | timestamp with time zone | default (now() + ((3)::double precision * '00:05:00'::interval)) Kris Jurka