From: Nathan Bossart <nathandbossart@gmail.com>
To: Vik Fearing <vik@postgresfriends.org>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>
Cc: pgsql-hackers@lists.postgresql.org, Jacob Champion <jacob.champion@enterprisedb.com>
Cc: Isaac Morland <isaac.morland@gmail.com>
Subject: Re: Logical Implication
Date: Fri, 6 Nov 2026 14:05:23 -0600
Message-ID: <au4zAwo3wQ-KfOh-@nathan> (raw)
In-Reply-To: <asU7s4y_QzU7yJVZ@nathan>
References: <37c76707-e6fa-4ee3-b57f-aa0bf1b0bba8@postgresfriends.org>
<aqQL78v7jr0AED_b@nathan>
<b0edbd8b-66e5-44c0-9b90-516760df1209@postgresfriends.org>
<arU0qXcp3KSj7M-g@nathan>
<9ab35dbb-d9a4-4c1e-bae2-7763ddeb720c@postgresfriends.org>
<CAN4CZFPUmkNyYP=MJbCE3OC21-De9AYhJXOD_wd8Q06E6xBzqQ@mail.gmail.com>
<3d779ee0-6596-4dae-b79c-e35b237f83bf@postgresfriends.org>
<ar0mGmQQz6vI6pts@nathan>
<b70aba34-e799-4c09-aa3e-281a335ebf2f@postgresfriends.org>
<asU7s4y_QzU7yJVZ@nathan>
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
Attachments:v4-0001-doc-Rearrange-the-logical-operator-truth-tables.patch (text/plain, 4.0K) download
From 29ddf7086ac5639646010f66137af7068a981bdc Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
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 <vik@postgresfriends.org>
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.sgmlindex 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 instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, vik@postgresfriends.org, zsolt.parragi@percona.com, jacob.champion@enterprisedb.com, isaac.morland@gmail.com
Subject: Re: Logical Implication
In-Reply-To: <au4zAwo3wQ-KfOh-@nathan>
References: <37c76707-e6fa-4ee3-b57f-aa0bf1b0bba8@postgresfriends.org> <aqQL78v7jr0AED_b@nathan> <b0edbd8b-66e5-44c0-9b90-516760df1209@postgresfriends.org> <arU0qXcp3KSj7M-g@nathan> <9ab35dbb-d9a4-4c1e-bae2-7763ddeb720c@postgresfriends.org> <CAN4CZFPUmkNyYP=MJbCE3OC21-De9AYhJXOD_wd8Q06E6xBzqQ@mail.gmail.com> <3d779ee0-6596-4dae-b79c-e35b237f83bf@postgresfriends.org> <ar0mGmQQz6vI6pts@nathan> <b70aba34-e799-4c09-aa3e-281a335ebf2f@postgresfriends.org> <asU7s4y_QzU7yJVZ@nathan> <au4zAwo3wQ-KfOh-@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox