Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 20B28B5DBDC for ; Tue, 5 Jul 2011 13:42:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 66748-05 for ; Tue, 5 Jul 2011 16:42: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 6CD28B5DBF0 for ; Tue, 5 Jul 2011 13:42: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 p65GgD16020114; Tue, 5 Jul 2011 12:42:14 -0400 (EDT) To: Robert Haas cc: Chris Bandy , 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> <29289.1309710675@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Tue, 05 Jul 2011 12:31:54 -0400" Date: Tue, 05 Jul 2011 12:42:13 -0400 Message-ID: <20113.1309884133@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/38 X-Sequence-Number: 30650 Robert Haas writes: > On Sun, Jul 3, 2011 at 12:31 PM, Tom Lane wrote: >> 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. > Gee, does Noah's recent patch adding the notion of "transform > functions" have any applicability to this problem? Not really. If someone held a gun to my head and said "fix that", what I'd do is run eval_const_expressions() on the default expression and see if that resulted in a constant NULL. But it seems unlikely to be worth the cycles in most cases. Also, we'd then need some other test to address the issue explained in AddRelationNewConstraints: /* * If the expression is just a NULL constant, we do not bother to make * an explicit pg_attrdef entry, since the default behavior is * equivalent. * * Note a nonobvious property of this test: if the column is of a * domain type, what we'll get is not a bare null Const but a * CoerceToDomain expr, so we will not discard the default. This is * critical because the column default needs to be retained to * override any default that the domain might have. */ if (expr == NULL || (IsA(expr, Const) &&((Const *) expr)->constisnull)) continue; IOW, there are cases where "DEFAULT NULL" is *not* a no-op. regards, tom lane