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

Incorrect output for LEFT JOINS with integer-valued filter. #6412

Closed
nicktobey opened this issue Jul 28, 2023 · 0 comments · Fixed by dolthub/go-mysql-server#1926
Closed
Labels
analyzer bug Something isn't working good first issue Good for newcomers good repro Easily reproducible bugs sql Issue with SQL

Comments

@nicktobey
Copy link
Contributor

nicktobey commented Jul 28, 2023

In MySQL, booleans are actually tinyints, true and false are aliases for 1 and 0, respectively, and all non-zero integers are "truthy".

As a result, the three select queries below are all equivalent.

create table a (aa int);
insert into a values (1), (2);

create table b (bb int);
insert into b values (1), (2);

select * from a join b on true;
select * from a join b on 1;
select * from a join b on 2;

MySql output:

aa	bb
2	1
1	1
2	2
1	2
aa	bb
2	1
1	1
2	2
1	2
aa	bb
2	1
1	1
2	2
1	2

However, running the same query in Dolt produces:

+----+----+
| aa | bb |
+----+----+
| 2  | 2  |
| 1  | 2  |
| 2  | 1  |
| 1  | 1  |
+----+----+
+-------+----+
| aa    | bb |
+-------+----+
| NULL  | 2  |
| NULL  | 1  |
+-------+----+
+-------+----+
| aa    | bb |
+-------+----+
| NULL  | 2  |
| NULL  | 1  |
+-------+----+

Curiously, this only effects left/right joins. Inner joins in Dolt behave the same as MySQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer bug Something isn't working good first issue Good for newcomers good repro Easily reproducible bugs sql Issue with SQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant