summaryrefslogtreecommitdiff
path: root/doc/src/sgml/func/func-logical.sgml
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2025-08-04 08:56:48 -0400
committerAndrew Dunstan <andrew@dunslane.net>2025-08-04 09:04:56 -0400
commit4e23c9ef65accde7eb3e56aa28d50ae5cf79b64b (patch)
treee56f52b0d1b8409794a5ac0cc54ee7a322c58c6a /doc/src/sgml/func/func-logical.sgml
parent6ae268cf284c5a706455e164f8879bd721296535 (diff)
Split func.sgml into more manageable pieces
func.sgml has grown over the years to the point where it is very difficult to manage. This commit splits out each sect1 piece into its own file, which is then included in the main file, so that the built documentation should be identical to the pre-split documentation. All these new files are placed in a new "func" subdirectory, and the previous func.sgml is removed. Done using scripts developed by: Author: jian he <jian.universality@gmail.com> Discussion: https://postgr.es/m/CACJufxFgAh1--EMwOjMuANe=VTmjkNaZjH+AzSe04-8ZCGiESA@mail.gmail.com
Diffstat (limited to 'doc/src/sgml/func/func-logical.sgml')
-rw-r--r--doc/src/sgml/func/func-logical.sgml146
1 files changed, 146 insertions, 0 deletions
diff --git a/doc/src/sgml/func/func-logical.sgml b/doc/src/sgml/func/func-logical.sgml
new file mode 100644
index 00000000000..65e50e65a81
--- /dev/null
+++ b/doc/src/sgml/func/func-logical.sgml
@@ -0,0 +1,146 @@
+ <sect1 id="functions-logical">
+ <title>Logical Operators</title>
+
+ <indexterm zone="functions-logical">
+ <primary>operator</primary>
+ <secondary>logical</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>Boolean</primary>
+ <secondary>operators</secondary>
+ <see>operators, logical</see>
+ </indexterm>
+
+ <para>
+ The usual logical operators are available:
+
+ <indexterm>
+ <primary>AND (operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>OR (operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>NOT (operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>conjunction</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>disjunction</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>negation</primary>
+ </indexterm>
+
+<synopsis>
+<type>boolean</type> <literal>AND</literal> <type>boolean</type> <returnvalue>boolean</returnvalue>
+<type>boolean</type> <literal>OR</literal> <type>boolean</type> <returnvalue>boolean</returnvalue>
+<literal>NOT</literal> <type>boolean</type> <returnvalue>boolean</returnvalue>
+</synopsis>
+
+ <acronym>SQL</acronym> uses a three-valued logic system with true,
+ false, and <literal>null</literal>, which represents <quote>unknown</quote>.
+ Observe the following truth tables:
+
+ <informaltable>
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry><replaceable>a</replaceable></entry>
+ <entry><replaceable>b</replaceable></entry>
+ <entry><replaceable>a</replaceable> AND <replaceable>b</replaceable></entry>
+ <entry><replaceable>a</replaceable> OR <replaceable>b</replaceable></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>TRUE</entry>
+ <entry>TRUE</entry>
+ <entry>TRUE</entry>
+ <entry>TRUE</entry>
+ </row>
+
+ <row>
+ <entry>TRUE</entry>
+ <entry>FALSE</entry>
+ <entry>FALSE</entry>
+ <entry>TRUE</entry>
+ </row>
+
+ <row>
+ <entry>TRUE</entry>
+ <entry>NULL</entry>
+ <entry>NULL</entry>
+ <entry>TRUE</entry>
+ </row>
+
+ <row>
+ <entry>FALSE</entry>
+ <entry>FALSE</entry>
+ <entry>FALSE</entry>
+ <entry>FALSE</entry>
+ </row>
+
+ <row>
+ <entry>FALSE</entry>
+ <entry>NULL</entry>
+ <entry>FALSE</entry>
+ <entry>NULL</entry>
+ </row>
+
+ <row>
+ <entry>NULL</entry>
+ <entry>NULL</entry>
+ <entry>NULL</entry>
+ <entry>NULL</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry><replaceable>a</replaceable></entry>
+ <entry>NOT <replaceable>a</replaceable></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>TRUE</entry>
+ <entry>FALSE</entry>
+ </row>
+
+ <row>
+ <entry>FALSE</entry>
+ <entry>TRUE</entry>
+ </row>
+
+ <row>
+ <entry>NULL</entry>
+ <entry>NULL</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ The operators <literal>AND</literal> and <literal>OR</literal> are
+ commutative, that is, you can switch the left and right operands
+ without affecting the result. (However, it is not guaranteed that
+ the left operand is evaluated before the right operand. See <xref
+ linkend="syntax-express-eval"/> for more information about the
+ order of evaluation of subexpressions.)
+ </para>
+ </sect1>