pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Pilling, Michael <Michael.Pilling@dsto.defence.gov.au>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6064: != NULL, <> NULL do not work [sec=UNCLASSIFIED]
Date: Tue, 29 Nov 2011 22:53:39 -0500 (EST)
Message-ID: <201111300353.pAU3rdp29050@momjian.us> (raw)
In-Reply-To: <DB2FF420856DB942829BF029A7E3C196029E3CB7@ednex514.dsto.defence.gov.au>

Pilling, Michael wrote:
> Hi Kevin,
> 
> Thanks for that. Point entirely taken. I think what I would add would
> be in the table 9-1 of operators, an extra column filled in only for
> =, <> and != saying Important: see difference from IS [NOT] NULL.
> Perhaps one reason I didn't pick up on this subtle issue is that IS
> NULL and IS NOT NULL are not listed in this table but they are
> comparison operators, just textual rather than symbolic ones in the
> grammar so they should be in the table. I recall specifically looking
> up what is the not equal operator in this language and only going
> forward from the table, not realising I had to read any further.
> 
> I'd also add after "Do not write expression = NULL because NULL is not
> "equal to" NULL." Do not write expression != NULL or <> NULL because
> NULL is not "not equal to" NULL.  because while implied, it's not
> obvious that because = doesn't work with NULL that != doesn't either.

I have written the attached patch to mention <> NULL also returns NULL.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

Attachments:

/rtmp/null (text/x-diff, 1.1K) download diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index be92e6a..ddfb29a *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** *** 364,371 **** </indexterm> Ordinary comparison operators yield null (signifying <quote>unknown</>), not true or false, when either input is null. For example, ! <literal>7 = NULL</> yields null. When this behavior is not suitable, ! use the <literal>IS <optional> NOT </> DISTINCT FROM</literal> constructs: <synopsis> <replaceable>expression</replaceable> IS DISTINCT FROM <replaceable>expression</replaceable> --- 364,371 ---- </indexterm> Ordinary comparison operators yield null (signifying <quote>unknown</>), not true or false, when either input is null. For example, ! <literal>7 = NULL</> yields null, as does <literal>7 &lt;&gt; NULL</>. When ! this behavior is not suitable, use the <literal>IS <optional> NOT </> DISTINCT FROM</literal> constructs: <synopsis> <replaceable>expression</replaceable> IS DISTINCT FROM <replaceable>expression</replaceable>

view thread (10+ messages)  latest in thread

Message-ID: <201111300353.pAU3rdp29050@momjian.us>
Permalink:  ../201111300353.pAU3rdp29050@momjian.us/
Also on:    postgresql.org/message-id/201111300353.pAU3rdp29050@momjian.us

 ·  · 

reply

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: bruce@momjian.us, Michael.Pilling@dsto.defence.gov.au, Kevin.Grittner@wicourts.gov
  Subject: Re: BUG #6064: != NULL, <> NULL do not work [sec=UNCLASSIFIED]
  In-Reply-To: <201111300353.pAU3rdp29050@momjian.us>
  References: <DB2FF420856DB942829BF029A7E3C196029E3CB7@ednex514.dsto.defence.gov.au> <201111300353.pAU3rdp29050@momjian.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