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

Query with a negative shift predicate yields an incorrect result #515

Closed
mrigger opened this issue Apr 11, 2020 · 1 comment · Fixed by #519
Closed

Query with a negative shift predicate yields an incorrect result #515

mrigger opened this issue Apr 11, 2020 · 1 comment · Fixed by #519

Comments

@mrigger
Copy link
Contributor

mrigger commented Apr 11, 2020

Consider the following statements:

CREATE TABLE t0(c0 INT);
CREATE TABLE t1(c0 INT8, c1 DOUBLE);
INSERT INTO t1(c0) VALUES (0);
INSERT INTO t1(c1, c0) VALUES (1, 1);
INSERT INTO t0 VALUES (0);
SELECT * FROM t1 JOIN t0 ON t1.c1 WHERE NOT (t1.c0<<-1); -- expected: {1|1|0}, actual: {}

Unexpectedly, this query does not fetch a row. That the predicate should evaluate to TRUE can be seen through the following:

SELECT NOT (t1.c0<<-1) FROM t1; -- {true, true}

When removing the NOT, no row is fetched, which is expected:

SELECT * FROM t1 JOIN t0 ON t1.c1 WHERE (t1.c0<<-1); -- {}

I can reproduce this on the latest master (commit c52fc9b) and the current fix branch (commit 5c4cde5).

Mytherin added a commit that referenced this issue Apr 11, 2020
@Mytherin
Copy link
Collaborator

Fixed in 7e1234d, this had to do with the shift by a negative number triggering undefined behavior. I have modified it so a left or right shift by a negative number results in 0.

@hannes hannes linked a pull request Apr 12, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants