Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAiDG-0006WT-6n for pgsql-docs@arkaria.postgresql.org; Thu, 11 Oct 2018 21:09:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAiDE-0002yk-DR for pgsql-docs@arkaria.postgresql.org; Thu, 11 Oct 2018 21:09:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAiDE-0002yd-7w for pgsql-docs@lists.postgresql.org; Thu, 11 Oct 2018 21:09:40 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gAiDB-00087Q-KH for pgsql-docs@lists.postgresql.org; Thu, 11 Oct 2018 21:09:39 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1gAiD8-000755-WF; Thu, 11 Oct 2018 17:09:34 -0400 Date: Thu, 11 Oct 2018 17:09:34 -0400 From: Bruce Momjian To: kes-kes@yandex.ru, pgsql-docs@lists.postgresql.org Subject: Re: Ambiguous usage of 'any' in explanation Message-ID: <20181011210934.GG7807@momjian.us> References: <153701242703.22334.1476830122267077397@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="JP+T4n/bALQSJXh8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <153701242703.22334.1476830122267077397@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 ALL is true if the comparison returns true for all subquery rows (including the case where the subquery returns no rows). The result is false 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 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 + --JP+T4n/bALQSJXh8 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="any.diff" 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 false 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. @@ -15272,7 +15272,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); The result of ALL is true if all rows yield true (including the case where the subquery returns no rows). The result is false 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. @@ -15302,8 +15302,8 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); case where the subquery returns no rows). The result is false 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. --JP+T4n/bALQSJXh8--