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

bug: union all get wrong result #17096

Open
zhyass opened this issue Dec 21, 2024 · 1 comment · May be fixed by #17100
Open

bug: union all get wrong result #17096

zhyass opened this issue Dec 21, 2024 · 1 comment · May be fixed by #17100
Assignees

Comments

@zhyass
Copy link
Member

zhyass commented Dec 21, 2024

mysql> create table t1 (a int, b int);
Query OK, 0 rows affected (0.09 sec)

mysql> insert into t1 values (1, 2), (2, 3);
+-------------------------+
| number of rows inserted |
+-------------------------+
|                       2 |
+-------------------------+
1 row in set (0.21 sec)
Read 2 rows, 18.00 B in 0.123 sec., 16.28 rows/sec., 146.50 B/sec.

mysql> create table t2 (a int, b int);
Query OK, 0 rows affected (0.12 sec)

mysql> insert into t2 values (1, 2), (2, 3) ;
+-------------------------+
| number of rows inserted |
+-------------------------+
|                       2 |
+-------------------------+
1 row in set (0.19 sec)
Read 2 rows, 18.00 B in 0.104 sec., 19.17 rows/sec., 172.49 B/sec.

mysql> select a, b from (select * from t1 where a>1 union all select * from t2 where b>2);
+------+------+
| a    | b    |
+------+------+
|    2 |    3 |
|    2 |    3 |
+------+------+
2 rows in set (0.12 sec)
Read 4 rows, 36.00 B in 0.048 sec., 82.94 rows/sec., 746.45 B/sec.

mysql> select b,a from (select * from t1 where a>1 union all select * from t2 where b>2);
+------+------+
| b    | a    |
+------+------+
|    2 |    3 |
|    2 |    3 |
+------+------+
2 rows in set (0.15 sec)
Read 4 rows, 36.00 B in 0.060 sec., 66.63 rows/sec., 599.66 B/sec.
@zhyass zhyass self-assigned this Dec 21, 2024
@zhyass zhyass removed their assignment Dec 21, 2024
@zhyass
Copy link
Member Author

zhyass commented Dec 23, 2024

I tried to fix it but it doesn't look easy so PTAL @sundy-li

@sundy-li sundy-li self-assigned this Dec 23, 2024
@sundy-li sundy-li linked a pull request Dec 23, 2024 that will close this issue
11 tasks
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