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

A select with BETWEEN and VARCHAR cast results in an incorrect result #584

Closed
mrigger opened this issue Apr 25, 2020 · 1 comment
Closed

Comments

@mrigger
Copy link
Contributor

mrigger commented Apr 25, 2020

Consider the following statements:

CREATE TABLE t0(c0 INTEGER);
INSERT INTO t0(c0) VALUES (-2);
SELECT t0.c0 FROM t0 WHERE -1 BETWEEN t0.c0::VARCHAR AND 1; -- expected: {-2}, actual: {}

Unexpectedly, the SELECT does not fetch the row. I found this based on commit 1d2e40e.

@Mytherin
Copy link
Collaborator

Fixes this in e8ec151. This was related to the cast moving optimizer. After optimization the expression was converted from an integer comparison into a varchar comparison, which resulted in the incorrect result being returned because "-1" < "-2", but -1 > -2.

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

No branches or pull requests

2 participants