Re: BUG #5028: CASE returns ELSE value always when type is"char" - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5028: CASE returns ELSE value always when type is"char"
Date
Msg-id 15013.1251917395@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5028: CASE returns ELSE value always when type is"char"  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-bugs
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Sam Mason <sam@samason.me.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is"char"
Next
From: "Kevin Grittner"
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is"char"