Re: BUG #13918: Simple query with Having clause returns incorrect results

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #13918: Simple query with Having clause returns incorrect results
Дата
Msg-id 19844.1454991472@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #13918: Simple query with Having clause returns incorrect results  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, February 4, 2016, <tarasbob@gmail.com> wrote:
>> The following query incorrectly returns 1 row instead of 0:
>>
>> SELECT 1
>> FROM some_table
>> WHERE FALSE
>> HAVING TRUE

> So, amazingly (to me), this behavior is documented.

>> The presence of HAVING turns a query into a grouped query even if there is
>> no GROUP BY clause. ... Such a
>> query will emit a single row if the HAVING condition is true, zero rows if
>> it is not true.

Yeah.  This is a pretty weird corner case, but the behavior is required
by SQL spec.

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #13928: Initdb.bat will not install if path has a space.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #13919: Cast error when table is empty.