Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5661AB5DBC1 for ; Sat, 2 Jul 2011 00:35:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 96010-09 for ; Sat, 2 Jul 2011 03:35:23 +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 C79EDB5DBC6 for ; Sat, 2 Jul 2011 00:35:22 -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 p623ZLAk000108; Fri, 1 Jul 2011 23:35:21 -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: <201106282042.p5SKgVjo044969@wwwmaster.postgresql.org> References: <201106282042.p5SKgVjo044969@wwwmaster.postgresql.org> Comments: In-reply-to "Chris Bandy" message dated "Tue, 28 Jun 2011 20:42:31 +0000" Date: Fri, 01 Jul 2011 23:35:21 -0400 Message-ID: <107.1309577721@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/5 X-Sequence-Number: 30617 "Chris Bandy" writes: > While using the information_schema to examine my tables, I found that > "columns"."column_default" does not consistently represent the DEFAULT > constraint/definition of a column. > I would expect a column without a DEFAULT definition to return a null value, > while a column with a DEFAULT definition would return the defined expression > as a character value. > In the following log, columns "a", "b" and "c" appear identical though their > definitions differ. I don't see anything to fix here. The standard says that for a column without any explicit default value, COLUMN_DEFAULT should be null. 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. I don't think we're bound to make every such case work like that, though. regards, tom lane