Re: BUG #6064: != NULL, <> NULL do not work [sec=UNCLASSIFIED]
От | Bruce Momjian |
---|---|
Тема | Re: BUG #6064: != NULL, <> NULL do not work [sec=UNCLASSIFIED] |
Дата | |
Msg-id | 201111300353.pAU3rdp29050@momjian.us обсуждение исходный текст |
Ответ на | Re: BUG #6064: != NULL, <> NULL do not work [sec=UNCLASSIFIED] ("Pilling, Michael" <Michael.Pilling@dsto.defence.gov.au>) |
Ответы |
Re: BUG #6064: != NULL, <> NULL do not work
[sec=UNCLASSIFIED]
|
Список | pgsql-bugs |
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. + 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 <> 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>
В списке pgsql-bugs по дате отправления: