Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D1938B5DBCC for ; Sun, 3 Jul 2011 13:33:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 34573-05 for ; Sun, 3 Jul 2011 16:31:17 +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 15A8CB5DBC6 for ; Sun, 3 Jul 2011 13:31:16 -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 p63GVFoL029290; Sun, 3 Jul 2011 12:31:15 -0400 (EDT) To: Chris Bandy cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6080: information_schema.columns.column_default contains NULL inconsistently In-reply-to: References: <201106282042.p5SKgVjo044969@wwwmaster.postgresql.org> <107.1309577721@sss.pgh.pa.us> Comments: In-reply-to Chris Bandy message dated "Sat, 02 Jul 2011 00:50:40 -0500" Date: Sun, 03 Jul 2011 12:31:15 -0400 Message-ID: <29289.1309710675@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/18 X-Sequence-Number: 30630 Chris Bandy writes: > On Fri, Jul 1, 2011 at 10:35 PM, Tom Lane wrote: >> But AFAICS there is room for implementation dependency in other cases. >> In the particular cases you show here, PG recognizes some of them as >> being equivalent to not having a default value, so for efficiency's sake >> it converts them to that form. > That makes sense, too. Perhaps I am naive, but a null is a null, > right? Is the different presentation of defaults for "d" and "e" > indicative of an *in*efficiency in PG? Yeah, it's intentional though. What the printout is not telling you is that there's a hidden cast function invocation to enforce the length limit in the cases where the column has an explicit length limit. That is, under the hood the expression is really more like "varchar(NULL, 1)". The code that recognizes a default expression as being just constant NULL doesn't think this is a constant NULL. In principle it could recognize that, since the cast function is marked strict, but so far it has not seemed worth the trouble. regards, tom lane