Re: comparing rows - Mailing list pgsql-hackers

From Tom Lane
Subject Re: comparing rows
Date
Msg-id 7622.965312595@sss.pgh.pa.us
Whole thread Raw
In response to Re: comparing rows  (Don Baccus <dhogaza@pacifier.com>)
Responses Re: comparing rows
List pgsql-hackers
Don Baccus <dhogaza@pacifier.com> writes:
> If foo = NULL is illegal, doesn't this make it rather difficult to
> say things like table1.i = table2.i for tables that contain NULLs
> in column i?

Thomas is not saying that the *operation* is illegal.  His point is
purely a syntactic one: SQL92 allows the keyword "NULL" only in certain
specified contexts, and out on its own as a component of an arithmetic
expression ain't one of them.  You could legally write the same thing in
at least two ways, though:
foo = (CASE WHEN TRUE THEN NULL END)
foo = (CAST NULL AS somedatatype)

It may be that the SQL92 authors intended this restriction to avoid
having to figure out what datatype an unadorned NULL is.  Unfortunately
they blew it in the CASE case :-(, so you still have to have a way of
deciding that.

As far as I can see, allowing NULL as a general-purpose literal is a
perfectly reasonable spec extension that *everybody* does, including us.
Thomas may be the only person anywhere who is bothered by it ;-)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: RE: comparing rows
Next
From: Bruce Momjian
Date:
Subject: Re: comparing rows