Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5846A6341A3 for ; Sat, 19 Sep 2009 19:18:27 -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 95556-05 for ; Sat, 19 Sep 2009 22:18:19 +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 1BABD6337C4 for ; Sat, 19 Sep 2009 19:18:19 -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 n8JMIGQj006490; Sat, 19 Sep 2009 18:18:16 -0400 (EDT) To: Kris Jurka , Dave Cramer , Andre Rothe , pgsql-jdbc@postgresql.org Subject: Re: Wrong column default values In-reply-to: <19331.1253386359@sss.pgh.pa.us> References: <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com> <5562.1253304906@sss.pgh.pa.us> <19331.1253386359@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 19 Sep 2009 14:52:39 -0400" Date: Sat, 19 Sep 2009 18:18:16 -0400 Message-ID: <6489.1253398696@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/34 X-Sequence-Number: 19981 Tom Lane writes: > Kris Jurka writes: >> On Fri, 18 Sep 2009, Tom Lane wrote: >>> Indeed. In 8.3 it seems that even if you try to set the default that >>> way, the system will throw away the cast: >> That's only true without a typmod. > Hmm, maybe that could use improvement. I looked at this a bit and found that AddRelationNewConstraints will throw away a plain null Const default, but what it's actually seeing in these cases is an invocation of the type's length coercion function on a null Const. We could possibly add more code to throw that away too (probably conditionally on the length coercion function being strict, else it might have processing to do for a null). It doesn't really seem worth it though. I think the OP's problem is most elegantly solved by not writing "default null" in the first place. It's certainly the only solution that he's likely to see payback from in less than a year's time ... regards, tom lane