public inbox for [email protected]  
help / color / mirror / Atom feed
boolean states
10+ messages / 5 participants
[nested] [flat]

* boolean states
@ 2011-04-27 08:46  Jack Douglas <[email protected]>
  0 siblings, 2 replies; 10+ messages in thread

From: Jack Douglas @ 2011-04-27 08:46 UTC (permalink / raw)
  To: pgsql-docs

Hi

http://www.postgresql.org/docs/current/static/datatype-boolean.html states:

         The boolean type can have one of only two states: "true" or 
"false". A third state, "unknown", is represented by the SQL null value.

This sounds like an oxymoron to me. Perhaps that sentence should be 
changed to:

         The boolean type can have one of three states: "true" or 
"false" and "unknown". The third state, "unknown", is represented by the 
SQL null value.
or:

         The boolean type can have one of three states: "true" or 
"false" and null. The third state, null, represents the logical value 
"unknown".

Best regards
Jack Douglas




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-04-29 01:20  Josh Kupershmidt <[email protected]>
  parent: Jack Douglas <[email protected]>
  1 sibling, 1 reply; 10+ messages in thread

From: Josh Kupershmidt @ 2011-04-29 01:20 UTC (permalink / raw)
  To: Jack Douglas <[email protected]>; +Cc: pgsql-docs

On Wed, Apr 27, 2011 at 4:46 AM, Jack Douglas
<[email protected]> wrote:
>        The boolean type can have one of only two states: "true" or "false".
> A third state, "unknown", is represented by the SQL null value.
>
> This sounds like an oxymoron to me.

I'm not crazy about that paragraph's confusion between two and three
states either, but..

> Perhaps that sentence should be changed
> to:
>
>        The boolean type can have one of three states: "true" or "false" and
> "unknown". The third state, "unknown", is represented by the SQL null value.
> or:
>
>        The boolean type can have one of three states: "true" or "false" and
> null. The third state, null, represents the logical value "unknown".

I don't think either of these suggested replacements are any better.
First, a boolean column can be declared NOT NULL. Second, I don't like
the idea of misleading people into thinking that NULL is on equal
footing with the other values of a given datatype, particularly as
your first alternative implies.

I'd vote for just ripping out the:
|  A third state, "unknown", is represented by the SQL null value.

sentence entirely. I see no reason why NULL should be talked about in
particular on the page about boolean data types; there are many data
types, any of which might be NULL.

I almost think it would be worthwhile to have a section in the docs on
the (counterintuitive) behaviors of NULL, such as this great post:
<http://thoughts.j-davis.com/2009/08/02/what-is-the-deal-with-nulls/;
-- or maybe just a link to that page.

Josh



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-04-29 07:29  Jack Douglas <[email protected]>
  parent: Josh Kupershmidt <[email protected]>
  0 siblings, 1 reply; 10+ messages in thread

From: Jack Douglas @ 2011-04-29 07:29 UTC (permalink / raw)
  To: Josh Kupershmidt <[email protected]>; +Cc: pgsql-docs


> I'd vote for just ripping out the:
> |  A third state, "unknown", is represented by the SQL null value.
>
> sentence entirely. I see no reason why NULL should be talked about in
> particular on the page about boolean data types; there are many data
> types, any of which might be NULL.
NULL is not unique to boolean, but UNKNOWN is - it would surely be wrong 
to have no mention of it at all on this page. This is because the 
boolean type is the only one used to represent truth (or logical) 
values. One of the comments from the link you provided:

> What’s even more interesting is that for BOOLEAN they invented the 
> keyword UNKNOWN and the 2003 standard states “The null value of the 
> boolean data type is equivalent to the Unknown truth value.” So for 
> BOOLEAN (and only BOOLEAN AFAICT) you’re supposed to say WHERE 
> <boolean primary> IS [NOT] UNKNOWN. And in the definition of 
> “literal”, which is supposed to “Specify a non-null value”, “boolean 
> literal” is equated to TRUE, FALSE or UNKNOWN (but the latter is 
> equivalent to a “null value” a few pages later).




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-01 23:07  Josh Kupershmidt <[email protected]>
  parent: Jack Douglas <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Josh Kupershmidt @ 2011-05-01 23:07 UTC (permalink / raw)
  To: Jack Douglas <[email protected]>; +Cc: pgsql-docs

On Fri, Apr 29, 2011 at 3:29 AM, Jack Douglas
<[email protected]> wrote:
> NULL is not unique to boolean, but UNKNOWN is - it would surely be wrong to
> have no mention of it at all on this page. This is because the boolean type
> is the only one used to represent truth (or logical) values. One of the
> comments from the link you provided:
>
>> What’s even more interesting is that for BOOLEAN they invented the keyword
>> UNKNOWN and the 2003 standard states “The null value of the boolean data
>> type is equivalent to the Unknown truth value.” So for BOOLEAN (and only
>> BOOLEAN AFAICT) you’re supposed to say WHERE <boolean primary> IS [NOT]
>> UNKNOWN. And in the definition of “literal”, which is supposed to “Specify a
>> non-null value”, “boolean literal” is equated to TRUE, FALSE or UNKNOWN (but
>> the latter is equivalent to a “null value” a few pages later).

Ah, OK - I had forgotten about that SQL syntax. I do agree that this sentence:
| A third state, "unknown", is represented by the SQL null value.

is particularly confusing, suggesting that "unknown" is a valid
boolean literal, on equal footing with "true" and "false".

We do document the use of IS [NOT] UNKNOWN already, see:
<http://www.postgresql.org/docs/current/interactive/functions-comparison.html;

and IMO that page is the appropriate place for such discussion. So
maybe we just need a link to that page, and should strip out the
confusing sentence about "third state" entirely? Patch attached.

Josh


Attachments:

  [application/octet-stream] boolean_unknown.patch (955B, 2-boolean_unknown.patch)
  download | inline diff:
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index bc1ec3f..b838ee1 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -2784,10 +2784,10 @@ P <optional> <replaceable>years</>-<replaceable>months</>-<replaceable>days</> <
     <productname>PostgreSQL</productname> provides the
     standard <acronym>SQL</acronym> type <type>boolean</type>;
     see <xref linkend="datatype-boolean-table">.
-    The <type>boolean</type> type can have one of only two states:
-    <quote>true</quote> or <quote>false</quote>.  A third state,
-    <quote>unknown</quote>, is represented by the
-    <acronym>SQL</acronym> null value.
+    A non-NULL <type>boolean</type> type can have one of only two states:
+    <quote>true</quote> or <quote>false</quote>. For a list of
+    operators to use with boolean expressions, see 
+    <xref linkend="functions-comparison">.
    </para>
 
    <table id="datatype-boolean-table">


^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-02 22:18  Jaime Casanova <[email protected]>
  parent: Jack Douglas <[email protected]>
  1 sibling, 1 reply; 10+ messages in thread

From: Jaime Casanova @ 2011-05-02 22:18 UTC (permalink / raw)
  To: Jack Douglas <[email protected]>; +Cc: pgsql-docs

On Wed, Apr 27, 2011 at 3:46 AM, Jack Douglas
<[email protected]> wrote:
>
> This sounds like an oxymoron to me. Perhaps that sentence should be changed
> to:
>
>        The boolean type can have one of three states: "true" or "false" and
> "unknown".

if my boolean arithmetic is not wrong the above expression is bad.
better expressed is: "true", "false" or "unknown"...


-- 
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte y capacitación de PostgreSQL



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-04 06:28  Jack Douglas <[email protected]>
  parent: Jaime Casanova <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Jack Douglas @ 2011-05-04 06:28 UTC (permalink / raw)
  To: Jaime Casanova <[email protected]>; +Cc: pgsql-docs


>> This sounds like an oxymoron to me. Perhaps that sentence should be changed
>> to:
>>
>>         The boolean type can have one of three states: "true" or "false" and
>> "unknown".
> if my boolean arithmetic is not wrong the above expression is bad.
> better expressed is: "true", "false" or "unknown"...
There are two kinds of people on this earth, those who understand 
boolean arithmatic and those who don't. I'm not one of them.




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-04 12:26  Kevin Grittner <[email protected]>
  0 siblings, 1 reply; 10+ messages in thread

From: Kevin Grittner @ 2011-05-04 12:26 UTC (permalink / raw)
  To: [email protected]; [email protected]; +Cc: pgsql-docs

Jack Douglas  wrote:
 
> There are two kinds of people on this earth, those who understand
> boolean arithmatic and those who don't. I'm not one of them.
 
Hmmm...  From that, I don't know if you do.  Which do I record in the
understands_boolean column of the database record for you?  Dang, I
knew I should have had *two* flags: known_to_understand_boolean and
known_to_not_understand_boolean.  That would have been much simpler
than allowing NULL for UNKNOWN....
 
-Kevin

"When you come to a fork in the road, take it."  -Yogi Berra




^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-10 01:04  Bruce Momjian <[email protected]>
  parent: Kevin Grittner <[email protected]>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2011-05-10 01:04 UTC (permalink / raw)
  To: Kevin Grittner <[email protected]>; +Cc: [email protected]; [email protected]; pgsql-docs

Kevin Grittner wrote:
> Jack Douglas  wrote:
>  
> > There are two kinds of people on this earth, those who understand
> > boolean arithmatic and those who don't. I'm not one of them.
>  
> Hmmm...  From that, I don't know if you do.  Which do I record in the
> understands_boolean column of the database record for you?  Dang, I
> knew I should have had *two* flags: known_to_understand_boolean and
> known_to_not_understand_boolean.  That would have been much simpler
> than allowing NULL for UNKNOWN....

Attached patch applied to HEAD and 9.0.X.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


Attachments:

  [text/x-diff] /rtmp/diff (788B, 2-%2Frtmp%2Fdiff)
  download | inline diff:
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
new file mode 100644
index 657835c..c1a34fb
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
***************
*** 82,89 ****
       <member><literal>NOT</></member>
      </simplelist>
  
!     <acronym>SQL</acronym> uses a three-valued Boolean logic where the null value represents
!     <quote>unknown</quote>.  Observe the following truth tables:
  
      <informaltable>
       <tgroup cols="4">
--- 82,90 ----
       <member><literal>NOT</></member>
      </simplelist>
  
!     <acronym>SQL</acronym> uses a three-valued logic system with true,
!     false, and <literal>null</>, which represents <quote>unknown</quote>.
!     Observe the following truth tables:
  
      <informaltable>
       <tgroup cols="4">


^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-10 01:45  Josh Kupershmidt <[email protected]>
  parent: Bruce Momjian <[email protected]>
  0 siblings, 1 reply; 10+ messages in thread

From: Josh Kupershmidt @ 2011-05-10 01:45 UTC (permalink / raw)
  To: Bruce Momjian <[email protected]>; +Cc: Kevin Grittner <[email protected]>; [email protected]; [email protected]; pgsql-docs

On Mon, May 9, 2011 at 9:04 PM, Bruce Momjian <[email protected]> wrote:
> Attached patch applied to HEAD and 9.0.X.

The patch you attached looks like it's a fix for the -bugs thread
about "inappropriate reference to boolean logic", not the complaint
raised in this thread.

Josh



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: boolean states
@ 2011-05-10 03:24  Bruce Momjian <[email protected]>
  parent: Josh Kupershmidt <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Bruce Momjian @ 2011-05-10 03:24 UTC (permalink / raw)
  To: Josh Kupershmidt <[email protected]>; +Cc: Kevin Grittner <[email protected]>; [email protected]; [email protected]; pgsql-docs

Josh Kupershmidt wrote:
> On Mon, May 9, 2011 at 9:04 PM, Bruce Momjian <[email protected]> wrote:
> > Attached patch applied to HEAD and 9.0.X.
> 
> The patch you attached looks like it's a fix for the -bugs thread
> about "inappropriate reference to boolean logic", not the complaint
> raised in this thread.

I see what you mean.  I have applied the attached doc patch to HEAD.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


Attachments:

  [text/x-diff] /rtmp/diff (1.1K, 2-%2Frtmp%2Fdiff)
  download | inline diff:
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
new file mode 100644
index bc1ec3f..ab8eb2d
*** a/doc/src/sgml/datatype.sgml
--- b/doc/src/sgml/datatype.sgml
*************** P <optional> <replaceable>years</>-<repl
*** 2784,2792 ****
      <productname>PostgreSQL</productname> provides the
      standard <acronym>SQL</acronym> type <type>boolean</type>;
      see <xref linkend="datatype-boolean-table">.
!     The <type>boolean</type> type can have one of only two states:
!     <quote>true</quote> or <quote>false</quote>.  A third state,
!     <quote>unknown</quote>, is represented by the
      <acronym>SQL</acronym> null value.
     </para>
  
--- 2784,2792 ----
      <productname>PostgreSQL</productname> provides the
      standard <acronym>SQL</acronym> type <type>boolean</type>;
      see <xref linkend="datatype-boolean-table">.
!     The <type>boolean</type> type can have several states:
!     <quote>true</quote>, <quote>false</quote>, and a third state,
!     <quote>unknown</quote>, which is represented by the
      <acronym>SQL</acronym> null value.
     </para>
  


^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2011-05-10 03:24 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 08:46 boolean states Jack Douglas <[email protected]>
2011-04-29 01:20 ` Josh Kupershmidt <[email protected]>
2011-04-29 07:29   ` Jack Douglas <[email protected]>
2011-05-01 23:07     ` Josh Kupershmidt <[email protected]>
2011-05-02 22:18 ` Jaime Casanova <[email protected]>
2011-05-04 06:28   ` Jack Douglas <[email protected]>
2011-05-04 12:26 Re: boolean states Kevin Grittner <[email protected]>
2011-05-10 01:04 ` Bruce Momjian <[email protected]>
2011-05-10 01:45   ` Josh Kupershmidt <[email protected]>
2011-05-10 03:24     ` Bruce Momjian <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox