Re: BUG #5028: CASE returns ELSE value always when type is"char"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-bugs(at)postgresql(dot)org, "Sam Mason" <sam(at)samason(dot)me(dot)uk>
Subject: Re: BUG #5028: CASE returns ELSE value always when type is"char"
Date: 2009-09-02 18:49:55
Message-ID: 15013.1251917395@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:
>> If we did follow Kevin's request directly, should we also be
>> specifying the type of NULL?

> I don't *think* the SQL standard requires that, and barring that I
> don't see any compelling reason to type NULL.

Actually, AFAICS the SQL spec *does* require you to cast NULL literals
explicitly in nearly all contexts. There are exceptions for assigning
NULL directly to a field (in INSERT or UPDATE), and maybe some other
places, but not many.

The PG type system treats a bare NULL literal as "unknown", so most
of the same issues come up for either NULL or literal constants.
If you were to try to get rid of the "unknown" concept, I think the
only place you'd find yourself violating the standard is the aforesaid
narrow exceptions. Usability is a different question though ...

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2009-09-02 18:55:28 Re: BUG #5028: CASE returns ELSE value always when type is"char"
Previous Message Tom Lane 2009-09-02 18:41:09 Re: BUG #5028: CASE returns ELSE value always when type is"char"