On Tue, Oct 06, 2026 at 01:19:31PM -0500, Nathan Bossart wrote:
> On Sat, Oct 03, 2026 at 06:18:43PM +0200, Vik Fearing wrote:
>>      <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:
>> +    false, and unknown; the null value of a <type>boolean</type> and the 
>> truth
>> +    value unknown are one and the same.  In the truth tables below the left
>> +    operand of a binary operator selects the row, and the right operand the
>> +    column:
> 
> I find the reorganization to be an improvement, and I intend to commit this
> one sooner than later.  The only thing I'd change is the switch from NULL
> to "unknown" in the tables.  Users deal with NULL at the command level, and
> the rest of the docs use NULL, so I think the existing text has the right
> idea by noting once that NULL represents "unknown" and then using NULL
> throughout.

Concretely, like the attached.

-- 
nathan
>From 29ddf7086ac5639646010f66137af7068a981bdc Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 6 Nov 2026 13:58:36 -0600
Subject: [PATCH v4 1/1] doc: Rearrange the logical operator truth tables.

Present AND, OR, and NOT as matrix tables indexed by operand,
instead of one combined row-per-case table, and mark the first
column as row headers so that it is styled like the header row.

Author: Vik Fearing <[email protected]>
Discussion: 
https://postgr.es/m/37c76707-e6fa-4ee3-b57f-aa0bf1b0bba8%40postgresfriends.org
---
 doc/src/sgml/func/func-logical.sgml | 70 ++++++++++++++++-------------
 1 file changed, 40 insertions(+), 30 deletions(-)

diff --git a/doc/src/sgml/func/func-logical.sgml 
b/doc/src/sgml/func/func-logical.sgml
index 65e50e65a81..28d49b61a89 100644
--- a/doc/src/sgml/func/func-logical.sgml
+++ b/doc/src/sgml/func/func-logical.sgml
@@ -47,16 +47,17 @@
 
     <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:
+    In the truth tables below, the left operand of a binary operator selects
+    the row, and the right operand the column:
 
-    <informaltable>
+    <informaltable rowheader="firstcol">
      <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>
+        <entry>AND</entry>
+        <entry>TRUE</entry>
+        <entry>FALSE</entry>
+        <entry>NULL</entry>
        </row>
       </thead>
 
@@ -64,41 +65,56 @@
        <row>
         <entry>TRUE</entry>
         <entry>TRUE</entry>
-        <entry>TRUE</entry>
-        <entry>TRUE</entry>
+        <entry>FALSE</entry>
+        <entry>NULL</entry>
        </row>
 
        <row>
-        <entry>TRUE</entry>
         <entry>FALSE</entry>
         <entry>FALSE</entry>
-        <entry>TRUE</entry>
+        <entry>FALSE</entry>
+        <entry>FALSE</entry>
        </row>
 
        <row>
-        <entry>TRUE</entry>
         <entry>NULL</entry>
         <entry>NULL</entry>
-        <entry>TRUE</entry>
+        <entry>FALSE</entry>
+        <entry>NULL</entry>
        </row>
+      </tbody>
+     </tgroup>
+    </informaltable>
 
+    <informaltable rowheader="firstcol">
+     <tgroup cols="4">
+      <thead>
        <row>
+        <entry>OR</entry>
+        <entry>TRUE</entry>
         <entry>FALSE</entry>
-        <entry>FALSE</entry>
-        <entry>FALSE</entry>
-        <entry>FALSE</entry>
+        <entry>NULL</entry>
+       </row>
+      </thead>
+
+      <tbody>
+       <row>
+        <entry>TRUE</entry>
+        <entry>TRUE</entry>
+        <entry>TRUE</entry>
+        <entry>TRUE</entry>
        </row>
 
        <row>
         <entry>FALSE</entry>
-        <entry>NULL</entry>
+        <entry>TRUE</entry>
         <entry>FALSE</entry>
         <entry>NULL</entry>
        </row>
 
        <row>
         <entry>NULL</entry>
-        <entry>NULL</entry>
+        <entry>TRUE</entry>
         <entry>NULL</entry>
         <entry>NULL</entry>
        </row>
@@ -106,28 +122,22 @@
      </tgroup>
     </informaltable>
 
-    <informaltable>
-     <tgroup cols="2">
+    <informaltable rowheader="firstcol">
+     <tgroup cols="4">
       <thead>
        <row>
-        <entry><replaceable>a</replaceable></entry>
-        <entry>NOT <replaceable>a</replaceable></entry>
-       </row>
-      </thead>
-
-      <tbody>
-       <row>
+        <entry>NOT</entry>
         <entry>TRUE</entry>
         <entry>FALSE</entry>
+        <entry>NULL</entry>
        </row>
+      </thead>
 
+      <tbody>
        <row>
+        <entry></entry>
         <entry>FALSE</entry>
         <entry>TRUE</entry>
-       </row>
-
-       <row>
-        <entry>NULL</entry>
         <entry>NULL</entry>
        </row>
       </tbody>
-- 
2.55.0

Reply via email to