Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joWB5-0003qk-RQ for pgsql-bugs@arkaria.postgresql.org; Thu, 25 Jun 2020 18:00:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1joWB4-0007yj-Me for pgsql-bugs@arkaria.postgresql.org; Thu, 25 Jun 2020 18:00:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joWB4-0007yc-GB for pgsql-bugs@lists.postgresql.org; Thu, 25 Jun 2020 18:00:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joWAy-0005Uq-8T for pgsql-bugs@lists.postgresql.org; Thu, 25 Jun 2020 18:00:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 05PI0bs82286503; Thu, 25 Jun 2020 14:00:37 -0400 From: Tom Lane To: anton.lugovoy.hopni@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16511: Using '= all ( )' with empty table returns true In-reply-to: <16511-ca1a7368d7453b7b@postgresql.org> References: <16511-ca1a7368d7453b7b@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 25 Jun 2020 17:40:04 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2286501.1593108037.1@sss.pgh.pa.us> Date: Thu, 25 Jun 2020 14:00:37 -0400 Message-ID: <2286502.1593108037@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > Given table is "task" (id uuid primary key, status text not null), > Query "select 'b' = all (select status from task where status = 'a')" > returns true if table "task" is empty Why do you think that's wrong? It matches usual mathematical practice, and even if you dispute that, the SQL standard is quite explicit about it: 1) Let R be the result of the and let T be the result of the . ... a) If T is empty or if the implied is true for every row RT in T, then "R T" is true. regards, tom lane