Re: BUG #16511: Using '= all ( )' with empty table returns true

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: anton(dot)lugovoy(dot)hopni(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16511: Using '= all ( )' with empty table returns true
Date: 2020-06-25 18:00:37
Message-ID: 2286502.1593108037@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 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 <row value constructor> and let T be
the result of the <table subquery>.
...
a) If T is empty or if the implied <comparison predicate> is
true for every row RT in T, then "R <comp op> <all> T" is
true.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-06-26 10:44:03 BUG #16512: Character considered as a number by regex but can not convert to numeric
Previous Message PG Bug reporting form 2020-06-25 17:40:04 BUG #16511: Using '= all ( )' with empty table returns true