On Sat, Sep 15, 2018 at 11:53:47AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/10/static/functions-subquery.html
> Description:
> 
> Hi.
> 
> The [DOC](https://www.postgresql.org/docs/10/static/functions-subquery.html)
> says:
>  
>     The result is NULL if the comparison does not return false for any
> subquery row
> 
> does *any* mean here: some or all?
> 
> For example in
> [MySQL](https://dev.mysql.com/doc/refman/8.0/en/any-in-some-subqueries.html)
> I have found this explanation:
> 
> >Use of the word SOME is rare, but this example shows why it might be
> useful. To most people, the English phrase “a is not equal to any b” means
> “there is no b which is equal to a,” but that is not what is meant by the
> SQL syntax. The syntax means “there is some b to which a is not equal.”
> Using <> SOME instead helps ensure that everyone understands the true
> meaning of the query.

I am kind of confused by this report.  You mention SOME in the text
above, which is a synonym for ANY, but the text you quote:

>     The result is NULL if the comparison does not return false for any
> subquery row

is from ALL:

        The result of <token>ALL</token> is <quote>true</quote> if
        the comparison returns true for all subquery rows (including
        the case where the subquery returns no rows).  The result is
        <quote>false</quote> if the comparison returns false for any
        subquery row.  The result is NULL if the comparison does not
        return false for any subquery row, and it returns NULL for at
        least one row.

I see the last line is just trying to negate the line above it, but the
mix of "not" and "any" is confusing.  I can reword this last line to be:

        The result is NULL if no comparison with a subquery row returns
        false, and it returns NULL for at least one row.

I can make similar adjustments in other places, and have attached a doc
patch.  Does that help?

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 5193df3..183f081 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15246,7 +15246,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2);
    The result is <quote>false</quote> if the comparison returns false for every
    subquery row (including the case where the subquery returns no
    rows).
-   The result is NULL if the comparison does not return true for any row,
+   The result is NULL if no comparison with a subquery row returns true,
    and it returns NULL for at least one row.
   </para>
 
@@ -15272,7 +15272,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2);
    The result of <token>ALL</token> is <quote>true</quote> if all rows yield true
    (including the case where the subquery returns no rows).
    The result is <quote>false</quote> if any false result is found.
-   The result is NULL if the comparison does not return false for any row,
+   The result is NULL if no comparison with a subquery row returns false,
    and it returns NULL for at least one row.
   </para>
 
@@ -15302,8 +15302,8 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2);
    case where the subquery returns no rows).
    The result is <quote>false</quote> if the comparison returns false for any
    subquery row.
-   The result is NULL if the comparison does not return false for any
-   subquery row, and it returns NULL for at least one row.
+   The result is NULL if no comparison with a subquery row returns false,
+   and it returns NULL for at least one row.
   </para>
 
   <para>

Reply via email to