Re: Logical Implication

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

Re: Logical Implication

От:
Thom Brown <thom@linux.com>
Дата:
On Fri, 11 Sept 2026 at 14:36, Vik Fearing  wrote:
>
> Hi.
>
>
> I would like to intruduce an IMPLIES operator for booleans that reads
> better than its developed formula.  That is, I think
>
>      a IMPLIES b
>
> is better in CHECK constraints and elsewhere than
>
>      NOT a OR b
>
> .
>
>
> I plan on submitting this to the SQL committee as well, but I've learned
> that they like an implementation to have it first, and I cannot imagine
> that they would quibble over the keyword used.
>
>
> The first patch is a restructure of the documentation for NOT/AND/OR
> because IMPLIES is not symmetric about the diagonal and I didn't want it
> to stand out like a sore thumb. The second patch is the actual
> implementation.
>
>
> It does not survive a round trip which has precedence with IN being
> changed to =ANY, BETWEEN changing to <= and >= (BETWEEN SYMMETRIC is
> even worse), etc; so I don't think that is a problem.

What behaviour should be expected for the following cases:

a IMPLIES b IMPLIES c

CHECK (a IMPLIES b) -- where b is NULL
-- And what does that deparse to?

a IMPLIES (100 / b > 10)


Thom


Re: Logical Implication

От:
solai v <solai.cdac@gmail.com>
Дата:
Hi all

I tested the  IMPLIES boolean operator patch.
First, I reproduced the issue on the unpatched PostgreSQL, where using
the IMPLIES operator resulted in a syntax error. I then applied the
two patches, rebuilt PostgreSQL, and repeated the same tests.
After applying the patch, I verified the IMPLIES operator with all
TRUE/FALSE combinations and confirmed that its results match the
equivalent NOT a OR b expressions. I also tested its use in a CHECK
constraint, including both valid and invalid cases. In addition, I
tested NULL handling, right associativity, and rejection of
non-boolean operands.
All the tested cases behaved as expected. Finally, I ran the
PostgreSQL regression test suite, and all tests passed.
Overall, the patch is working as expected based on the tests performed.

Regards
solai


Re: Logical Implication

От:
Vik Fearing <vik@postgresfriends.org>
Дата:

On 17/09/2026 06:53, solai v wrote:
> Overall, the patch is working as expected based on the tests performed.


Thanks for testing!

-- 

Vik Fearing



FAQ