Document IS DISTINCT FROM in a more obvious place, and add some more

index entries for IS-foo constructs.
This commit is contained in:
Tom Lane 2004-10-26 22:16:12 +00:00
parent 3b6cc1ad6d
commit 3d2849820b
2 changed files with 86 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.220 2004/10/04 08:15:41 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.221 2004/10/26 22:16:11 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
@ -283,6 +283,18 @@ PostgreSQL documentation
</para> </para>
<para> <para>
<indexterm>
<primary>IS NULL</primary>
</indexterm>
<indexterm>
<primary>IS NOT NULL</primary>
</indexterm>
<indexterm>
<primary>ISNULL</primary>
</indexterm>
<indexterm>
<primary>NOTNULL</primary>
</indexterm>
To check whether a value is or is not null, use the constructs To check whether a value is or is not null, use the constructs
<synopsis> <synopsis>
<replaceable>expression</replaceable> IS NULL <replaceable>expression</replaceable> IS NULL
@ -305,6 +317,7 @@ PostgreSQL documentation
behavior conforms to the SQL standard. behavior conforms to the SQL standard.
</para> </para>
<tip>
<para> <para>
Some applications may expect that Some applications may expect that
<literal><replaceable>expression</replaceable> = NULL</literal> <literal><replaceable>expression</replaceable> = NULL</literal>
@ -318,8 +331,43 @@ PostgreSQL documentation
the default behavior in <productname>PostgreSQL</productname> the default behavior in <productname>PostgreSQL</productname>
releases 6.5 through 7.1. releases 6.5 through 7.1.
</para> </para>
</tip>
<para> <para>
<indexterm>
<primary>IS DISTINCT FROM</primary>
</indexterm>
The ordinary comparison operators yield null (signifying <quote>unknown</>)
when either input is null. Another way to do comparisons is with the
<literal>IS DISTINCT FROM</literal> construct:
<synopsis>
<replaceable>expression</replaceable> IS DISTINCT FROM <replaceable>expression</replaceable>
</synopsis>
For non-null inputs this is the same as the <literal>&lt;&gt;</> operator.
However, when both inputs are null it will return false, and when just
one input is null it will return true. Thus it effectively acts as though
null were a normal data value, rather than <quote>unknown</>.
</para>
<para>
<indexterm>
<primary>IS TRUE</primary>
</indexterm>
<indexterm>
<primary>IS NOT TRUE</primary>
</indexterm>
<indexterm>
<primary>IS FALSE</primary>
</indexterm>
<indexterm>
<primary>IS NOT FALSE</primary>
</indexterm>
<indexterm>
<primary>IS UNKNOWN</primary>
</indexterm>
<indexterm>
<primary>IS NOT UNKNOWN</primary>
</indexterm>
Boolean values can also be tested using the constructs Boolean values can also be tested using the constructs
<synopsis> <synopsis>
<replaceable>expression</replaceable> IS TRUE <replaceable>expression</replaceable> IS TRUE
@ -329,9 +377,13 @@ PostgreSQL documentation
<replaceable>expression</replaceable> IS UNKNOWN <replaceable>expression</replaceable> IS UNKNOWN
<replaceable>expression</replaceable> IS NOT UNKNOWN <replaceable>expression</replaceable> IS NOT UNKNOWN
</synopsis> </synopsis>
These are similar to <literal>IS NULL</literal> in that they will These will always return true or false, never a null value, even when the
always return true or false, never a null value, even when the operand is null. operand is null.
A null input is treated as the logical value <quote>unknown</>. A null input is treated as the logical value <quote>unknown</>.
Notice that <literal>IS UNKNOWN</> and <literal>IS NOT UNKNOWN</> are
effectively the same as <literal>IS NULL</literal> and
<literal>IS NOT NULL</literal>, respectively, except that the input
expression must be of Boolean type.
</para> </para>
</sect1> </sect1>
@ -7344,7 +7396,7 @@ SELECT col1 FROM tab1
</sect2> </sect2>
<sect2> <sect2>
<title><literal>NOT IN </literal></title> <title><literal>NOT IN</literal></title>
<synopsis> <synopsis>
<replaceable>expression</replaceable> NOT IN (<replaceable>subquery</replaceable>) <replaceable>expression</replaceable> NOT IN (<replaceable>subquery</replaceable>)
@ -7538,9 +7590,9 @@ SELECT col1 FROM tab1
<sect2> <sect2>
<title>Row-wise Comparison</title> <title>Row-wise Comparison</title>
<indexterm> <indexterm zone="functions-subquery">
<primary>comparison</primary> <primary>comparison</primary>
<secondary>of rows</secondary> <secondary>subquery result row</secondary>
</indexterm> </indexterm>
<synopsis> <synopsis>
@ -7594,6 +7646,23 @@ SELECT col1 FROM tab1
<primary>SOME</primary> <primary>SOME</primary>
</indexterm> </indexterm>
<indexterm>
<primary>comparison</primary>
<secondary>row-wise</secondary>
</indexterm>
<indexterm>
<primary>IS DISTINCT FROM</primary>
</indexterm>
<indexterm>
<primary>IS NULL</primary>
</indexterm>
<indexterm>
<primary>IS NOT NULL</primary>
</indexterm>
<para> <para>
This section describes several specialized constructs for making This section describes several specialized constructs for making
multiple comparisons between groups of values. These forms are multiple comparisons between groups of values. These forms are

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.95 2004/09/20 22:48:25 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.96 2004/10/26 22:16:12 tgl Exp $
--> -->
<chapter id="sql-syntax"> <chapter id="sql-syntax">
@ -1421,6 +1421,10 @@ SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)
<secondary>constructor</secondary> <secondary>constructor</secondary>
</indexterm> </indexterm>
<indexterm>
<primary>ARRAY</primary>
</indexterm>
<para> <para>
An array constructor is an expression that builds an An array constructor is an expression that builds an
array value from values for its member elements. A simple array array value from values for its member elements. A simple array
@ -1521,13 +1525,17 @@ SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
<secondary>constructor</secondary> <secondary>constructor</secondary>
</indexterm> </indexterm>
<indexterm>
<primary>ROW</primary>
</indexterm>
<para> <para>
A row constructor is an expression that builds a row value (also A row constructor is an expression that builds a row value (also
called a composite value) from values called a composite value) from values
for its member fields. A row constructor consists of the key word for its member fields. A row constructor consists of the key word
<literal>ROW</literal>, a left parenthesis <literal>(</>, zero or more <literal>ROW</literal>, a left parenthesis, zero or more
expressions (separated by commas) for the row field values, and finally expressions (separated by commas) for the row field values, and finally
a right parenthesis <literal>)</>. For example, a right parenthesis. For example,
<programlisting> <programlisting>
SELECT ROW(1,2.5,'this is a test'); SELECT ROW(1,2.5,'this is a test');
</programlisting> </programlisting>