Обсуждение: Comparison Predicates - example - documentation seems contradictory?

Поиск
Список
Период
Сортировка

Comparison Predicates - example - documentation seems contradictory?

От
PG Doc comments form
Дата:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/functions.html
Description:

https://www.postgresql.org/docs/14/functions-comparison.html

See the heading: "Table 9.2. Comparison Predicates"

"2 BETWEEN 3 AND 1 → f" # ok this is false.

But let's read the example immediately below (the 'not between' example)

2 NOT BETWEEN 1 AND 3 → f   # what? This is also false. how can the negation
also be the same value? I would expect it to be true?

That doesn't seem right?

Re: Comparison Predicates - example - documentation seems contradictory?

От
Alvaro Herrera
Дата:
On 2022-Oct-06, PG Doc comments form wrote:

> See the heading: "Table 9.2. Comparison Predicates"
> 
> "2 BETWEEN 3 AND 1 → f" # ok this is false.
> 
> But let's read the example immediately below (the 'not between' example)
> 
> 2 NOT BETWEEN 1 AND 3 → f   # what? This is also false. how can the negation
> also be the same value? I would expect it to be true?

Actually, 2 *is* between 1 and 3.  So if you ask if it's NOT between,
that's false.

The other one is false because the boundaries are reversed, and BETWEEN
does not put them in the proper order before comparing.  BETWEEN
SYMMETRIC does that, as explained in the line below.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/



Re: Comparison Predicates - example - documentation seems contradictory?

От
Ben Koshy
Дата:
you're 100% right. Got it now. The documentation is correct and does not need to be changed. chrs.

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Sent: Friday, 7 October 2022 7:49 PM
To: benkoshy@hotmail.com <benkoshy@hotmail.com>; pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>
Subject: Re: Comparison Predicates - example - documentation seems contradictory?
 
On 2022-Oct-06, PG Doc comments form wrote:

> See the heading: "Table 9.2. Comparison Predicates"
>
> "2 BETWEEN 3 AND 1 → f" # ok this is false.
>
> But let's read the example immediately below (the 'not between' example)
>
> 2 NOT BETWEEN 1 AND 3 → f   # what? This is also false. how can the negation
> also be the same value? I would expect it to be true?

Actually, 2 *is* between 1 and 3.  So if you ask if it's NOT between,
that's false.

The other one is false because the boundaries are reversed, and BETWEEN
does not put them in the proper order before comparing.  BETWEEN
SYMMETRIC does that, as explained in the line below.

--
Álvaro Herrera               48°01'N 7°57'E  —  https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.enterprisedb.com%2F&amp;data=05%7C01%7C%7Ced05496dced34d16154408daa84d6526%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638007347613366454%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=f5aDRnJa9jZX%2BmfPUAxgsBXSJASWt52JWjWb5WS0DCY%3D&amp;reserved=0