From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Chris Bandy <bandy.chris@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6080: information_schema.columns.column_default contains NULL inconsistently
Date: Tue, 05 Jul 2011 12:42:13 -0400
Message-ID: <20113.1309884133@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoYHX9TC8Hjb2sP+Sv1ODcurrTRwmUi58bdWSuOL2OZRCw@mail.gmail.com>
References: <201106282042.p5SKgVjo044969@wwwmaster.postgresql.org>
<107.1309577721@sss.pgh.pa.us>
<CAMDg7WyLbvTGxV4c625KZOphwnjJDDzkrKutVvwzBoC+JAr0yw@mail.gmail.com>
<29289.1309710675@sss.pgh.pa.us>
<CA+TgmoYHX9TC8Hjb2sP+Sv1ODcurrTRwmUi58bdWSuOL2OZRCw@mail.gmail.com>
Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Jul 3, 2011 at 12:31 PM, Tom Lane <tgl@sss.pgh.pa.us> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, bandy.chris@gmail.com
Subject: Re: BUG #6080: information_schema.columns.column_default contains NULL inconsistently
In-Reply-To: <20113.1309884133@sss.pgh.pa.us>
References: <201106282042.p5SKgVjo044969@wwwmaster.postgresql.org> <107.1309577721@sss.pgh.pa.us> <CAMDg7WyLbvTGxV4c625KZOphwnjJDDzkrKutVvwzBoC+JAr0yw@mail.gmail.com> <29289.1309710675@sss.pgh.pa.us> <CA+TgmoYHX9TC8Hjb2sP+Sv1ODcurrTRwmUi58bdWSuOL2OZRCw@mail.gmail.com> <20113.1309884133@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox