Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHERE-clause with two ORs doesn't evaluate to true #54779

Closed
slanderous-mambo opened this issue Sep 19, 2023 · 5 comments · Fixed by #55418 or #55678
Closed

WHERE-clause with two ORs doesn't evaluate to true #54779

slanderous-mambo opened this issue Sep 19, 2023 · 5 comments · Fixed by #55418 or #55678
Labels
bug Confirmed user-visible misbehaviour in official release major st-fixed v23.8-affected

Comments

@slanderous-mambo
Copy link

What's wrong

Hello. We encountered a regression in some of our queries after upgrading Clickhouse from 23.7 to 23.8. Now, inside a WHERE-clause a three-literal or-clause doesn't get evaluated right if two of the clauses are always false and one is sometimes true.

Does it reproduce on recent release?

Every release starting with 23.8

How to reproduce

CREATE TABLE or_bug (column_1 UInt8) ENGINE=MergeTree ORDER BY column_1;

INSERT INTO TABLE or_bug VALUES (0), (1);

SELECT * FROM or_bug WHERE (column_1 = 1) OR false OR false;

Ok.

0 rows in set. Elapsed: 0.001 sec.

Same behavior with fiddle (using versions >= 23.8): https://fiddle.clickhouse.com/424f3fbf-58db-4b3a-b1c8-f4a287a9bf05

Expected behavior

Clickhouse should (and did with 23.7) instead return

┌─column_1─┐
│        1 │
└───────────

Additional context

Note that this doesn't happen with ENGINE=Memory and only happens with two times "OR false", not one or three times "OR false".

@slanderous-mambo slanderous-mambo added the potential bug To be reviewed by developers and confirmed/rejected. label Sep 19, 2023
@ucasfl ucasfl added bug Confirmed user-visible misbehaviour in official release and removed potential bug To be reviewed by developers and confirmed/rejected. labels Sep 19, 2023
@tavplubix
Copy link
Member

It's fixed in master, we need to find the fix and backport

@SaltTan
Copy link
Contributor

SaltTan commented Sep 23, 2023

@slanderous-mambo
Copy link
Author

I came around to bisecting this and the first bad commit seems to be 68aed0d.

Could someone with better understanding than me take a look?

@den-crane
Copy link
Contributor

cc @azat

@azat
Copy link
Collaborator

azat commented Oct 9, 2023

I came around to bisecting this and the first bad commit seems to be 68aed0d.

Hi @slanderous-mambo, thanks for bisect!

Could someone with better understanding than me take a look?

Here is a fix - #55418

P.S. @den-crane thanks for tagging me

P.P.S. BTW you can surely tag commit author by yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release major st-fixed v23.8-affected
Projects
None yet
6 participants