Re: Re: very big problem with NULL - Mailing list pgsql-general

From Tom Lane
Subject Re: Re: very big problem with NULL
Date
Msg-id 26002.992439741@sss.pgh.pa.us
Whole thread Raw
In response to Re[2]: Re: very big problem with NULL  (Alexey Borzov <borz_off@rdw.ru>)
List pgsql-general
Alexey Borzov <borz_off@rdw.ru> writes:
> TL> NULL does not equal NULL, either.  Read the SQL spec, or any of the
> TL> many prior coverings of this territory in our list archives ...

> Er, how about this stuff?

> newweb=# select null=null;
>  ?column?
> ----------
>  t
> (1 row)

That's in the archives, too: there's a special hack to convert the
literal sequence "= NULL" into the SQL-legal "IS NULL" operator.
Wihout that hack, Microsoft Access' forms code does not work (seems
no one at M$ can read the spec :-().

In fact I was just arguing a few days ago on pghackers that it's time
to remove that hack, because it confuses too many people... I seem to
have lost the argument (again), but it's still a pet peeve.

Here's an example:

regression=# create table foo (f1 int);
CREATE
regression=# insert into foo values (1);
INSERT 412352 1
regression=# insert into foo values (null);
INSERT 412353 1
regression=# select f1 = f1 from foo;
 ?column?
----------
 t

(2 rows)

regression=# create view vfoo as select f1 = null from foo;
CREATE

-- Peeking at the view definition shows how the parser interpreted this:

regression=# \d vfoo
          View "vfoo"
 Attribute |  Type   | Modifier
-----------+---------+----------
 ?column?  | boolean |
View definition: SELECT (foo.f1 ISNULL) FROM foo;

regression=# select * from vfoo;
 ?column?
----------
 f
 t
(2 rows)


            regards, tom lane

pgsql-general by date:

Previous
From: jdassen@cistron.nl (J.H.M. Dassen (Ray))
Date:
Subject: Re: Unix time stamp function?
Next
From: Tom Lane
Date:
Subject: Re: [Help] AGGREGATE problem w/v7.0