Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6C92712BCD42 for ; Tue, 29 Nov 2011 23:53:57 -0400 (AST) Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RVbF5-0006GI-7N for pgsql-bugs@postgresql.org; Wed, 30 Nov 2011 03:53:57 +0000 Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id pAU3rdp29050; Tue, 29 Nov 2011 22:53:39 -0500 (EST) From: Bruce Momjian Message-Id: <201111300353.pAU3rdp29050@momjian.us> Subject: Re: BUG #6064: != NULL, <> NULL do not work [sec=UNCLASSIFIED] In-Reply-To: To: "Pilling, Michael" Date: Tue, 29 Nov 2011 22:53:39 -0500 (EST) CC: Kevin Grittner , pgsql-bugs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1322625219-23280-1_" Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201111/209 X-Sequence-Number: 31804 --ELM1322625219-23280-1_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" 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 http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --ELM1322625219-23280-1_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/rtmp/null" 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 **** Ordinary comparison operators yield null (signifying unknown), not true or false, when either input is null. For example, ! 7 = NULL yields null. When this behavior is not suitable, ! use the IS NOT DISTINCT FROM constructs: expression IS DISTINCT FROM expression --- 364,371 ---- Ordinary comparison operators yield null (signifying unknown), not true or false, when either input is null. For example, ! 7 = NULL yields null, as does 7 <> NULL. When ! this behavior is not suitable, use the IS NOT DISTINCT FROM constructs: expression IS DISTINCT FROM expression --ELM1322625219-23280-1_--